
Select Default Attributes from Trust Tab
var express = require('express');
var app = express();
const request = require('request');
const bodyParser = require('body-parser');
var approuter = require('@sap/approuter');
const jwtDecode = require('jwt-decode');
var ar = new approuter();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(__dirname +'/'));
ar.beforeRequestHandler.use('/jwtdecode', function (req, res, next) {
if (!req.user) {
res.statusCode = 403;
res.end(`Missing JWT Token`);
} else {
res.statusCode = 200;
res.end(`${JSON.stringify(jwtDecode(req.user.token.accessToken))}`);
}
});
ar.start();
// serve app
app.get('/', function(req, res){
res.sendFile('index.html');
console.log('[server] index served');
});
{
"name": "userinfo",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "Prashant Patil",
"license": "ISC",
"dependencies": {
"@sap/approuter": "6.5.0",
"express": "*",
"jwt-decode": "2.2.0",
"request": "latest"
}
}
{
"welcomeFile": "index.html",
"authenticationMethod": "route",
"routes": [
{
"source": "/*",
"localDir": "./",
"authenticationType": "xsuaa"
}
]
}
{
"xsappname": "userInfo",
"tenant-mode": "dedicated",
"description": "Security profile of getuserinfo",
"scopes": [
{
"name": "uaa.user",
"description": "UAA"
},
{
"name": "$XSAPPNAME.Display",
"description": "display"
}
],
"attributes": [
{
"name": "Country",
"description": "Country",
"valueType": "s"
},
{
"name": "City",
"description": "City",
"valueType": "string"
},
{
"name": "EmployeeNum",
"description": "EmployeeNum",
"valueType": "int"
},
{
"name": "Groups",
"description": "Groups",
"valueType": "s"
}
],
"role-templates": [
{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": ["uaa.user"]
},
{
"name": "Viewer",
"description": "View all",
"scope-references": ["$XSAPPNAME.Display"],
"attribute-references": ["Country", "City", "EmployeeNum", "Groups"]
}
]
}
cf create-service xsuaa application userinfo-uaa -c xs-security.json
---
applications:
- name: user-info
memory: 128M
instances: 1
services:
- userinfo-uaa
cf push user-info
{
"jti": "******",
"ext_attr": {
"enhancer": "XSUAA",
"zdn": "********"
},
"xs.system.attributes": {
"xs.saml.groups": [],
"xs.rolecollections": []
},
"given_name": "Prashant",
"xs.user.attributes": {},
"family_name": "Patil",
"sub": "********",
"scope": [
"openid",
"uaa.user"
],
"client_id": "********",
"cid": "********",
"azp": "********",
"grant_type": "authorization_code",
"user_id": "*******",
"origin": "********",
"user_name": "P000004",
"email": "******@********.com",
"auth_time": ****,
"rev_sig": "****",
"iat": ****,
"exp": *****,
"iss": "https://********/oauth/token",
"zid": "*****",
"aud": [
"uaa",
"openid"
]
}
Now Navigate to Trust Configuration & Select your custom IdP,
Select Role Collection Mappings ,and Click on New Role Collection Mappings,
{
"jti": "******",
"ext_attr": {
"enhancer": "XSUAA",
"zdn": "********"
},
"xs.system.attributes": {
"xs.saml.groups": [
"SAML_XSUAA_Group"
],
"xs.rolecollections": [
"userinfo"
]
},
"given_name": "Prashant",
"xs.user.attributes": {
"City": [
"Pune"
],
"Country": [
"IN"
],
"EmployeeNum": [
"760"
],
"Groups": [
"SAML_XSUAA_Group"
]
},
"family_name": "Patil",
"sub": "********",
"scope": [
"userInfo!t159.Display",
"openid",
"uaa.user"
],
"client_id": "********",
"cid": "********",
"azp": "********",
"grant_type": "authorization_code",
"user_id": "*******",
"origin": "********",
"user_name": "P000004",
"email": "******@********.com",
"auth_time": ****,
"rev_sig": "****",
"iat": ****,
"exp": *****,
"iss": "https://********/oauth/token",
"zid": "*****",
"aud": [
"uaa",
"userInfo!t159",
"openid",
"sb-userInfo!t159"
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |