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

Commit 120ec40

Browse files
committed
client cb uris can be randomic now
* feat: op_hash doesn't match anymore to the final node of the configured uris (fix: #36) * feat: added django_provider to example providers
1 parent 366904b commit 120ec40

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
@@ -173,7 +173,7 @@
173173
}
174174
}
175175
},
176-
"local": {
176+
"flask_provider": {
177177
"client_preferences": {
178178
"application_name": "rphandler",
179179
"application_type": "web",
@@ -241,6 +241,75 @@
241241
}
242242
}
243243
}
244+
},
245+
"django_provider": {
246+
"client_preferences": {
247+
"application_name": "rphandler",
248+
"application_type": "web",
249+
"contacts": [
250+
251+
],
252+
"response_types": [
253+
"code"
254+
],
255+
"scope": [
256+
"openid",
257+
"profile",
258+
"email",
259+
"address",
260+
"phone"
261+
],
262+
"token_endpoint_auth_method": [
263+
"client_secret_basic",
264+
"client_secret_post"
265+
]
266+
},
267+
"issuer": "https://127.0.0.1:8000/",
268+
"redirect_uris": [
269+
"https://{domain}:{port}/authz_cb/django"
270+
],
271+
"post_logout_redirect_uris": [
272+
"https://{domain}:{port}/session_logout/django"
273+
],
274+
"frontchannel_logout_uri": "https://{domain}:{port}/fc_logout/django",
275+
"frontchannel_logout_session_required": true,
276+
"backchannel_logout_uri": "https://{domain}:{port}/bc_logout/django",
277+
"backchannel_logout_session_required": true,
278+
"services": {
279+
"discovery": {
280+
"class": "oidcrp.oidc.provider_info_discovery.ProviderInfoDiscovery",
281+
"kwargs": {}
282+
},
283+
"registration": {
284+
"class": "oidcrp.oidc.registration.Registration",
285+
"kwargs": {}
286+
},
287+
"authorization": {
288+
"class": "oidcrp.oidc.authorization.Authorization",
289+
"kwargs": {}
290+
},
291+
"accesstoken": {
292+
"class": "oidcrp.oidc.access_token.AccessToken",
293+
"kwargs": {}
294+
},
295+
"userinfo": {
296+
"class": "oidcrp.oidc.userinfo.UserInfo",
297+
"kwargs": {}
298+
},
299+
"end_session": {
300+
"class": "oidcrp.oidc.end_session.EndSession",
301+
"kwargs": {}
302+
}
303+
},
304+
"add_ons": {
305+
"pkce": {
306+
"function": "oidcrp.oauth2.add_on.pkce.add_support",
307+
"kwargs": {
308+
"code_challenge_length": 64,
309+
"code_challenge_method": "S256"
310+
}
311+
}
312+
}
244313
}
245314
},
246315
"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)