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

Commit a91c89a

Browse files
committed
Fixed a couple of errors.
1 parent 0fd9ed0 commit a91c89a

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

flask_rp/application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def oidc_provider_init_app(config_file, name=None, **kwargs):
3737
app = Flask(name, static_url_path='', **kwargs)
3838

3939
app.rp_config = Configuration.create_from_config_file(config_file)
40-
# app.config['SECRET_KEY'] = os.urandom(12).hex()
40+
41+
# Session key for the application session
42+
app.config['SECRET_KEY'] = os.urandom(12).hex()
4143

4244
app.users = {'test_user': {'name': 'Testing Name'}}
4345

flask_rp/conf.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
logging:
2+
version: 1
3+
root:
4+
handlers:
5+
- console
6+
level: DEBUG
7+
loggers:
8+
idp:
9+
level: DEBUG
10+
handlers:
11+
console:
12+
class: logging.StreamHandler
13+
stream: 'ext://sys.stdout'
14+
formatter: default
15+
formatters:
16+
default:
17+
format: '%(asctime)s %(name)s %(levelname)s %(message)s'
18+
119
port: &port 8090
220
domain: &domain 127.0.0.1
321
base_url: "https://{domain}:{port}"
@@ -71,7 +89,7 @@ clients:
7189
client_preferences: *id001
7290
issuer: https://127.0.0.1:5000/
7391
jwks_uri: 'static/jwks.json'
74-
redirect_uris: ['authz_cb/flop']
92+
redirect_uris: ['https://{domain}:{port}/authz_cb/flop']
7593
services: *id002
7694
add_ons:
7795
pkce:
@@ -91,3 +109,4 @@ webserver:
91109
# verify_user: optional
92110
# The you also need
93111
# ca_bundle: ''
112+
debug: true

flask_rp/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def send_js(path):
3636

3737
@oidc_rp_views.route('/')
3838
def index():
39-
_providers = current_app.config.get('CLIENTS').keys()
39+
_providers = current_app.rp_config.clients.keys()
4040
return render_template('opbyuid.html', providers=_providers)
4141

4242

@@ -68,7 +68,7 @@ def rp():
6868
else:
6969
return redirect(result['url'], 303)
7070
else:
71-
_providers = current_app.config.get('CLIENTS').keys()
71+
_providers = current_app.rp_config.clients.keys()
7272
return render_template('opbyuid.html', providers=_providers)
7373

7474

src/oidcrp/oauth2/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from json import JSONDecodeError
23

34
from cryptojwt.key_jar import KeyJar
45
from oidcmsg.exception import FormatError
@@ -245,6 +246,8 @@ def parse_request_response(self, service, reqresp, response_body_type='',
245246
else:
246247
raise OidcServiceError("HTTP ERROR: %s [%s] on %s" % (
247248
reqresp.text, reqresp.status_code, reqresp.url))
249+
except JSONDecodeError: # So it's not JSON assume text then
250+
err_resp = {'error': reqresp.text}
248251

249252
err_resp['status_code'] = reqresp.status_code
250253
return err_resp

0 commit comments

Comments
 (0)