| Component | Usage |
| Odata Service | To print JWT token |
| XSUAA | Generate JWT Token |
| Approuter | Read the JWT Token and pass it to ODATA service |
Branch Name | Purpose |
without-uaa | App without XSUAA service |
with-uaa | App with XSUAA service but without Approuter |
with-approuter | App with XSUAA service and Approuter |
mkdir cap-test-jwtcds initOnly function import is added the service which returns the JWT token as a string
@path: '/test'
service TestService {
function getJWTToken() returns String
};const cds = require('@sap/cds');
module.exports = async function () {
this.on("getJWTToken", async (req) => {
// As Approuter module and XSUAA service is added
// That is why JWT Token is returned after user got authenticated by Approuter from UAA service
let sToken = "";
if (req.headers.authorization) {
sToken = req.headers.authorization;
}
return sToken;
})
}npm run deploy/test/getJWTToken()cds add xsuaacds add approutercf de cap-test-jwt-srv "destinations": [
{
"name": "srv-api",
"url": "http://localhost:4004",
"forwardAuthToken": true
}
],You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 33 | |
| 28 | |
| 24 | |
| 14 | |
| 13 | |
| 12 | |
| 11 | |
| 10 | |
| 9 | |
| 8 |