From 041039cf33b3eaffce52ea9699e7081119a20c53 Mon Sep 17 00:00:00 2001 From: jannyHou Date: Mon, 9 Mar 2020 14:39:50 -0400 Subject: [PATCH] docs: update --- docs/site/migration/auth/example.md | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/site/migration/auth/example.md b/docs/site/migration/auth/example.md index 55aed1f576d7..e277203fd7b8 100644 --- a/docs/site/migration/auth/example.md +++ b/docs/site/migration/auth/example.md @@ -179,6 +179,9 @@ in the application constructor: {% include code-caption.html content="src/application.ts" %} ```ts +// Add this line to import the component +import {JWTAuthenticationComponent} from './components/jwt-authentication'; + export class AccessControlApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { @@ -336,7 +339,32 @@ Since the model and policy are already covered in section files are defined in folder [fixtures/casbin](https://github.com/strongloop/loopback-next/blob/master/examples/access-control-migration/fixtures/casbin). -5. Casbin persistency and synchronize(2nd Phase implementation, TBD) +5. Mount the casbin authorization system as a component + +The casbin authorizer, voter and enforcers above are packed under component +'src/components/casbin-authorization'. You can export their bindings in a +[component file](https://github.com/strongloop/loopback-next/blob/master/examples/access-control-migration/src/components/casbin-authorization/casbin-authorization-component.ts) +and mount the component in the application constructor: + +{% include code-caption.html content="src/application.ts" %} + +```ts +// Add this line to import the component +import {CasbinAuthorizationComponent} from './components/casbin-authorization'; + +export class AccessControlApplication extends BootMixin( + ServiceMixin(RepositoryMixin(RestApplication)), +) { + constructor(options: ApplicationConfig = {}) { + // ... + // Add this line to mount the casin authorization component + this.component(CasbinAuthorizationComponent); + // ... + } +} +``` + +6. Casbin persistency and synchronize(2nd Phase implementation, TBD) This will be supported at the 2nd phase of implementation. The plan is to have model or operation hooks to update the casbin policies when new data created. It