Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 9fbef23

Browse files
authored
Merge pull request #38 from IdentityPython/pplnx
client cb uris can be randomic now
2 parents f5d1707 + 120ec40 commit 9fbef23

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

example/flask_rp/conf.json

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
}
137137
}
138138
},
139-
"local": {
139+
"flask_provider": {
140140
"client_preferences": {
141141
"application_name": "rphandler",
142142
"application_type": "web",
@@ -204,6 +204,75 @@
204204
}
205205
}
206206
}
207+
},
208+
"django_provider": {
209+
"client_preferences": {
210+
"application_name": "rphandler",
211+
"application_type": "web",
212+
"contacts": [
213+
214+
],
215+
"response_types": [
216+
"code"
217+
],
218+
"scope": [
219+
"openid",
220+
"profile",
221+
"email",
222+
"address",
223+
"phone"
224+
],
225+
"token_endpoint_auth_method": [
226+
"client_secret_basic",
227+
"client_secret_post"
228+
]
229+
},
230+
"issuer": "https://127.0.0.1:8000/",
231+
"redirect_uris": [
232+
"https://{domain}:{port}/authz_cb/django"
233+
],
234+
"post_logout_redirect_uris": [
235+
"https://{domain}:{port}/session_logout/django"
236+
],
237+
"frontchannel_logout_uri": "https://{domain}:{port}/fc_logout/django",
238+
"frontchannel_logout_session_required": true,
239+
"backchannel_logout_uri": "https://{domain}:{port}/bc_logout/django",
240+
"backchannel_logout_session_required": true,
241+
"services": {
242+
"discovery": {
243+
"class": "oidcrp.oidc.provider_info_discovery.ProviderInfoDiscovery",
244+
"kwargs": {}
245+
},
246+
"registration": {
247+
"class": "oidcrp.oidc.registration.Registration",
248+
"kwargs": {}
249+
},
250+
"authorization": {
251+
"class": "oidcrp.oidc.authorization.Authorization",
252+
"kwargs": {}
253+
},
254+
"accesstoken": {
255+
"class": "oidcrp.oidc.access_token.AccessToken",
256+
"kwargs": {}
257+
},
258+
"userinfo": {
259+
"class": "oidcrp.oidc.userinfo.UserInfo",
260+
"kwargs": {}
261+
},
262+
"end_session": {
263+
"class": "oidcrp.oidc.end_session.EndSession",
264+
"kwargs": {}
265+
}
266+
},
267+
"add_ons": {
268+
"pkce": {
269+
"function": "oidcrp.oauth2.add_on.pkce.add_support",
270+
"kwargs": {
271+
"code_challenge_length": 64,
272+
"code_challenge_method": "S256"
273+
}
274+
}
275+
}
207276
}
208277
},
209278
"webserver": {

example/flask_rp/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import urllib
23
from urllib.parse import parse_qs
34

45
from flask import Blueprint
@@ -149,8 +150,21 @@ def finalize(op_hash, request_args):
149150
return make_response(res['error'], 400)
150151

151152

153+
def get_ophash_by_cb_uri(url:str):
154+
uri = urllib.parse.splitquery(request.url)[0]
155+
clients = current_app.rp_config.clients
156+
for k,v in clients.items():
157+
for endpoint in ("redirect_uris",
158+
"post_logout_redirect_uris",
159+
"frontchannel_logout_uri",
160+
"backchannel_logout_uri"):
161+
if uri in clients[k].get(endpoint, []):
162+
return k
163+
164+
152165
@oidc_rp_views.route('/authz_cb/<op_hash>')
153166
def authz_cb(op_hash):
167+
op_hash = get_ophash_by_cb_uri(request.url)
154168
return finalize(op_hash, request.args)
155169

156170

@@ -215,6 +229,7 @@ def session_change():
215229
# post_logout_redirect_uri
216230
@oidc_rp_views.route('/session_logout/<op_hash>')
217231
def session_logout(op_hash):
232+
op_hash = get_ophash_by_cb_uri(request.url)
218233
_rp = get_rp(op_hash)
219234
logger.debug('post_logout')
220235
return "Post logout from {}".format(_rp.client_get("service_context").issuer)

0 commit comments

Comments
 (0)