Skip to content

fix code snippet in registering authorization component with options documentation  #4576

@alyhegazy

Description

@alyhegazy

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions