You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/build_and_test_cap.yml
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,19 @@
1
1
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
2
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
3
4
-
name: CAP sample - Build and Test
4
+
name: CAP sample
5
5
6
6
on:
7
7
push:
8
8
branches: [ "main" ]
9
+
paths:
10
+
- "ams-cap-nodejs-bookshop/**"
11
+
- ".github/workflows/build_and_test_cap.yml"
9
12
pull_request:
10
13
branches: [ "**" ]
14
+
paths:
15
+
- "ams-cap-nodejs-bookshop/**"
16
+
- ".github/workflows/build_and_test_cap.yml"
11
17
12
18
jobs:
13
19
npm:
@@ -16,7 +22,7 @@ jobs:
16
22
JAVA_HOME: /usr/lib/jvm/java-17-openjdk
17
23
strategy:
18
24
matrix:
19
-
node-version: [18.x, 20.x, 22.x]
25
+
node-version: [20.x, 22.x]
20
26
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
# SAP Identity Service Authentication and Authorization Sample
2
+
3
+
This project is a sample application that demonstrates how to use SAP Identity Service for authentication and authorization via the client libraries [`@sap/xssec`](https://www.npmjs.com/package/@sap/xssec) and [`@sap/ams`](https://www.npmjs.com/package/@sap/ams).
4
+
5
+
---
6
+
7
+
## Demonstrated Features
8
+
9
+
1.**Authentication via IAS (Identity Authentication Service)**:
10
+
- Uses the `@sap/xssec` library to authenticate users via SAP Identity Service.
11
+
12
+
1.**Authorization via AMS (Authorization Management Service)**:
13
+
- Uses the `@sap/ams` library to check user privileges for specific actions and resources and provide instance-based authorization.
14
+
- Demonstrates how to configure and use the `IdentityServiceAuthProvider` for authorization based on IAS tokens.
15
+
16
+
1.**Middleware Integration**:
17
+
- Demonstrates how to integrate the client libraries into an Express application for seamless access to the security context and authorization checks in any place where the `req` object is available.
18
+
19
+
1.**Technical communication** via SAP Identity Service APIs
20
+
- Demonstrates how the `IdentityServiceAuthProvider` can authorize principal propagation requests from other systems that consume SAP Identity Service APIs of this application. The resulting authorizations are the intersection of the user's policies and the policies defined for the consumed API.
21
+
22
+
1.**Mocking security contexts for Testing**:
23
+
- Shows how different security contexts can be mocked for testing without authenticating via a real IAS instance.
24
+
- Demonstrates how to compile DCL policies locally to DCN and use users with mocked policy assignments for testing without a real AMS instance.
25
+
26
+
1.**Privilege-Based UI Rendering**:
27
+
- Includes an example of how to retrieve potential user privileges to determine which UI elements to display.
28
+
29
+
---
30
+
31
+
## Project Structure
32
+
33
+
-**`server.js`**:
34
+
- The main application server setup.
35
+
36
+
-**`auth/authenticate.js` and `auth/authorize.js`**:
37
+
- Contains the main logic for setting up authentication and authorization.
38
+
39
+
-**`auth/dcl`**:
40
+
- Defines the authorization policies.
41
+
42
+
-**`db`**:
43
+
- A mock database with dummy data.
44
+
45
+
-**`service`**:
46
+
- Service layer of the application with request handlers for the REST API.
47
+
48
+
-**`ui`**:
49
+
- A simple UI to demonstrate features of this project when logged in with users that have different policies assigned.
50
+
51
+
-**`test`**:
52
+
- Tests against the REST API that demonstrate the expected result of the authorization checks.
53
+
54
+
---
55
+
56
+
## Testing
57
+
58
+
### Run Unit Tests
59
+
```bash
60
+
npm i
61
+
npm test
62
+
```
63
+
64
+
### Start server for local testing
65
+
```bash
66
+
NODE_ENV=test npm start
67
+
```
68
+
69
+
The application UI will be accessible under https://localhost:3000.
0 commit comments