Auth
The auth module contains all the functionality required to authentication users, including SSO.
Usage
Import the module into your application:
//app.module.ts
import { forwardRef, Module } from '@nestjs/common'
import { AuthModule } from '@juicyllama/core'
@Module({
imports: [forwardRef(() => AuthModule)],
})
export class AppModule {}
Out of the box, this will add all the authentication endpoints to your application.
Single Sign On (SSO)
The application supports SSO via the following providers:
Provider |
---|
Google SSO
- Create a new project in the Google Cloud Console
- Set up the Oauth consent screen
- Add the following scopes:
.../auth/userinfo.email
.../auth/userinfo.profile
- Create a new OAuth 2.0 Client ID
- Add your Javascript origins e.g.
https://api.<your-domain>
for your backend API application - Add the frontend redirect URI (must point to the login page) e.g.
https://app.<your-domain>/login
for the frontend application - Follow the verification process to make the app public if you need to
- Add the following environment variables to your application:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_LOGIN_SCOPES='email profile' # space separated scopes. if not provided "email profile" will be used as default
- To show the Google SSO button on the frontend, add the following environment variables to your frontend application:
VITE_SSO_GOOGLE=true
For customizing how the Google SSO button looks, see the Frontend Auth Docs