Skip to content

Commit 2f39c77

Browse files
committed
Updated doc.
1 parent dc3a13b commit 2f39c77

File tree

4 files changed

+80
-5
lines changed

4 files changed

+80
-5
lines changed

chrp/example_conf.py

+29
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,35 @@
215215
'AccessToken': {},
216216
'UserInfo': {}
217217
},
218+
},
219+
'pingfed': {
220+
"issuer": "https://pf.example.com/",
221+
'client_id': 'pyrp_client',
222+
'client_secret': 'someSecretxxx',
223+
"redirect_uris": ["{}/authz_cb/pingfed".format(BASEURL)],
224+
"behaviour": {
225+
"response_types": ["code"],
226+
"scope": ["openid", "profile", "email"],
227+
"token_endpoint_auth_method": "client_secret_basic"
228+
},
229+
"provider_info": {
230+
"authorization_endpoint":
231+
"https://pf.example.com/as/authorization.oauth2",
232+
"token_endpoint":
233+
"https://pf.example.com/as/token.oauth2",
234+
"userinfo_endpoint":
235+
"https://pf.example.com/idp/userinfo.openid"
236+
},
237+
'services': {
238+
'Authorization': {},
239+
'AccessToken': {},
240+
'UserInfo': {}
241+
},
242+
"keys": {
243+
"url": {
244+
"https://pf.example.com/": "https://pf.example.com/jwks.json"
245+
}
246+
}
218247
}
219248

220249
}

doc/source/rp_handler.rst

+44
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,39 @@ authorization request and accepted by the user.
226226

227227
resp = self.rph.get_user_info(state_key)
228228

229+
:py:meth:`oidcrp.RPHandler.has_active_authentication`
230+
After a while when the user returns after having been away for a while
231+
you may want to know if you should let her reauthenticate or not.
232+
This method will tell you if the last done authentication is still
233+
valid or of it has timed out.
234+
235+
Usage example::
236+
237+
resp = self.rph.has_active_authentication(state_key)
238+
239+
response will be True or False depending in the state of the authentication.
240+
241+
:py:meth:`oidcrp.RPHandler.get_valid_access_token`
242+
When you are issued a access token they normally comes with a life time.
243+
After that time you are expected to use the refresh token to get a new
244+
access token. There are 2 ways of finding out if the access token you have
245+
passed their life time. You can use this method or you can just try using
246+
the access token and see what happens.
247+
248+
Now, if you use this method and it tells you you have an access token
249+
that should still be usable. That is no guarantee that that is the case.
250+
things may have happened on the OPs side that makes the access token
251+
invalid. So if this method only returns a hint as to the usability of the
252+
access token.
253+
254+
Usage example::
255+
256+
resp = self.rph.get_valid_access_token(state_key)
257+
258+
Response will be a tuple containing with the access token and the
259+
expiration time (in epoch) if there is a valid access token otherwise an
260+
exception will be raised.
261+
229262
----------------
230263
RP configuration
231264
----------------
@@ -263,6 +296,17 @@ redirect_uris
263296
behavior
264297
Information about how the RP should behave towards the OP/AS
265298

299+
keys
300+
If the OP doesn't support dynamic provider discovery it may still want to
301+
have a way of distributing keys that allows it to rotate them at anytime.
302+
To accomplish this some providers have choosen to publish a URL to where
303+
you can find their OPs key material in the form of a JWKS.
304+
305+
Usage example::
306+
307+
'keys': {'url': {<issuer_id> : <jwks_url>}}
308+
309+
266310
If the provider info discovery is done dynamically you need this
267311

268312
client_prefs

src/oidcrp/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ def get_valid_access_token(self, state):
754754
Find me a valid access token
755755
756756
:param state:
757-
:return: An access token if a valid one exists otherwise raise
758-
exception.
757+
:return: An access token if a valid one exists and when it
758+
expires. Otherwise raise exception.
759759
"""
760760

761761
exp = 0
@@ -779,12 +779,12 @@ def get_valid_access_token(self, state):
779779
try:
780780
_exp = response['__expires_at']
781781
except KeyError: # No expiry date, lives for ever
782-
indefinite.append(access_token)
782+
indefinite.append((access_token, 0))
783783
else:
784784
if _exp > now: # expires sometime in the future
785785
if _exp > exp:
786786
exp = _exp
787-
token = access_token
787+
token = (access_token, _exp)
788788

789789
if indefinite:
790790
return indefinite[0]

tests/test_20_rp_handler.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -549,4 +549,6 @@ def test_has_active_authentication(self):
549549
assert self.rph.has_active_authentication(self.state)
550550

551551
def test_get_valid_access_token(self):
552-
assert self.rph.get_valid_access_token(self.state)
552+
(token, expires_at) = self.rph.get_valid_access_token(self.state)
553+
assert token == 'accessTok'
554+
assert expires_at > 0

0 commit comments

Comments
 (0)