Skip to content

Commit 8f59785

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

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,47 @@ 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+
`custom-sequence.ts`
2986+
2987+
```ts title="custom-sequence.ts"
2988+
export class CustomSequence implements SequenceHandler {
2989+
@inject(SequenceActions.INVOKE_MIDDLEWARE, {optional: true})
2990+
protected invokeMiddleware: InvokeMiddleware = () => false;
2991+
...
2992+
2993+
async handle(context: RequestContext) {
2994+
...
2995+
...
2996+
// call custom registered middlewares in the pre-invoke chain
2997+
let finished = await this.invokeMiddleware(context, {
2998+
chain: CustomMiddlewareChain.PRE_INVOKE,
2999+
});
3000+
if (finished) return;
3001+
const result = await this.invoke(route, args);
3002+
this.send(response, result);
3003+
...
3004+
}
3005+
}
3006+
```
3007+
3008+
`application.ts`
3009+
3010+
```ts title="application.ts"
3011+
import {ClientAuthenticationMiddlewareProvider} from 'loopback4-authentication';
3012+
...
3013+
...
3014+
3015+
// bind middleware with custom options
3016+
this.middleware(ClientAuthenticationMiddlewareProvider, {
3017+
chain: CustomMiddlwareChain.PRE_INVOKE
3018+
});
3019+
3020+
```
3021+
29813022
### Passport Auth0
29823023

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

docs/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,46 @@ 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+
`custom-sequence.ts`
2986+
2987+
```ts title="custom-sequence.ts"
2988+
export class CustomSequence implements SequenceHandler {
2989+
@inject(SequenceActions.INVOKE_MIDDLEWARE, {optional: true})
2990+
protected invokeMiddleware: InvokeMiddleware = () => false;
2991+
...
2992+
2993+
async handle(context: RequestContext) {
2994+
...
2995+
...
2996+
// call custom registered middlewares in the pre-invoke chain
2997+
let finished = await this.invokeMiddleware(context, {
2998+
chain: CustomMiddlewareChain.PRE_INVOKE,
2999+
});
3000+
if (finished) return;
3001+
const result = await this.invoke(route, args);
3002+
this.send(response, result);
3003+
...
3004+
}
3005+
}
3006+
```
3007+
3008+
`application.ts`
3009+
3010+
```ts title="application.ts"
3011+
import {ClientAuthenticationMiddlewareProvider} from 'loopback4-authentication';
3012+
...
3013+
...
3014+
// bind middleware with custom options
3015+
this.middleware(ClientAuthenticationMiddlewareProvider, {
3016+
chain: CustomMiddlwareChain.PRE_INVOKE
3017+
});
3018+
3019+
```
3020+
29813021
### Passport Auth0
29823022

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

0 commit comments

Comments
 (0)