-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Steps to reproduce
The code snippet in the documentation for how to register authorization component with options doesn't add the options.
https://loopback.io/doc/en/lb4/Loopback-component-authorization.html#registering-the-authorization-component
Current Behavior
Options are not added to the authorization component.
const options: AuthorizationOptions = {
precedence: AuthorizationDecision.DENY,
defaultDecision: AuthorizationDecision.DENY,
};
const binding = app.component(AuthorizationComponent);
app.configure(binding.key).to(options);
app.component() has a void return type so binding will be undefined.
Expected Behavior
Options should be added to the authorization component.
The following worked for me:
import {
AuthorizationComponent,
AuthorizationOptions,
AuthorizationBindings,
} from '@loopback/authorization';
const options: AuthorizationOptions = {
precedence: AuthorizationDecision.ALLOW,
defaultDecision: AuthorizationDecision.DENY,
};
app.component(AuthorizationComponent);
app.configure(AuthorizationBindings.COMPONENT).to(options);
Link to reproduction sandbox
Additional information
Node: v10.14.0
@loopback/cli version: 1.29.0
@loopback/* dependencies:
- @loopback/authorization: ^0.4.8
Related Issues
See Reporting Issues for more tips on writing good issues