Skip to content

Commit

Permalink
docs(docs): update README.md file
Browse files Browse the repository at this point in the history
256
  • Loading branch information
rashisf committed Jan 8, 2025
1 parent 2e1f22b commit 23ae356
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,43 @@ this.component(AuthenticationComponent);
This binding needs to be done before adding the Authentication component to your application.
Apart from this all other steps for authentication for all strategies remain the same.

### Custom Sequence Support

You can also configure `ClientAuthenticationMiddlewareProvider` and `UserAuthenticationMiddlewareProvider` options, which can be invoked using a custom sequence. See the sample below.

```ts title="custom-sequence.ts"
export class CustomSequence implements SequenceHandler {
@inject(SequenceActions.INVOKE_MIDDLEWARE, {optional: true})
protected invokeMiddleware: InvokeMiddleware = () => false;
...

async handle(context: RequestContext) {
...
...
// call custom registered middlewares in the pre-invoke chain
let finished = await this.invokeMiddleware(context, {
chain: CustomMiddlewareChain.PRE_INVOKE,
});
if (finished) return;
const result = await this.invoke(route, args);
this.send(response, result);
...
}
}
```

```ts title="application.ts"
import {ClientAuthenticationMiddlewareProvider} from 'loopback4-authentication';
...
...

// bind middleware with custom options
this.middleware(ClientAuthenticationMiddlewareProvider, {
chain: CustomMiddlwareChain.PRE_INVOKE
});

```

### Passport Auth0

In order to use it, run `npm install passport-auth0` and `npm install @types/passport-auth0`.
Expand Down
36 changes: 36 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,42 @@ this.component(AuthenticationComponent);
This binding needs to be done before adding the Authentication component to your application.
Apart from this all other steps for authentication for all strategies remain the same.

### Custom Sequence Support

You can also configure `ClientAuthenticationMiddlewareProvider` and `UserAuthenticationMiddlewareProvider` options, which can be invoked using a custom sequence. See the sample below.

```ts title="custom-sequence.ts"
export class CustomSequence implements SequenceHandler {
@inject(SequenceActions.INVOKE_MIDDLEWARE, {optional: true})
protected invokeMiddleware: InvokeMiddleware = () => false;
...

async handle(context: RequestContext) {
...
...
// call custom registered middlewares in the pre-invoke chain
let finished = await this.invokeMiddleware(context, {
chain: CustomMiddlewareChain.PRE_INVOKE,
});
if (finished) return;
const result = await this.invoke(route, args);
this.send(response, result);
...
}
}
```

```ts title="application.ts"
import {ClientAuthenticationMiddlewareProvider} from 'loopback4-authentication';
...
...
// bind middleware with custom options
this.middleware(ClientAuthenticationMiddlewareProvider, {
chain: CustomMiddlwareChain.PRE_INVOKE
});

```

### Passport Auth0

In order to use it, run `npm install passport-auth0` and `npm install @types/passport-auth0`.
Expand Down

0 comments on commit 23ae356

Please sign in to comment.