Skip to content

Latest commit

 

History

History
119 lines (79 loc) · 4.27 KB

ExternalLogins.md

File metadata and controls

119 lines (79 loc) · 4.27 KB

External Logins

Generic External Login Flow

Code Locations

Application entry point src/client/index.html in the <head> section (COOP header required to avoid errors during google auth popup):

<script src="https://accounts.google.com/gsi/client" async defer></script>
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin-allow-popups">

Button components:

  • src/client/components/auth/GoogleLoginButton.tsx
  • src/client/components/auth/MicrosoftLoginButton.tsx

Login page: src/client/pages/auth/Login.tsx

  • <GoogleLoginButton />
  • <MicrosoftLoginButton />

Sign-up page: src/client/pages/auth/SignUp.tsx

  • <GoogleLoginButton />
  • <MicrosoftLoginButton />

Environment setting: .env

  • GOOGLE_API_CLIENT_ID
  • GOOGLE_API_SECRET

Strongly typed environment setting reference: GlobalSettings.cs:

  • GOOGLE_API_CLIENT_ID

Service endpoints: WebServer/Controllers/AccountController.cs:

  • LoginGoogle
  • LoginMicrosoft
  • MicrosoftLoginRedirect

Third Party Library Dependencies

Npm dependencies:

  • @azure/msal-browser

Npm dev dependencies:

  • @types/gtag.js
  • @types/google.accounts
  • @types/google-one-tap

Nuget packages:

  • Google.Apis.Auth
  • Microsoft.AspNetCore.Authentication.Google
  • Microsoft.AspNetCore.Authentication.JwtBearer

Account Setup

These UI's change from time to time so this might not be exactly how to do it, but it should be similar.

Microsoft Login Account Setup

Azure -> App Registrations

Initial screen asks for display name. Ignore the redirect URIs initially - those will be updated later.

After creation, there should be a "Manage" left nav link - most of the config options are within this submenu.

Important fields:

The client_id you need to copy into your client code is also called the "application id" and can be found in the app "overview" section.

Other notes:

  • A verified domain is required to get this working in production for all users rather than just test users (see the Branding and properties page -> publisher domain)

Google Login Account Setup

Google developer console

  • Create a project
  • Create an OAuth 2.0 credential (left nav, OAuth consent screen -> External user type)
  • Add all appropriate javascript origins, including ports for local development. Examples:
  • In OAuth consent screen there is an "edit app" button, be sure to set "Your non-sensitive scopes" to have .../auth/userinfo.email, .../auth/userinfo.profile and openid

Create API credential: