cds-entra-id
A CAP plugin that maps Microsoft Entra ID groups and app roles onto cds.User roles, so @requires and @restrict keep working for a CAP app hosted on Azure App Services.
Lets @requires and @restrict keep working when the identity provider is Entra ID rather than XSUAA or IAS — the case for a CAP app hosted on Azure App Services.
Facts
Where it sits
Who is behind it
In the atlas: maintains 7, contributes to 53, wrote 2@vobumaintainerGregor WolfContributes to this
In the atlas: maintains 17, contributes to 59, wrote 2@gregorwolf1 contributor
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 25 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
PracticalFunctional boundary
It performs no authentication flow of its own. The app must already be protected by Entra ID OAuth 2.0 at the App Service level; this only maps the resulting claims. It is explicitly not intended to run locally.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- Independently maintained
- Runtime
- Node.js
As a CDS plugin
- Declared for
- ^7
- Distributed through
- npm
Connections
Deciding who may read or change what, down to instance level
Download
Install
npm add cds-entra-idDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from vobu/cds-entra-id under Apache-2.0, readcds-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
❗ Your CAP app must be protected by OAuth 2.0 authorization with Microsoft Entra ID, configured via the App Service → Settings → Authentication
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 IDgroup '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
ObjectIDattribute. The groupObjectIDattribute 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 🚙
The plugin parses the OAuth 2.0 claims into proper CAP User objects.
Additionally, it has no Node.js module dependencies - yay.
Contributing
💻 hack away and PR!
- please use conventional commits so the changelog can be auto-generated. Their usage here is guarded by 🐶 husky.
- please format the code w/ Prettier. A
.prettierrcis 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.
History
Others providing
Compare all 7 on the Authorization page →- SAP Authorization and Trust Management serviceSAP Authorization and Trust Management serviceThe OAuth server behind a BTP application: issues the JWT the app checks, holds the scopes and role collections it checks against, and brokers trust to an identity provider. Bound, never installed.sap official, btpOAuth server issuing JWTs and holding scopes for BTP apps
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versions
- cap-toolkitcap-toolkitA utility bundle for CAP handlers, with a chainable HandlerBuilder, role checks, validation rules and query helpers, collecting boilerplate that otherwise repeats across projects into one dependency.independent, capUtility bundle for CAP handlers: builder, roles, validation, queries
- @sap/ams-dev@sap/ams-devCompiles the DCL authorization policies of SAP's Authorization Management Service to DCN, so an AMS-secured application runs and is tested on a laptop.sap official, capCompiler from AMS DCL policies to DCN for local runs and tests
- @sap/ams@sap/amsDecides what a signed-in user may do in a Node.js application that authenticates through SAP Cloud Identity Services, from policies written in DCL.sap official, capAuthorization from DCL policies for Node.js apps on SAP Cloud Identity
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtime
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:vobu-cds-entra-id- JSON
- /artifacts/vobu-cds-entra-id.json
- MCP
- Connecting an agent