Skip to content

Commit c81ab28

Browse files
committed
Description of how to move from oidcmsg, oidcrp and oidcop to idpyoidc.
1 parent 728ce56 commit c81ab28

2 files changed

Lines changed: 123 additions & 7 deletions

File tree

doc/move.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
.. _move:
2+
3+
********************************************************
4+
How to move from oidcmsg,oidcrp and oidc-op to idpy-oidc
5+
********************************************************
6+
7+
Since you are here the chance that you are using OidcRP and/or oidc-op is very
8+
high. Hopefully you are happy with what the packages has provided you with
9+
so far. But somehow you have now learned that idpy-oidc is where the
10+
action will be in the future so you want to know what it takes to move
11+
from OidcRP and/or oidc-op to idpy-oidc.
12+
13+
idpy-oidc is collecting the three original packages into one:
14+
15+
* OidcMsg -> idpy-oidc/message
16+
* OidcRP -> idpy-oidc/client
17+
* oidc-op -> idpy-oidc/server
18+
19+
Some of the functionality that was in OidcMsg because it was needed by
20+
both OidcRP and oidc-op is now placed at the root of idpy-oidc.
21+
We will do them one by one
22+
23+
OidcRP
24+
------
25+
26+
If you have kept yourself to always using the high level api moving
27+
28+
You probably can get away only doing what I descibe below.
29+
These are the steps I had to take to get the example/flask_rp RP working.
30+
31+
1) Created a file, named script_py.sed with this content::
32+
33+
s/from oidcop.server import Server/from idpyoidc.server import Server/g
34+
s/oidcop/idpyoidc.server/g
35+
s/oidcrp/idpyoidc.client/g
36+
s/oidcmsg/idpyoidc.message/g
37+
s/idpyoidc.message.configure/idpyoidc.configure/g
38+
s/idpyoidc.message.client/idpyoidc.client/g
39+
s/idpyoidc.message.ssl_context/idpyoidc.ssl_context/g
40+
s/from idpyoidc.client.util import create_context/from idpyoidc.ssl_context import create_context/g
41+
42+
2) Create another file, named script_json.sed with this content::
43+
44+
s/oidcop/idpyoidc.server/g
45+
s/oidcrp/idpyoidc.client/g
46+
s/oidcmsg/idpyoidc.message/g
47+
48+
3) Ran the commands::
49+
50+
find . -name "*.py" -exec sed -i '' -f script_py.sed {} \;
51+
find . -name "*.json" -exec sed -i '' -f script_json.sed {} \;
52+
53+
And I was able to successfully launch the RP.
54+
This worked for me, it might be enough for you too. If not you can probably
55+
figure out what needs changing. If you do I'd appreciate letting me know
56+
so I can add those steps to this document.
57+
58+
oidc-op
59+
-------
60+
61+
Getting oidc-op/example/flask_op running was a bit trickier but not a lot.
62+
63+
Started of with creating the sed script files:
64+
65+
1) Created a file, named script_py.sed with this content::
66+
67+
s/from oidcop.server import Server/from idpyoidc.server import Server/g
68+
s/oidcop/idpyoidc.server/g
69+
s/oidcrp/idpyoidc.client/g
70+
s/oidcmsg/idpyoidc.message/g
71+
s/idpyoidc.message.configure/idpyoidc.configure/g
72+
s/idpyoidc.message.client/idpyoidc.client/g
73+
s/idpyoidc.message.ssl_context/idpyoidc.ssl_context/g
74+
s/from idpyoidc.server.utils import create_context/from idpyoidc.ssl_context import create_context/g
75+
76+
2) Create another file, named script_json.sed with this content::
77+
78+
s/oidcop/idpyoidc.server/g
79+
s/oidcrp/idpyoidc.client/g
80+
s/oidcmsg/idpyoidc.message/g
81+
82+
3) Ran the commands::
83+
84+
find . -name "*.py" -exec sed -i '' -f script_py.sed {} \;
85+
find . -name "*.json" -exec sed -i '' -f script_json.sed {} \;
86+
87+
Now, I had to edit 2 files.
88+
89+
views.py
90+
++++++++
91+
92+
Removed the single line (22)::
93+
94+
from oidcop.exception import TokenAuthenticationError
95+
96+
and the lines (233-238::
97+
98+
except TokenAuthenticationError as err:
99+
_log.error(err)
100+
return make_response(json.dumps({
101+
'error': 'invalid_token',
102+
'error_description': str(err)
103+
}), 401)
104+
105+
106+
config.json
107+
+++++++++++
108+
109+
Removed the line (312) ::
110+
111+
"jwks_file": "private/token_jwks.json",
112+
113+
And that was it.

src/idpyoidc/server/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Server specific defaults and a basic Server class
2+
import logging
23
from typing import Any
34
from typing import Optional
45
from typing import Union
56

67
from cryptojwt import KeyJar
7-
88
from idpyoidc.impexp import ImpExp
9+
from idpyoidc.message.oidc import RegistrationRequest
910
from idpyoidc.server import authz
1011
from idpyoidc.server.client_authn import client_auth_setup
1112
from idpyoidc.server.configure import ASConfiguration
@@ -20,6 +21,8 @@
2021
from idpyoidc.server.util import allow_refresh_token
2122
from idpyoidc.server.util import build_endpoints
2223

24+
logger = logging.getLogger(__name__)
25+
2326

2427
def do_endpoints(conf, server_get):
2528
_endpoints = conf.get("endpoint")
@@ -33,12 +36,12 @@ class Server(ImpExp):
3336
parameter = {"endpoint": [Endpoint], "endpoint_context": EndpointContext}
3437

3538
def __init__(
36-
self,
37-
conf: Union[dict, OPConfiguration, ASConfiguration],
38-
keyjar: Optional[KeyJar] = None,
39-
cwd: Optional[str] = "",
40-
cookie_handler: Optional[Any] = None,
41-
httpc: Optional[Any] = None,
39+
self,
40+
conf: Union[dict, OPConfiguration, ASConfiguration],
41+
keyjar: Optional[KeyJar] = None,
42+
cwd: Optional[str] = "",
43+
cookie_handler: Optional[Any] = None,
44+
httpc: Optional[Any] = None,
4245
):
4346
ImpExp.__init__(self)
4447
self.conf = conf

0 commit comments

Comments
 (0)