
In this scenario, both Mobile Service and Back-end service deployed in Cloud Foundry.There are four types of "SSO Mechanism" apply to this kind of deployment:
Create a Mobile Application called "mobileApp" with the default XSUAA service instance in Cloud Platform Mobile Services Cockpit. By default, system will create a new XSUAA service instance with the prefix of application name "mobileApp" and "-xsuaa" as the suffix, which name is " mobileApp-xsuaa".
The "Mobile Connectivity" feature must be assigned.
Check the XSUAA service instance in SAP Cloud Platform Cockpit.
Navigate to {Your Global Account} > {Your Sub-account} > {Your Space} > Services > Service Instances page, there is a "mobileApp-xsuaa" XSUAA service instance created for "mobileApp" as following:
One way is "odata-service-backend" binding the same XSUAA service instance with "mobileApp".
In SAP Cloud Platform Cockpit, navigate to {Your Global Account} > {Your Sub-account} > {Your Space} > Applications > odata-service-backend > Service Bindings page, click the "Bind Service" button, in the popup window, choose "Authorization & Trust Management", select the existing XSUAA service "mobileApp-xsuaa" as the Back-end Service's XSUAA service instance.
The other way is "mobileApp" binding the same XSUAA service with "odata-service-backend".
When creating the Mobile Application, in the "XSUAA Service" field, select the XSUAA service instance you created both for "odata-service-backend" and "mobileApp".
If Back-end Service and Mobile Service used different XSUAA service instances, through granting scopes access to Mobile Application, destination can still use Forward Authorization.
This scenario applies to Mobile Service and Back-end Service deployed in different spaces, sub-accounts, even different global accounts.
{
"xsappname": "xsuaa-forward",
"tenant-mode": "shared",
"scopes":
[
{
"description": "Service user scope",
"name": "$XSAPPNAME.Everyone",
"granted-apps": [ "$XSAPPNAME(application, 88*****0e, mobileApp-*g)"]
},
{
"description": "Service administrator scope",
"name": "$XSAPPNAME.ViewMetrics",
"granted-apps": [ "$XSAPPNAME(application, 88*****0e, mobileApp-*g)"]
}
],
"role-templates":
[
{
"description": "Service user role",
"name": "Everyone",
"scope-references": ["$XSAPPNAME.Everyone"]
},
{
"description": "Service administrator role",
"name": "ViewMetrics",
"scope-references": ["$XSAPPNAME.ViewMetrics"]
}
]
}
This "xsuaa-forward" xsappname will be used in step 2.
The "tenant-mode" should be set the same value with mobileApp's XSUAA service instance's "tenant-mode".
The scope name is "$XSAPPNAME.Everyone", it will be referenced in step 2.
Add "granted-apps" property to "scopes". The format is:
$XSAPPNAME(application, {The Sub-account id of Mobile Service deployed}, {The xsappname of Mobile Service's XSUAA service instance}).
The xsappname of mobileApp's XSUAA service instance gets from {Global Account} > {Sub-account} > {Space} > Services > Service Instance page, select the "mobileApp-xsuaa", on the "Service Keys" part in the right, click the more icon, then click the "View" button as following:
It will pop up XSUAA detail information:
We can see the "xsappname" value is "mobileApp-*g!t57", remove "!t57" just use "mobileApp-*g".
{
"xsappname":"mobileApp-*g",
"role-templates":[
{
"name":"ODataViewer",
"description":"View Data",
"scope-references":[
"$XSAPPNAME(application, 88*****0e, xsuaa-forward).Everyone", "$XSAPPNAME(application, 88*****0e, xsuaa-forward).ViewMetrics"
]
}
],
"role-collections":[
{
"name":"ODataViewer",
"description":"Viewer ODataService data",
"role-template-references":[
"$XSAPPNAME.ODataViewer"
]
}
],
"foreign-scope-references": [ "$ACCEPT_GRANTED_SCOPES"]
}
$XSAPPNAME(application, {The Sub-account id of XSUAA service instance created in step 1}, {The xsappname of XSUAA service instance created in step 1}).{The scope name of XSUAA service instance created in step 1}
The procedure is the same with Back-end Service uses the same XSUAA instance with mobile application Create a Destination part.
If Back-end Server and Mobile Service used different XSUAA service instances under the same sub-account, you can use "User Token Exchange" SSO Mechanism.
{
"xsappname": "xsuaa-token-exchange",
"tenant-mode": "shared",
"oauth2-configuration": {
"grant-types": [
"urn:ietf:params:oauth:grant-type:jwt-bearer"
]
},
"role-templates":
[
......
],
"scopes":
[
......
]
}
This scenario applies to Mobile service and Back-end Service deployed in different spaces, sub-accounts, global accounts, even cross different systems.
In Cloud Platform Mobile Services Cockpit, navigate to Mobile Applications > Native/Hybrid > mobileApp page, click the "Mobile Connectivity" feature to create a new Destination:
SSO Mechanism: OAuth2 SAML Bearer Assertion
Audience: In the SAML Metadata file got in step 1, copy the value of "entityID".
Token Service URL: In the SAML Metadata file got in step 1, find the xml node pattern as following:
<md:AssertionConsumerService Location="{Token Service URL}" Binding="urn:oasis:names:tc:SAML:2.0:bindings:URI" index="1"/>
Copy the value of Location property.
Token Service URL Type: Dedicated.
Client Key: The "clientid" value of Back-end's XSUAA service instance.
Client Secret: The "clientsecret" value of Back-end's XSUAA service instance.
SAML Assertion Issuer: Name a issuer.
Signing Key: You can click the "Generate Key" to generate one.
This scenario is suitable for machine-to-machine authentication, for example in a cron job which preforms schedule task.
{
"xsappname": "client-credentials",
"tenant-mode": "shared",
"oauth2-configuration": {
"grant-types": [
"client_credentials"
]
},
"role-templates":
[
......
],
"scopes":
[
......
]
}
In SAP Cloud Platform Cockpit, navigate to {Your Global Account} > {Your Sub-account} > {Your Space} > Applications > odata-service-backend > Service Bindings page, click the "Show sensitive data" button. The "url", "clientid", "clientsecret" properties will be used in step 3.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
11 | |
11 | |
10 | |
8 | |
8 | |
7 | |
7 | |
7 |