-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add OIDC user to the functional test #3235
Add OIDC user to the functional test #3235
Conversation
ae1a077
to
73ac125
Compare
Note:
|
lib/pbench/client/oidc_admin.py
Outdated
from requests.structures import CaseInsensitiveDict | ||
|
||
|
||
class OIDCAdmin: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the Connection
class in the lib/pbench/server/auth/__init__.py
module which we should probably re-use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to defer reviewing this code until this change is made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not re-add the same code that is already in the Connection
class.
lib/pbench/server/auth/__init__.py
Outdated
@@ -468,7 +468,7 @@ def token_introspect_offline(self, token: str) -> JSON: | |||
token, | |||
self._pem_public_key, | |||
algorithms=[self._TOKEN_ALG], | |||
audience=self.client_id, | |||
audience=["account", self.client_id], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this audience coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I forgot to add a comment here.
Basically, if a user logs in with a username and password directly with a Keycloak rest API using private client then the aud
claim included in the token is account
for example this request:
requests.post(
"<token_endpoint>",
headers=<{headers}>,
data={"client_id": "pbench-server-client", "client_secret": <secret>,
"scope": "profile email", "grant_type": "password", "username": user, "password": "123"},
verify=False
)
will generate a token that has a payload like following:
{'exp': 1675890382,
'iat': 1675890082,
'jti': 'a8dc9cca-d734-4758-ab1d-be6510fe85b2',
'iss': 'http://localhost:8090/realms/pbench-server',
'aud': 'account',
'sub': '9202c4a9-5901-46dc-9b8e-2643a5f4372e',
'typ': 'Bearer',
'azp': 'pbench-server-client',
'session_state': '5730b4b1-bdb3-438c-a308-d3c1f8108fd8', ....}
And right now our functional test user is logging in using the Keycloak Rest API, so I had to include this claim to get the functional tests to pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be fixed now. I have added a client scope in the Keycloak configuration that will add the Pbench openid client (pbench-dashboard) in the aud
claim by default. So the functional test user tokens should be able to get validated now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@portante can we resolve this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't require comments to be resolved before merging. Forgive me, but I have not had the time to review the changes in detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, can you consider removing your objection to this PR, its blocking the merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I got finished; but I just realized I left comments so I might as well publish them before today ends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the dependencies of this PR, should it be moved to draft mode?
lib/pbench/client/oidc_admin.py
Outdated
from requests.structures import CaseInsensitiveDict | ||
|
||
|
||
class OIDCAdmin: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to defer reviewing this code until this change is made.
Converted this to the draft mode again, I need to work on the new users table that we talked about in the design sync meeting. |
Please don't create a new users table. We already have one. |
Well, we can't use the current users table, it has user credentials information in it. So we have to drop it entirely and create a have a new one without all the user login stuff. |
That's a semantic distinction I wouldn't worry about. You probably want to drop most of the existing columns. We only need a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase this on the openid-connect
branch?
I changed the base but I'll rebase it on the openid-connect in some time. |
73ac125
to
f100592
Compare
9f96d38
to
c0c8625
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you've added support for the json
parameter, you should revert the changes to add the str
type to the data
parameter (I'm hoping there's no reason why you cannot do that...). And, there are a bunch of nits which you should fix. And, I've got some suggestions, questions, and the odd request.
0d3351a
to
9f70672
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, Nikhil.
Just a couple of tiny nits if you are so inclined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it!
No longer participating in the review cycle for this PR.
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
* Use OIDC user for the functional test Functional tests should move to using OIDC tokens by making an Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing Register/Login capabilities on its endpoints. - Create a new scope in the Keycloak to add OIDC client name in aud claim (required for the authentication) - Functional test user registration happens directly with the OIDC server using the Admin token - Functional test user makes a REST API call to get the OIDC token PBENCH-1070
PBENCH-1070
To facilitate the removal of the dependency on the internal user API and internal users table we need to update the functional tests to not use the internal APIs.
Functional tests should move to using OIDC tokens by making a Admin REST API request to the OIDC server (Keycloak) directly as the server won't be providing those capabilities on its endpoints.
This PR is currently rebased on top of PR #3114