Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
583 stars 109 forks source link

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

Closed andimarc closed 1 month ago

andimarc commented 2 months ago

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