Skip to content

Commit

Permalink
Merge pull request Azure#901 from Timothyw0/developer/timothywang/rev…
Browse files Browse the repository at this point in the history
…ert-to-last-release-and-update-versions-url

fix: Update SWA versions.json metadata URL & chore: Prepare 2.0.2 release
  • Loading branch information
Timothyw0 authored Dec 16, 2024
2 parents c74de88 + 29ca328 commit 4ccea55
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 372 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/azuresdkdrop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- run: npm pack

- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v2
with:
name: package
path: "*.tgz"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
- run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
- run: npm pack
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v2
with:
name: static-web-apps-cli
path: "*.tgz"
2 changes: 1 addition & 1 deletion docs/www/docs/cli/swa.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is the commandline utility for streamlining local development for Azure Sta
- start emulator or bind to dev server
- deploy project to Azure Static Web Apps

If you don't enter any command and run `swa`, it will act as a macro command shortcut for `swa init`, `swa build`, `swa login` and `swa deploy`. The `swa init` command will only be executed if the `swa-cli.config.json` does not exist in the current folder.
If you don't enter any command and run `swa`, it will act as a macro command shorcut for `swa init`, `swa build`, `swa login` and `swa deploy`. The `swa init` command will only be executed if the `swa-cli.config.json` does not exist in the current folder.

The best way to get started is to use the `swa` command and follow the interactive prompts.

Expand Down
34 changes: 10 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/static-web-apps-cli",
"version": "2.0.1",
"version": "2.0.2",
"description": "Azure Static Web Apps CLI",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -49,7 +49,6 @@
"internal-ip": "^6.2.0",
"json-schema-library": "^9.3.5",
"json-source-map": "^0.6.1",
"jwt-decode": "^4.0.0",
"keytar": "^7.9.0",
"node-fetch": "^2.7.0",
"open": "^8.4.2",
Expand Down
64 changes: 1 addition & 63 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const __dirname = path.dirname(__filename);
export const DEPLOY_BINARY_NAME = "StaticSitesClient";
export const DEPLOY_BINARY_STABLE_TAG = "stable";
export const DEPLOY_FOLDER = path.join(os.homedir(), ".swa", "deploy");
export const STATIC_SITE_CLIENT_RELEASE_METADATA_URL = "https://swalocaldeploy.azureedge.net/downloads/versions.json";
export const STATIC_SITE_CLIENT_RELEASE_METADATA_URL = "https://aka.ms/swalocaldeploy";

// Data-api-builder related constants
export const DATA_API_BUILDER_BINARY_NAME = "DataApiBuilder";
Expand Down Expand Up @@ -49,68 +49,6 @@ export const SWA_AUTH_CONTEXT_COOKIE = `StaticWebAppsAuthContextCookie`;
export const SWA_AUTH_COOKIE = `StaticWebAppsAuthCookie`;
export const ALLOWED_HTTP_METHODS_FOR_STATIC_CONTENT = ["GET", "HEAD", "OPTIONS"];

// Custom Auth constants
export const SUPPORTED_CUSTOM_AUTH_PROVIDERS = ["google", "github", "aad", "facebook", "twitter", "dummy"];
/*
The full name is required in staticwebapp.config.json's schema that will be normalized to aad
https://learn.microsoft.com/en-us/azure/static-web-apps/authentication-custom?tabs=aad%2Cinvitations
*/
export const ENTRAID_FULL_NAME = "azureActiveDirectory";
export const CUSTOM_AUTH_TOKEN_ENDPOINT_MAPPING: AuthIdentityTokenEndpoints = {
google: {
host: "oauth2.googleapis.com",
path: "/token",
},
github: {
host: "github.com",
path: "/login/oauth/access_token",
},
aad: {
host: "login.microsoftonline.com",
path: "/tenantId/oauth2/v2.0/token",
},
facebook: {
host: "graph.facebook.com",
path: "/v11.0/oauth/access_token",
},
twitter: {
host: "api.twitter.com",
path: "/2/oauth2/token",
},
};
export const CUSTOM_AUTH_USER_ENDPOINT_MAPPING: AuthIdentityTokenEndpoints = {
google: {
host: "www.googleapis.com",
path: "/oauth2/v2/userinfo",
},
github: {
host: "api.github.com",
path: "/user",
},
aad: {
host: "graph.microsoft.com",
path: "/oidc/userinfo",
},
twitter: {
host: "api.twitter.com",
path: "/2/users/me",
},
};
export const CUSTOM_AUTH_ISS_MAPPING: AuthIdentityIssHosts = {
google: "https://account.google.com",
github: "",
aad: "https://graph.microsoft.com",
facebook: "https://www.facebook.com",
twitter: "https://www.x.com",
};
export const CUSTOM_AUTH_REQUIRED_FIELDS: AuthIdentityRequiredFields = {
google: ["clientIdSettingName", "clientSecretSettingName"],
github: ["clientIdSettingName", "clientSecretSettingName"],
aad: ["clientIdSettingName", "clientSecretSettingName", "openIdIssuer"],
facebook: ["appIdSettingName", "appSecretSettingName"],
twitter: ["consumerKeySettingName", "consumerSecretSettingName"],
};

export const AUTH_STATUS = {
NoAuth: 0,
HostNameAuthLogin: 1,
Expand Down
17 changes: 7 additions & 10 deletions src/msha/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@ import type http from "node:http";
import { serializeCookie } from "../../core/utils/cookie.js";
import { logger } from "../../core/utils/logger.js";
import { response as newResponse } from "../../core/utils/net.js";
import { SUPPORTED_CUSTOM_AUTH_PROVIDERS } from "../../core/constants.js";

function getAuthPaths(isCustomAuth: boolean): Path[] {
const paths: Path[] = [];

if (isCustomAuth) {
const supportedAuthsRegex = SUPPORTED_CUSTOM_AUTH_PROVIDERS.join("|");

paths.push({
method: "GET",
// only match for providers with custom auth support implemented (github, google, aad, facebook, twitter)
route: new RegExp(`^/\\.auth/login/(?<provider>${supportedAuthsRegex})/callback(\\?.*)?$`, "i"),
// only match for providers with custom auth support implemented (github, google)
route: /^\/\.auth\/login\/(?<provider>github|google|dummy)\/callback(\?.*)?$/i,
function: "auth-login-provider-callback",
});
paths.push({
method: "GET",
// only match for providers with custom auth support implemented (github, google, aad, facebook, twitter)
route: new RegExp(`^/\\.auth/login/(?<provider>${supportedAuthsRegex})(\\?.*)?$`, "i"),
// only match for providers with custom auth support implemented (github, google)
route: /^\/\.auth\/login\/(?<provider>github|google|dummy)(\?.*)?$/i,
function: "auth-login-provider-custom",
});
paths.push({
method: "GET",
// For providers with custom auth support not implemented, revert to old behavior
route: /^\/\.auth\/login\/(?<provider>twitter|[a-z]+)(\?.*)?$/i,
route: /^\/\.auth\/login\/(?<provider>aad|twitter|facebook|[a-z]+)(\?.*)?$/i,
function: "auth-login-provider",
});
paths.push({
Expand All @@ -36,7 +33,7 @@ function getAuthPaths(isCustomAuth: boolean): Path[] {
} else {
paths.push({
method: "GET",
route: /^\/\.auth\/login\/(?<provider>github|twitter|google|facebook|[a-z0-9]+)(\?.*)?$/i,
route: /^\/\.auth\/login\/(?<provider>aad|github|twitter|google|facebook|[a-z]+)(\?.*)?$/i,
function: "auth-login-provider",
});
}
Expand All @@ -54,7 +51,7 @@ function getAuthPaths(isCustomAuth: boolean): Path[] {
},
{
method: "GET",
route: /^\/\.auth\/purge\/(?<provider>aad|github|twitter|google|facebook|[a-z0-9]+)(\?.*)?$/i,
route: /^\/\.auth\/purge\/(?<provider>aad|github|twitter|google|facebook|[a-z]+)(\?.*)?$/i,
// locally, all purge requests are processed as logout requests
function: "auth-logout",
},
Expand Down
Loading

0 comments on commit 4ccea55

Please sign in to comment.