-
Notifications
You must be signed in to change notification settings - Fork 80
Readme auth #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Readme auth #2378
Changes from all commits
6f34707
42e1872
c470c08
9af2fe6
9e779f0
bc96338
ccd3397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -142,6 +142,36 @@ npm i @sourceloop/authentication-service | |||||||||||||||||||||
| - Use `/verify-otp` to enter otp or code from authenticator app. | ||||||||||||||||||||||
| for using Google Authenticator user needs to pass client id in the payload which is optional in case for OTP | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - **Oauth- using Cognito** - | ||||||||||||||||||||||
| - Make sure your AWS Cognito setup is properly configured. You can refer to the official documentation [here](https://docs.aws.amazon.com/cognito/latest/developerguide/authentication.html). | ||||||||||||||||||||||
| - Add the following environment variables: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| COGNITO_AUTH_CALLBACK_URL= \ | ||||||||||||||||||||||
| COGNITO_AUTH_CLIENT_DOMAIN=\ | ||||||||||||||||||||||
| COGNITO_AUTH_CLIENT_ID=\ | ||||||||||||||||||||||
| COGNITO_AUTH_CLIENT_SECRET=\ | ||||||||||||||||||||||
| COGNITO_AUTH_REGION= | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| COGNITO_AUTH_CALLBACK_URL should point to the /auth/cognito-auth-redirect endpoint provided by the authentication service. | ||||||||||||||||||||||
| - Add NODE_TLS_REJECT_UNAUTHORIZED=0 in environment to disables TLS/SSL certificate validation in Node.js. for ***Development only***. | ||||||||||||||||||||||
| - We are using the loopback4-authentication package in the backend service. The User, AuthClient, and UserCredential models, along with the /auth/cognito and /auth/cognito-auth-redirect APIs, have been set up in the authentication service. You only need to bind the required providers as described in the [loopback4-authentication](https://github.com/sourcefuse/loopback4-authentication) | ||||||||||||||||||||||
| - When the application is redirected back with the authorization code generated by the callback API, the application can send this code to the /auth/token endpoint to obtain the access token for your application. | ||||||||||||||||||||||
| - Create an auth_client entry in your database using the query below: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```typescript | ||||||||||||||||||||||
| INSERT INTO auth_clients (client_id, client_secret, secret) | ||||||||||||||||||||||
| VALUES ('temp_client', 'temp_secret', 'secret'); | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
| Use the client_id and client_secret to invoke the auth/cognito API from the frontend. | ||||||||||||||||||||||
| - Additionally, configure the redirect_url for this auth client to point to the frontend URL where you want the user to be redirected after successful authorization from Cognito. The user will be redirected to this URL with a code query parameter, which can then be exchanged for a token using the /auth/token endpoint. | ||||||||||||||||||||||
| - The OAuth endpoints are meant to be accessed from a web browser, not from API testing tools. The API explorer shows you | ||||||||||||||||||||||
| the endpoint structure, but you must test OAuth flows through: | ||||||||||||||||||||||
| - Your frontend application | ||||||||||||||||||||||
| - A real browser session | ||||||||||||||||||||||
| - Tools specifically designed for OAuth testing (like Postman with proper OAuth 2.0 support) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Kindly create a Dummy web App to hit and manage the apis. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - **OAuth- using Azure AD** - | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Passport strategy for authenticating via Azure Ad using [passport-azure-ad](https://www.npmjs.com/package/passport-azure-ad). | ||||||||||||||||||||||
|
|
@@ -528,6 +558,8 @@ sequenceDiagram | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| Here is a sample Implementation `DataSource` implementation using environment variables and PostgreSQL as the data source. The `auth-multitenant-example` utilizes both Redis and PostgreSQL as data sources. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| run - ```npm install loopback-connector-postgresql --save``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```typescript | ||||||||||||||||||||||
| import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core'; | ||||||||||||||||||||||
| import {juggler} from '@loopback/repository'; | ||||||||||||||||||||||
|
|
@@ -562,6 +594,77 @@ export class AuthenticationDbDataSource | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
| redis datasource - | ||||||||||||||||||||||
| run - ```npm install loopback-connector-kv-redis --save``` | ||||||||||||||||||||||
| ```typescript | ||||||||||||||||||||||
| for redis, datasource example is as below | ||||||||||||||||||||||
|
Comment on lines
+597
to
+600
|
||||||||||||||||||||||
| redis datasource - | |
| run - ```npm install loopback-connector-kv-redis --save``` | |
| ```typescript | |
| for redis, datasource example is as below | |
| Redis datasource - | |
| run - ```npm install loopback-connector-kv-redis --save``` | |
| ```typescript | |
| For Redis, datasource example is as below |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization and style: Should be formatted as a proper sentence, e.g., 'For Redis, the datasource example is as follows:'
| for redis, datasource example is as below | |
| For Redis, the datasource example is as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization: 'Oauth' should be 'OAuth' to match the naming convention used elsewhere in the document (see line 160).