static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

feat(auth): Add custom auth support for Google and GitHub providers

Open andimarc opened this issue 1 year ago • 0 comments

Setup

The user must first create the necessary GitHub OAuth app and/or Google OAuth Client ID with the redirect URIs set to http://localhost:4280/.auth/login/github and http://localhost:4280/.auth/login/google respectively.

They must then add the "auth" configuration in their staticwebapp.config.json file and set the appropriate environment variables containing client ID and client secret values before running starting the SWA CLI.

GitHub Login

User clicks on "Log in with GitHub" link (http://localhost:4280/.auth/login/github), which redirects to https://github.com/login/oauth/authorize.

AppPage

User logs into GitHub if not already logged in.

GitHubLogin

User authorizes GitHub OAuth app if not already authorized for their account.

GitHubAuthorize

User is redirected back to the static web app.

GitHubLoggedIn

Google Login

User clicks on "Log in with Google" link (http://localhost:4280/.auth/login/google), which redirects to https://accounts.google.com/o/oauth2/v2/auth.

AppPage

User logs into Google if not already logged in.

GoogleLogin

User authorizes Google OAuth app if not already authorized for their account.

GoogleAuthorize

User is redirected back to the static web app.

GoogleLoggedIn

andimarc avatar Apr 25 '24 20:04 andimarc