Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Mar 9, 2020
1 parent 217218d commit 041039c
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion docs/site/migration/auth/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 041039c

Please sign in to comment.