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

Commit ab4b9da

Browse files
authored
Merge pull request #1 from openid/master
Merge
2 parents d24c20d + b780598 commit ab4b9da

6 files changed

Lines changed: 36 additions & 57 deletions

File tree

.pytest_cache/v/cache/lastfailed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"tests/test_14_oidc.py::TestClient::()::test_service_request": true,
33
"tests/test_20_rp_handler.py::TestRPHandler::()::test_get_accesstoken": true,
4-
"tests/test_20_rp_handler.py::TestRPHandler::()::test_get_userinfo": true
4+
"tests/test_20_rp_handler.py::TestRPHandler::()::test_get_userinfo": true,
5+
"tests/test_20_rp_handler.py::TestRPHandler::test_support_webfinger": true
56
}

flask_rp/application.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22

3-
from flask.app import Flask
4-
53
from cryptojwt.key_jar import init_key_jar
4+
from flask.app import Flask
5+
from oidcop.utils import load_yaml_config
66

77
from oidcrp import RPHandler
88

@@ -34,7 +34,13 @@ def init_oidc_rp_handler(app):
3434
def oidc_provider_init_app(config_file, name=None, **kwargs):
3535
name = name or __name__
3636
app = Flask(name, static_url_path='', **kwargs)
37-
app.config.from_pyfile(os.path.join(dir_path, config_file))
37+
38+
if config_file.endswith('.yaml'):
39+
app.config.update(load_yaml_config(config_file))
40+
elif config_file.endswith('.py'):
41+
app.config.from_pyfile(os.path.join(dir_path, config_file))
42+
else:
43+
raise ValueError('Unknown configuration format')
3844

3945
app.users = {'test_user': {'name': 'Testing Name'}}
4046

flask_rp/conf.yaml

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PORT: 8090
12
BASEURL: "https://127.0.0.1:8090"
23

34
# If BASE is https these has to be specified
@@ -40,16 +41,16 @@ client_preferences: &id001
4041

4142
services: &id002
4243
discovery:
43-
class: oidcservice.rp.provider_info_discovery.ProviderInfoDiscovery
44+
class: oidcservice.oidc.provider_info_discovery.ProviderInfoDiscovery
4445
kwargs: {}
4546
registration:
46-
class: oidcservice.rp.registration.Registration
47+
class: oidcservice.oidc.registration.Registration
4748
kwargs: {}
4849
authorization:
4950
class: oidcservice.oidc.authorization.Authorization
5051
kwargs: {}
5152
accesstoken:
52-
class: oidcservice.oidc.accesstoken.Accesstoken
53+
class: oidcservice.oidc.access_token.AccessToken
5354
kwargs: {}
5455
refresh_accesstoken:
5556
class: oidcservice.oidc.refresh_access_token.RefreshAccessToken
@@ -58,52 +59,14 @@ services: &id002
5859
class: oidcservice.oidc.userinfo.UserInfo
5960
kwargs: {}
6061
end_session:
61-
class: oidcservice.oidc.session.EndSession
62+
class: oidcservice.oidc.end_session.EndSession
6263
kwargs: {}
6364

6465

65-
client:
66-
bobcat:
67-
client_id: client3
68-
client_preferences:
69-
response_types: [code]
70-
scope: [openid, offline_access]
71-
token_endpoint_auth_method: client_secret_basic
72-
client_secret: '2222222222222222222222222222222222222222'
73-
issuer: https://127.0.0.1:8443/
74-
redirect_uris: [['https://127.0.0.1:8090/authz_cb/bobcat', '']]
75-
services:
76-
authorization:
77-
class: oidcservice.oidc.authorization.Authorization
78-
kwargs: {}
79-
accesstoken:
80-
class: oidcservice.oidc.accesstoken.Accesstoken
81-
kwargs: {}
82-
discovery:
83-
class: oidcservice.rp.provider_info_discovery.ProviderInfoDiscovery
84-
kwargs: {}
85-
refresh_accesstoken:
86-
class: oidcservice.oidc.refresh_access_token.RefreshAccessToken
87-
kwargs: {}
88-
filip:
89-
backchannel_logout_uri: https://127.0.0.1:8090/bc_logout
90-
client_preferences: *id001
91-
issuer: https://guarded-cliffs-8635.herokuapp.com/
92-
post_logout_redirect_uris: ['https://127.0.0.1:8090/session_logout']
93-
redirect_uris: ['https://127.0.0.1:8090/authz_cb/filip']
94-
services: *id002
95-
filip_local:
96-
backchannel_logout_uri: https://127.0.0.1:8090/bc_logout
97-
client_preferences: *id001
98-
issuer: http://localhost:3000/
99-
post_logout_redirect_uris: ['https://127.0.0.1:8090/session_logout']
100-
redirect_uris: ['https://127.0.0.1:8090/authz_cb/filip_local']
101-
services: *id002
66+
CLIENTS:
10267
flop:
103-
backchannel_logout_uri: https://127.0.0.1:8090/bc_logout/flop
10468
client_preferences: *id001
10569
issuer: https://127.0.0.1:5000/
106-
post_logout_redirect_uris: ['https://127.0.0.1:8090/session_logout']
10770
redirect_uris: ['https://127.0.0.1:8090/authz_cb/flop']
10871
services: *id002
10972

src/oidcrp/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,18 @@ def do_provider_info(self, client=None, state=''):
226226
return client.service_context.provider_info['issuer']
227227
else:
228228
_pi = client.service_context.provider_info
229-
for endp in ['authorization_endpoint', 'token_endpoint',
230-
'userinfo_endpoint']:
231-
if endp in _pi:
232-
for srv in client.service.values():
233-
if srv.endpoint_name == endp:
234-
srv.endpoint = _pi[endp]
229+
for key, val in _pi.items():
230+
# All service endpoint parameters in the provider info has
231+
# a name ending in '_endpoint' so I can look specifically
232+
# for those
233+
if key.endswith("_endpoint"):
234+
for _srv in client.service_context.service.values():
235+
# Every service has an endpoint_name assigned
236+
# when initiated. This name *MUST* match the
237+
# endpoint names used in the provider info
238+
if _srv.endpoint_name == key:
239+
_srv.endpoint = val
240+
235241
try:
236242
return client.service_context.provider_info['issuer']
237243
except KeyError:

src/oidcrp/oauth2/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
import cherrypy
43
from cryptojwt.key_jar import KeyJar
54
from oidcmsg.exception import FormatError
65
from oidcservice.client_auth import factory as ca_factory
@@ -211,16 +210,16 @@ def parse_request_response(self, service, reqresp, response_body_type='',
211210
err_resp = service.parse_response(reqresp.text,
212211
response_body_type)
213212
except (OidcServiceError, FormatError):
214-
raise cherrypy.HTTPError("HTTP ERROR: %s [%s] on %s" % (
213+
raise OidcServiceError("HTTP ERROR: %s [%s] on %s" % (
215214
reqresp.text, reqresp.status_code, reqresp.url))
216215
else:
217-
raise cherrypy.HTTPError("HTTP ERROR: %s [%s] on %s" % (
216+
raise OidcServiceError("HTTP ERROR: %s [%s] on %s" % (
218217
reqresp.text, reqresp.status_code, reqresp.url))
219218

220219
err_resp['status_code'] = reqresp.status_code
221220
return err_resp
222221
else:
223222
logger.error('Error response ({}): {}'.format(reqresp.status_code,
224223
reqresp.text))
225-
raise cherrypy.HTTPError("HTTP ERROR: %s [%s] on %s" % (
224+
raise OidcServiceError("HTTP ERROR: %s [%s] on %s" % (
226225
reqresp.text, reqresp.status_code, reqresp.url))

src/oidcrp/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,7 @@ def load_configuration(filename):
241241
elif filename.endswith('.py'):
242242
sys.path.insert(0, ".")
243243
conf = importlib.import_module(filename[:-3])
244+
else:
245+
raise ValueError('Wrong file type')
246+
247+
return conf

0 commit comments

Comments
 (0)