forked from geigerzaehler/oidc-provider-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md.tpl
More file actions
79 lines (53 loc) · 2.66 KB
/
README.md.tpl
File metadata and controls
79 lines (53 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# OpenID Provider Mock
[](https://pypi.org/project/oidc-provider-mock/)
[](https://github.com/geigerzaehler/oidc-provider-mock/actions/workflows/main.yaml)
[][docs]
> A mock OpenID Provider server to test and develop OpenID Connect
> authentication.
You can find the full documentation [here][docs].
[docs]: https://oidc-provider-mock.readthedocs.io/latest/
## Usage
The simplest method to run the server is
[`pipx`](https://pipx.pypa.io/latest/installation/):
```bash
$ pipx run oidc-provider-mock
Started OpenID provider http://localhost:9400
```
Now, configure your OpenID Connect client library in your app to use
`http://localhost:9400` as the issuer URL. By default, you can use any client ID
and client secret with the provider.
Finally, you can authenticate against the app (the Relying Party) through the
mock provider’s login form:

Take a look at the following example that uses the server in a test for a
[Flask-OIDC](https://flask-oidc.readthedocs.io/en/latest/) app.
```python
SNIPPET flask_test_login
```
For all full testing example, see
[`examples/flask_oidc_example.py`](examples/flask_oidc_example.py). You can find
more advanced tests in
[`tests/flask_advanced_test.py`](tests/flask_advanced_test.py).
If you’re using [Playwright](https://playwright.dev) for end-to-end tests, a
login test looks like this:
```python
SNIPPET flask_test_login_playwright
```
You can find a full example at
[`examples/flask_oidc_example.py`](examples/flask_oidc_example.py), too.
## Alternatives
There already exist a couple of OpendID provider servers for testing. This is
how they differ from this project (to the best of my knowledge):
[`axa-group/oauth2-mock-server`](https://github.com/axa-group/oauth2-mock-server)
- Does not offer a HTML login form where the subject can be input or
authorization denied.
- Behavior can only be customized through the JavaScript API.
[`Soluto/oidc-server-mock`](https://github.com/Soluto/oidc-server-mock)
- Identities (users) and clients must be statically configured.
- Requires a non-trivial amount of configuration before it can be used.
[`oauth2-proxy/mockoidc`](https://github.com/oauth2-proxy/mockoidc`)
- Does not have a CLI, only available as a Go library
<https://oauth.wiremockapi.cloud/>
- Only a hosted version exists
- Claims and user info cannot be customized
- Cannot simulate errors