npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cds-entra-id

v1.0.5

Published

Microsoft Entra ID Authorization extension for SAP Cloud Application Programming Model

Downloads

35

Readme

cds-entra-id

A SAP Cloud Application Programming Model (CAP) plugin to map Entra ID authorization to the cds.User scope.

It is intended as a drop-in authorization mapper for a CAP app running on Azure AppServices - not (!) locally. The plugin does not support any authentication flow, but the mapping of Entra ID artefacts to CAP roles for declarative authorization.

Requirements

:exclamation: Your CAP app must be protected by OAuth 2.0 authorization with Microsoft Entra ID, configured via the App ServiceSettingsAuthentication

Both Entra ID Groups (https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims#configure-groups-optional-claims) and App roles https://learn.microsoft.com/en-us/security/zero-trust/develop/configure-tokens-group-claims-app-roles are supported to be subsequentially used for annotation in CDS files.

Installation + Configuration

npm i --save cds-entra-id

Then tell your CAP app to use this plugin (see https://cap.cloud.sap/docs/node.js/cds-env#sources-for-cds-env for possible config file locations and configuration options).

E.g. in ./.cdsrc.json:

{
  "requires": {
    "auth": {
      "[development]": { // <-- let's keep local dev as is
        "kind": "mocked"
      },
      "[production]": { // <-- grow as you go when deployed to Azure
        "impl": "cds-entra-id"
      }
    }
  }
}

For Debugging purposes, you can set the enviornment variable DEBUG=cds-entra-id as with all CAP DEBUG options.

Usage

Annotate your .cds services as usual:

service its {
    @(requires: 'authenticated-user')
    function ok() returns String;
    @(requires: ['7b428506-466b-45b0-9cbf-4e1b20734874', 'test-app-role'])
    function nok() returns String;
}

The function import ok() requires any authenticated user, no matter the role or group.

However, nok() requires the logged in user

  • to be a member of the Entra ID group '7b428506-466b-45b0-9cbf-4e1b20734874' or
  • a member of the App role 'test-app-role'.

Why a GUID for an Entra ID group and not a regular name? Entra ID passes out group memberships only as GUIDs in order to prevent wrongful impersonation. As the note on https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-fed-group-claims explains:

"a group name is not unique, and display names can only be emitted for groups explicitly assigned to the application to reduce the security risks. Otherwise, any user could create a group with duplicate name and gain access in the application side."

The same website also states:

When you're using group membership for in-application authorization, it's preferable to use the group ObjectID attribute. The group ObjectID attribute is immutable and unique in Microsoft Entra ID. It's available for all groups.

And that's why cds-entra-id supports GUIDs for Entra ID group authorizations.

The App roles are app-specific (and not valid Entra ID-wide). They are relayed as regular names and can be used as such for CDS annotations.

Under the hood :blue_car:

The plugin parses the OAuth 2.0 claims into proper CAP User objects.

Additionally, it has no Node.js module dependencies - yay.

Contributing

:computer: hack away and PR!

  • please use conventional commits so the changelog can be auto-generated. Their usage here is guarded by :dog: husky.
  • please format the code w/ Prettier. A .prettierrc is in the repo.

License

This work is dual-licensed under Apache 2.0 and the Derived Beer-ware 🍺 License. The official license will be Apache 2.0 but finally you can choose between one of them if you use this work.

Thus, when you like this stuff, buy any (or all 😆) of the contributors a beer when you see them.