Skip to content

Commit

Permalink
Refactor custom auth files to generic functions for all auth providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Wang committed Aug 7, 2024
1 parent c2016f6 commit 8386aab
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 323 deletions.
35 changes: 35 additions & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,44 @@ export const SWA_RUNTIME_CONFIG_MAX_SIZE_IN_KB = 20; // 20kb
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"];
// Full name is required in staticwebapp.config.json's schema so we will normalize it to aad
export const AAD_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.microsoft.com",
path: "/tenantId/oauth/v2.0/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",
},
};
export const CUSTOM_AUTH_ISS_MAPPING: AuthIdentityIssHosts = {
google: "https://account.google.com",
github: "",
aad: "https://graph.microsoft.com",
};

export const AUTH_STATUS = {
NoAuth: 0,
Expand Down
Loading

0 comments on commit 8386aab

Please sign in to comment.