Skip to content

Commit be12583

Browse files
authored
Merge pull request #129 from sourcefuse/automated-docs-sync/loopback4-authentication
Sync loopback4-authentication Docs
2 parents 6c3c246 + e833898 commit be12583

File tree

1 file changed

+41
-1
lines changed
  • docs/arc-api-docs/extensions/loopback4-authentication

1 file changed

+41
-1
lines changed

docs/arc-api-docs/extensions/loopback4-authentication/README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ npm install loopback4-authentication
5656

5757
## Quick Starter
5858

59-
For a quick starter guide, you can refer to our [loopback 4 starter](https://github.com/sourcefuse/loopback4-starter) application which utilizes all of the above auth strategies from the extension in a simple multi-tenant application. Refer to the auth module [there](https://github.com/sourcefuse/loopback4-starter/tree/master/src/modules/auth) for specific details on authentication.
59+
For a quick starter guide, you can refer to our [loopback 4 starter](https://github.com/sourcefuse/loopback4-starter) application which utilizes all of the above auth strategies from the extension in a simple multi-tenant application. Refer to the auth module [there](https://github.com/sourcefuse/loopback4-starter/tree/master/src/modules/auth) for specific details on authentication mechanism.
6060

6161
## Detailed Usage
6262

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