-
Notifications
You must be signed in to change notification settings - Fork 50
Support new JWT token based auth (openEO API 1.3.0) #859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 23 commits
26422dc
cde00d6
b0a66a5
d4d5dad
1e75abe
6566959
208b729
39958bf
65eff77
4273d74
84a82ab
ce742e3
d05271f
5166eda
9884bf8
299a079
71a4503
d8dda41
7107497
d925094
7a92e8f
9317759
dc89970
6040a9c
8b72876
85ff1b0
240c18d
94fe914
e6230a3
c2c5766
82c00f4
1d5c20f
8f960e8
33641c4
f943691
9a810c1
a6d3cc2
4abf67e
7c02e85
8ed91bf
15bfc77
63d607a
de28943
555613c
cc4a2e5
473ede2
ed0fa58
c0490dd
897da28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,9 @@ | |
| API_URL = "https://oeo.test/" | ||
|
|
||
| # TODO: eliminate this and replace with `build_capabilities` usage | ||
| BASIC_ENDPOINTS = [{"path": "/credentials/basic", "methods": ["GET"]}] | ||
| BASIC_ENDPOINTS = [ | ||
| {"path": "/credentials/basic", "methods": ["GET"]} | ||
| ] | ||
|
niebl marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| GEOJSON_POINT_01 = {"type": "Point", "coordinates": [3, 52]} | ||
|
|
@@ -407,8 +409,8 @@ def test_connect_with_session(): | |
| ], | ||
| "https://oeo.test/openeo/1.1.0/", | ||
| "1.1.0", | ||
| ), | ||
| ( | ||
| ), | ||
| ( | ||
| [ | ||
| {"api_version": "0.4.1", "url": "https://oeo.test/openeo/0.4.1/"}, | ||
| {"api_version": "1.0.0", "url": "https://oeo.test/openeo/1.0.0/"}, | ||
|
|
@@ -462,8 +464,8 @@ def test_connect_with_session(): | |
| ], | ||
| "https://oeo.test/openeo/1.1.0/", | ||
| "1.1.0", | ||
| ), | ||
| ( | ||
| ), | ||
| ( | ||
| [ | ||
| { | ||
| "api_version": "0.1.0", | ||
|
|
@@ -860,6 +862,19 @@ def test_authenticate_basic_from_config(requests_mock, api_version, auth_config, | |
| assert conn.auth.bearer == "basic//6cc3570k3n" | ||
|
|
||
|
|
||
| def test_authenticate_basic_jwt_bearer(requests_mock, basic_auth): | ||
| requests_mock.get(API_URL, json=build_capabilities(api_version="1.3.0")) | ||
|
|
||
| conn = Connection(API_URL) | ||
|
|
||
| assert isinstance(conn.auth, NullAuth) | ||
| conn.authenticate_basic(username=basic_auth.username, password=basic_auth.password) | ||
| capabilities = conn.capabilities() | ||
| assert isinstance(conn.auth, BearerAuth) | ||
| assert capabilities.api_version() == "1.3.0" | ||
| assert capabilities.has_conformance("https://api.openeo.org/*/authentication/jwt") == True | ||
| assert conn.auth.bearer == "6cc3570k3n" | ||
|
|
||
| @pytest.mark.slow | ||
| def test_authenticate_oidc_authorization_code_100_single_implicit(requests_mock, caplog): | ||
| requests_mock.get(API_URL, json={"api_version": "1.0.0"}) | ||
|
|
@@ -1049,6 +1064,36 @@ def test_authenticate_oidc_auth_code_pkce_flow_client_from_config(requests_mock, | |
| assert conn.auth.bearer == 'oidc/oi/' + oidc_mock.state["access_token"] | ||
| assert refresh_token_store.mock_calls == [] | ||
|
|
||
| @pytest.mark.slow | ||
| def test_authenticate_oidc_auth_code_pkce_flow_jwt_bearer(requests_mock, auth_config): | ||
| requests_mock.get(API_URL, json=build_capabilities(api_version="1.3.0")) | ||
| client_id = "myclient" | ||
| issuer = "https://oidc.test" | ||
| requests_mock.get(API_URL + 'credentials/oidc', json={ | ||
| "providers": [{"id": "oi", "issuer": issuer, "title": "example", "scopes": ["openid"]}] | ||
| }) | ||
| oidc_mock = OidcMock( | ||
| requests_mock=requests_mock, | ||
| expected_grant_type="authorization_code", | ||
| expected_client_id=client_id, | ||
| expected_fields={"scope": "openid"}, | ||
| oidc_issuer=issuer, | ||
| scopes_supported=["openid"], | ||
| ) | ||
| auth_config.set_oidc_client_config(backend=API_URL, provider_id="oi", client_id=client_id) | ||
|
|
||
| # With all this set up, kick off the openid connect flow | ||
| refresh_token_store = mock.Mock() | ||
| conn = Connection(API_URL, refresh_token_store=refresh_token_store) | ||
| assert isinstance(conn.auth, NullAuth) | ||
| conn.authenticate_oidc_authorization_code(webbrowser_open=oidc_mock.webbrowser_open) | ||
| capabilities = conn.capabilities() | ||
| assert isinstance(conn.auth, BearerAuth) | ||
| assert capabilities.api_version() == "1.3.0" | ||
| assert capabilities.has_conformance("https://api.openeo.org/*/authentication/jwt") == True | ||
| assert conn.auth.bearer == oidc_mock.state["access_token"] | ||
| # TODO: check issuer ("iss") value in parsed jwt. this will require the example jwt to be formatted accordingly | ||
| assert refresh_token_store.mock_calls == [] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of duplicating tests for JWT conformace mode (like this single e.g. there are 41 occurrences of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @soxofaan, There are still five failing tests under version All of these have in common that they use the Should we change those parts of the code accordingly so the |
||
|
|
||
| def test_authenticate_oidc_client_credentials(requests_mock): | ||
| requests_mock.get(API_URL, json={"api_version": "1.0.0"}) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.