Skip to content

Commit f2b8e6d

Browse files
jgomer2001yuriyz
andauthored
chore(agama): refactor agama to use acr_values instead of agama_flow (#8354)
* docs: update documentation to conform changes #8228 Signed-off-by: jgomer2001 <[email protected]> * chore: refactor agama to use data in acr_values #8228 Signed-off-by: jgomer2001 <[email protected]> --------- Signed-off-by: jgomer2001 <[email protected]> Co-authored-by: YuriyZ <[email protected]> Former-commit-id: 1b6bb3e
1 parent 0c3f9ed commit f2b8e6d

File tree

6 files changed

+20
-46
lines changed

6 files changed

+20
-46
lines changed

docs/admin/developer/agama/engine-bridge-config.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,4 @@ Please account additional behaviors:
7575

7676
## Bridge configuration
7777

78-
There are a few configuration properties admins can set to modify the behavior of the bridge:
79-
80-
- `cust_param_name`: The name of the request parameter - in the authentication request - that will carry the name of the flow to launch. Ensure to register the given parameter name in the [server configuration](../../config-guide/jans-authorization-server-config.md) (property `authorizationRequestCustomAllowedParameters`) beforehand
81-
82-
- `default_flow_name`: If the relying party (RP) is not able to send custom parameters or omits the flow name in the authentication request, the value of this property will be assumed to be the flow to launch by default
83-
84-
- `finish_userid_db_attribute`: It is used to map the identity of the user to login in the case of sucessfully finished flows. The value of this property will contain a physical database attribute that will be correlated with the `userId` passed in the `Finish` instruction of the flow
78+
Administrators can modify the behavior of the bridge by setting the `finish_userid_db_attribute` configuration property of the script. This is used to map the identity of the user to login in the case of sucessfully finished flows. The value of this property will contain a physical database attribute that will be correlated with the `userId` passed in the `Finish` instruction of the flow.

docs/admin/developer/agama/jans-agama-engine.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@ The rest of this document describes implementation-specific details of the engin
2626

2727
## Launching flows
2828

29-
Flows can be launched by sending an (OpenId Connect) authentication request to the user's browser. This usually boils down to make a redirection to a URL looking like `https://<jans-server-name>/jans-auth/restv1/authorize?acr_values=agama&agama_flow=flow-qname&scope=...&response_type=...&redirect_uri=https...&client_id=...&state=...`. Check the OpenId Connect [spec](https://openid.net/specs/openid-connect-core-1_0.html) for more details. Note Jans Server is spec-compliant.
29+
Flows can be launched by sending an (OpenId Connect) authentication request to the user's browser. This usually boils down to making a redirection to a URL looking like `https://<jans-server-name>/jans-auth/restv1/authorize?acr_values=agama_flowQname&scope=...&response_type=...&redirect_uri=https...&client_id=...&state=...`. Check the OpenId Connect [spec](https://openid.net/specs/openid-connect-core-1_0.html) for more details. Note Jans Server is spec-compliant.
3030

3131
Things to highlight:
3232

33-
- The `acr_values` parameter must be equal to `agama`
33+
- The `acr_values` parameter carries the qualified name (identifier) of the flow to launch prefixed with the string `agama_`, for example `acr_values=agama_test.acme.co`
3434

35-
- The qualified name (identifier) of the flow to launch is passed using the parameter referenced in property `cust_param_name` of the Agama [bridge](./engine-bridge-config.md#bridge-configuration) script. `agama_flow` will most likely work since this is the default value employed by the Jans installer, e.g. `agama_flow=test.acme.co`
36-
37-
- If the flow to call receives input parameters, their values can be passed in the custom parameter as well. Use a hyphen to separate the flow name and the parameters expressed in JSON object format. For example, if the flow had inputs `height` and `color`, you can use `test.acme.co-{"height": 190, "color": "blue"}` for the value of `agama_flow`. Ensure to apply proper URL-encoding beforehand. In this case, the actual value would be `test-%7B%22height%22%3A+190%2C+%22color%22%3A+%22blue%22%7D`. If certain inputs are not provided, `null` values will be assigned for them
38-
39-
- If for some reason you are not able to set the given custom parameter in the authorization request, you can set its value in the configuration property `default_flow_name` of the [bridge](./engine-bridge-config.md#bridge-configuration) script. Note this will launch the same fixed flow at all times
35+
- If the flow to call receives input parameters, this data can be appended to the `acr_values` parameter: use a hyphen to separate the flow name and the parameters expressed in Base64 URL encoded format. For example, if the flow had inputs `height` and `color`, you would encode the string `{"height": 190, "color": "blue"}` and the resulting value would be `agama_test.acme.co-eyJoZWlnaHQiOiAxOTAsICJjb2xvciI6ICJibHVlIn0`. When a given input variable is not provided, the engine will assign a `null` value automatically
4036

4137
## Authentication and `Finish`
4238

docs/script-catalog/person_authentication/agama-bridge/AgamaBridge.py

+16-22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from io.jans.agama import NativeJansFlowBridge
88
from io.jans.agama.engine.misc import FlowUtils
99
from io.jans.service import EncryptionService
10+
from io.jans.as.model.util import Base64Util
1011
from io.jans.as.server.security import Identity
1112
from io.jans.as.server.service import AuthenticationService, UserService
1213
from io.jans.jsf2.service import FacesService
@@ -29,26 +30,14 @@ def __init__(self, currentTimeMillis):
2930
def init(self, customScript, configurationAttributes):
3031
print "Agama. Initialization"
3132
self.resultParam = "agamaData"
32-
33-
prop = "cust_param_name"
34-
self.cust_param_name = self.configProperty(configurationAttributes, prop)
35-
36-
if self.cust_param_name == None:
37-
print "Agama. Custom parameter name not referenced via property '%s'" % prop
38-
return False
39-
40-
prop = "default_flow_name"
41-
self.default_flow_name = self.configProperty(configurationAttributes, prop)
4233

4334
prop = "finish_userid_db_attribute"
4435
self.finish_userid_db_attr = self.configProperty(configurationAttributes, prop)
4536

4637
if self.finish_userid_db_attr == None:
4738
print "Agama. Property '%s' is missing value" % prop
4839
return False
49-
50-
print "Agama. Request param '%s' will be used to pass flow name and inputs" % self.cust_param_name
51-
print "Agama. When '%s' is missing, the flow to launch will be '%s'" % (self.cust_param_name, self.default_flow_name)
40+
5241
print "Agama. DB attribute '%s' will be used to map the identity of userId passed in Finish directives (if any)" % self.finish_userid_db_attr
5342
print "Agama. Initialized successfully"
5443

@@ -139,20 +128,19 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
139128
print "Agama. Failed to retrieve session_id"
140129
return False
141130

142-
param = session.getSessionAttributes().get(self.cust_param_name)
131+
cesar = session.getSessionAttributes()
132+
param = cesar.get("agama_flow")
133+
143134
if StringHelper.isEmpty(param):
144-
print "Agama. Request param '%s' is missing or has no value" % self.cust_param_name
145-
146-
param = self.default_flow_name
147-
if param == None:
148-
print "Agama. Default flow name is not set either..."
135+
param = self.extractAgamaFlow(cesar.get("acr_values"))
149136

137+
if StringHelper.isEmpty(param):
150138
print "Agama. Unable to determine the Agama flow to launch. Check the docs"
151139
return False
152140

153141
(qn, ins) = self.extractParams(param)
154142
if qn == None:
155-
print "Agama. Param '%s' is missing the name of the flow to be launched" % self.cust_param_name
143+
print "Agama. Unable to determine the Agama flow to launch. Check the docs"
156144
return False
157145

158146
try:
@@ -215,10 +203,16 @@ def setMessageError(self, severity, msg):
215203
facesMessages.clear()
216204
facesMessages.add(severity, msg)
217205

206+
def extractAgamaFlow(self, acr):
207+
prefix = "agama_"
208+
if StringHelper.isNotEmpty(acr) and acr.find(prefix) == 0:
209+
return acr[len(prefix):]
210+
return None
211+
218212
def extractParams(self, param):
219213

220214
# param must be of the form QN-INPUT where QN is the qualified name of the flow to launch
221-
# INPUT is a JSON object that contains the arguments to use for the flow call.
215+
# INPUT is a base64URL-encoded JSON object that contains the arguments to use for the flow call.
222216
# The keys of this object should match the already defined flow inputs. Ideally, and
223217
# depending on the actual flow implementation, some keys may not even be required
224218
# QN and INPUTS are separated by a hyphen
@@ -230,4 +224,4 @@ def extractParams(self, param):
230224
elif i == -1:
231225
return (param, None)
232226
else:
233-
return (param[:i], param[i+1:])
227+
return (param[:i], Base64Util.base64urldecodeToString(param[i+1:]))

jans-auth-server/server/conf/jans-config.json

-4
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,6 @@
460460
{
461461
"paramName": "customParam5",
462462
"returnInResponse": true
463-
},
464-
{
465-
"paramName": "agama_flow",
466-
"returnInResponse": false
467463
}
468464
],
469465
"legacyDynamicRegistrationScopeParam": false,

jans-linux-setup/jans_setup/templates/jans-auth/jans-auth-config.json

-4
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,6 @@
499499
{
500500
"paramName": "customParam5",
501501
"returnInResponse": true
502-
},
503-
{
504-
"paramName": "agama_flow",
505-
"returnInResponse": false
506502
}
507503
],
508504
"legacyDynamicRegistrationScopeParam": false,

jans-linux-setup/jans_setup/templates/scripts.ldif

-2
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,6 @@ objectClass: top
570570
description: Agama Script
571571
displayName: agama
572572
inum: BADA-BADA
573-
jansConfProperty: {"value1":"cust_param_name","value2":"agama_flow","description":""}
574-
jansConfProperty: {"value1":"default_flow_name","value2":"","description":""}
575573
jansConfProperty: {"value1":"finish_userid_db_attribute","value2":"uid","description":""}
576574
jansEnabled: false
577575
jansLevel: 10

0 commit comments

Comments
 (0)