Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@entur-partner/permission-client-node

Package Overview
Dependencies
Maintainers
5
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur-partner/permission-client-node

Node client library for Permission Store

  • 1.3.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

Permission Client for Node

Javascript modul som tilbyr en cache av bruker rettigheter fra Permission Store.

Oppsett for bruk

npm install @entur-partner/permission-client-node

# eller hvis du bruker Yarn:
yarn add @entur-partner/permission-client-node

Eksempel på bruk

TokenFactory

Benyttes for å hente ut access tokens from Auth0 ved bruk av klient id og klient hemmelighet (Auth0 Clients)

import {TokenOptions, TokenFactory} from '@entur-private/permission-client-node'
const clientTokenOptions : TokenOptions = {
    domain: 'internal.dev.entur.org',
    clientId: '<clientId>',
    clientSecret: '<secret>',
    audience: 'https://api.dev.entur.io',
    refreshAt: 600  // Forny token når den utgår om 10 minutter.
}
const accessTokenFactory = new TokenFactory(clientTokenOptions);

// Eksempel bruk av TokenFactory
const accessToken = await accessTokenFactory.getAccessToken();

AuthorizeCache

Ønsker en å sjekke hvilke rettigheter en bruker har i Permission Store benyttes PermissionClient.

import {AuthorizeCacheType, Application, ApplicationPermission, PermissionDeliverRepository} from '@entur-private/permission-client-node'
import PermissionClient from '@entur-private/permission-client-node'
const application : Application = {
    name : 'TestApplication',
    refreshRate : 300  // Hver 5 minutt sjekkes Permission Store for endringer
}
const permissionStoreUrl = 'https://api.dev.entur.io/permission-store/v1';
const repository = new PermissionDeliverRepository(application, accessTokenFactory, permissionStoreUrl);

// Definerer rettigheter som benyttes av tjenesten
const applicationpermissions : ApplicationPermission[] = [];
applicationpermissions.push({operation: 'produkt', access: 'les', responsibilityType: null});
applicationpermissions.push({operation: 'produkt', access: 'les', responsibilityType: 'produkt.organisation'});
applicationpermissions.push({operation: 'produkt', access: 'les', responsibilityType: 'produkt.id'});

const autorizeCache = await PermissionClient(AuthorizeCacheType.IN_MEMORY, applicationpermissions, repository);

/* autorizeCache are ready to be used like:
const hasAccess = autorizeCache.checkBusinessCapabilityPermission(authoritySubject, businessCapability);
const hasAccess = autorizeCache.checkResponsibilitySetPermission(authoritySubject, responsibilitySet);
const userPermissions = getPermissions(authoritySubject);
*/

Bidrag til vidreutvikling

Clone modulen fra Bitbucket med:

git clone https://<username>@bitbucket.org/enturas/permission-client-node.git

Innstaller avhengigeter fra konsoll på roten av prosjektet:

npm install

Enhetstester utviklet i Jest kjøres ned:

npm test

Publisering

Opprett en NPM user account på https://www.npmjs.com/signup. Send brukeren din til tech-lead i Entur Partner og be om å bli lagt til i Entur Partner organisation.

Publisering utføres ved å skrive:

npm publish

FAQs

Package last updated on 19 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc