Skip to content

Commit 160724b

Browse files
committed
docs(docs): update README.md file
256
1 parent 2e1f22b commit 160724b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,44 @@ this.component(AuthenticationComponent);
29782978
This binding needs to be done before adding the Authentication component to your application.
29792979
Apart from this all other steps for authentication for all strategies remain the same.
29802980

2981+
### Custom Sequence Support
2982+
2983+
You can also configure `ClientAuthenticationMiddlewareProvider` and `UserAuthenticationMiddlewareProvider` options, which can be invoked using a custom sequence. See the sample below.
2984+
2985+
```ts title="custom-sequence.ts"
2986+
export class CustomSequence implements SequenceHandler {
2987+
@inject(SequenceActions.INVOKE_MIDDLEWARE, {optional: true})
2988+
protected invokeMiddleware: InvokeMiddleware = () => false;
2989+
...
2990+
2991+
async handle(context: RequestContext) {
2992+
...
2993+
...
2994+
// call custom registered middlewares in the pre-invoke chain
2995+
let finished = await this.invokeMiddleware(context, {
2996+
chain: CustomMiddlewareChain.PRE_INVOKE,
2997+
});
2998+
if (finished) return;
2999+
const result = await this.invoke(route, args);
3000+
this.send(response, result);
3001+
...
3002+
}
3003+
}
3004+
```
3005+
3006+
application.ts
3007+
3008+
```ts title="application.ts"
3009+
import {ClientAuthenticationMiddlewareProvider} from 'loopback4-authentication';
3010+
...
3011+
...
3012+
//
3013+
this.middleware(ClientAuthenticationMiddlewareProvider, {
3014+
chain: CustomMiddlwareChain.PRE_INVOKE
3015+
});
3016+
3017+
```
3018+
29813019
### Passport Auth0
29823020

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

0 commit comments

Comments
 (0)