Skip to content

van-ibm/loopback-appid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loopback-appid

Conveniently adds an IBM App ID authentication strategy to Loobpack 4.

Usage

Within your index.ts main function, add the authentication strategy to your app.

import { AppIdAuthentication } from 'loopback-appid';
...

export async function main(options: ApplicationConfig = {}) {
  const app = new Application(options);

  // creates an authentication strategy for appid
  const appid = new AppIdAuthentication(app);
...
}

Then in your controller, decorate your APIs with the @authenticate decorator.

import { AuthenticationBindings, UserProfile, authenticate } from '@loopback/authentication';
...

constructor(
    @inject(AuthenticationBindings.CURRENT_USER, { optional: true }) private user: UserProfile,
    @repository(OrderRepository) protected orderRepository: OrderRepository,
  ) { }
...

@authenticate('appid-api-strategy')
@get(`/orders/{orderId}`)
async orderById(
  @param.path.string('orderId') orderId: string
): Promise<Order> {
  return await this.orderRepository.findById(orderId);
}

About

Loopback authentication component for IBM App ID

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published