Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions services/authentication-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ npm i @sourceloop/authentication-service
- It works for almost all authentication methods provided by this 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** -
Copy link

Copilot AI Dec 5, 2025

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).

Suggested change
- **Oauth- using Cognito** -
- **OAuth- using Cognito** -

Copilot uses AI. Check for mistakes.
- Make sure you have your cognito setup over aws. You can take reference from [here](https://docs.aws.amazon.com/cognito/latest/developerguide/authentication.html).
- add the below envs-

COGNITO_AUTH_CALLBACK_URL= \
COGNITO_AUTH_CLIENT_DOMAIN=\
COGNITO_AUTH_CLIENT_ID=\
COGNITO_AUTH_CLIENT_SECRET=\
COGNITO_AUTH_REGION=

COGNITO_AUTH_CALLBACK_URL refers to the API endpoint /auth/cognito-auth-redirect provided by authentication service
- we are using the loopback4-authentication package inside the backend service. we have setup the User, AuthClient UserCredential Models and the api /auth/cognito and /auth/cognito-auth-redirect via authentication service. You only need to bind the providers as stated in [loopback4-authentication](https://github.com/sourcefuse/loopback4-authentication)
- on redirecting back to the application with the code generated by the call back api , application can use that code to sent to /auth/token api to get the token for your application.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical error: 'sent' should be 'send' (infinitive form after 'to').

Suggested change
- on redirecting back to the application with the code generated by the call back api , application can use that code to sent to /auth/token api to get the token for your application.
- on redirecting back to the application with the code generated by the call back api , application can use that code to send to /auth/token api to get the token for your application.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing error: Extra space before comma after 'api'.

Suggested change
- on redirecting back to the application with the code generated by the call back api , application can use that code to sent to /auth/token api to get the token for your application.
- on redirecting back to the application with the code generated by the call back api, application can use that code to sent to /auth/token api to get the token for your application.

Copilot uses AI. Check for mistakes.


- **OAuth- using Azure AD** -

Expand Down Expand Up @@ -528,6 +543,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';
Expand Down Expand Up @@ -562,6 +579,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
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent capitalization: 'redis' should be 'Redis' to match proper noun convention.

Suggested change
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 uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

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:'

Suggested change
for redis, datasource example is as below
For Redis, the datasource example is as follows:

Copilot uses AI. Check for mistakes.
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {AnyObject, juggler} from '@loopback/repository';
import {readFileSync} from 'fs';
import {AuthCacheSourceName} from '@sourceloop/authentication-service';

const config = {
name: process.env.REDIS_NAME,
connector: 'kv-redis',
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: process.env.REDIS_PASSWORD,
db: process.env.REDIS_DATABASE,
url: process.env.REDIS_URL,
tls:
+process.env.REDIS_TLS_ENABLED! ||
(process.env.REDIS_TLS_CERT
? {
ca: readFileSync(process.env.REDIS_TLS_CERT),
}
: undefined),
sentinels:
+process.env.REDIS_HAS_SENTINELS! && process.env.REDIS_SENTINELS
? JSON.parse(process.env.REDIS_SENTINELS)
: undefined,
sentinelPassword:
+process.env.REDIS_HAS_SENTINELS! && process.env.REDIS_SENTINEL_PASSWORD
? process.env.REDIS_SENTINEL_PASSWORD
: undefined,
role:
+process.env.REDIS_HAS_SENTINELS! && process.env.REDIS_SENTINEL_ROLE
? process.env.REDIS_SENTINEL_ROLE
: undefined,
};

// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The `stop()` method is inherited from `juggler.DataSource`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class RedisDataSource
extends juggler.DataSource
implements LifeCycleObserver
{
static readonly dataSourceName = AuthCacheSourceName;
static readonly defaultConfig = config;

constructor(
@inject(`datasources.config.${process.env.REDIS_NAME}`, {optional: true})
dsConfig: AnyObject = config,
) {
if (
+process.env.REDIS_HAS_SENTINELS! &&
!!process.env.REDIS_SENTINEL_HOST &&
!!process.env.REDIS_SENTINEL_PORT
) {
dsConfig.sentinels = [
{
host: process.env.REDIS_SENTINEL_HOST,
port: +process.env.REDIS_SENTINEL_PORT,
},
];
}
super(dsConfig);
}
}
```


### Migrations

Expand Down
Loading