Support passing groups in OAuth access token claim#10262
Support passing groups in OAuth access token claim#10262kokosing merged 11 commits intotrinodb:masterfrom
Conversation
kokosing
left a comment
There was a problem hiding this comment.
Let's add a product tests that would call current_groups() To make sure it works end to end.
Looks nice!
core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/server/security/oauth2/OAuth2Authenticator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
identity = identity.withPrincipal(new BasicPrincipal(principal));?
There was a problem hiding this comment.
withPrincipal just modifies the builder and returns this, thus reassignment is unnecessary.
core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/server/security/TestResourceSecurity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
It's not important actually whether it allows impersonation or not but I think it's better to deny by default.
The important part is:
@Override
public void checkCanReadSystemInformation(SystemSecurityContext context)
{
if (!context.getIdentity().getUser().equals(MANAGEMENT_USER)) {
denyReadSystemInformationAccess();
}
}as it's being tested by assertAuthenticationAutomatic
There was a problem hiding this comment.
nit: we can skip this rnn here and in other places as groups field is an empty Optional by default in the config.
There was a problem hiding this comment.
Maybe not for this PR, but would it be possible to make this filter using OAuth2Authenticator? Seems they share more logic now than previously.
There was a problem hiding this comment.
I initially thought about it and I think it's generally a good idea but it would require a bit broader refactor. The important difference between OAuth2Authenticator and this filter is that protocol authenticator throws an Authentication exception (401 Unauthorized) whereas this filter redirects the browser to authentication url (303 See Other). It's doable ofc but as I said, it requires a bit of refactoring.
There was a problem hiding this comment.
You can continue the chain and avoid the if statement here by using map.
There was a problem hiding this comment.
I'm afraid it would not work. User mapping throws UserMappingException which is checked exception.
There was a problem hiding this comment.
No need for flatMap as map handles null correctly.
There was a problem hiding this comment.
Optional.map(o -> Optional.of(o)) returns Optional<Optional<>>
whereas
Optional.flatMap(o -> Optional.of(o)) returns Optional<>
There was a problem hiding this comment.
withPrincipal just modifies the builder and returns this, thus reassignment is unnecessary.
There was a problem hiding this comment.
Again map here is cleaner and clearer.
There was a problem hiding this comment.
userMapping.mapUser(principalName) throws checked UserMappingException
4b3bfdb to
13d4aea
Compare
There was a problem hiding this comment.
It's already done:
* - ``http-server.authentication.oauth2.groups-field``
- The field of the access token used for Trino groups. The corresponding claim value must be an array.Would like to add something?
...main/java/io/trino/tests/product/launcher/env/environment/EnvSinglenodeOauth2HttpsProxy.java
Outdated
Show resolved
Hide resolved
13d4aea to
dabb828
Compare
dabb828 to
338f27a
Compare
Is this related? |
...duct-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentModule.java
Outdated
Show resolved
Hide resolved
338f27a to
f9e5058
Compare
|
I don't why this happend tbh. The container simply didn't start. Let's give it another try. |
This is not an option. It seems that the environment is flaky. Please stress it out instead to see how frequent it is. Also IIRC we do retry setup of each environment which may suggest that this env failed couple times in row. I am not sure if retry happened here. |
|
Fair point. I'll stress test it. |
Also you can stress test the master to see if it is something or pre-existing issue. |
|
I was able to reproduce it locally and it looks like the problem is that |
👍 Thank you! |
26c8c76 to
a79ca06
Compare
|
I've fixed problems with the startup check. Stress tested in: https://github.com/trinodb/trino/actions/runs/1735765630 |
Temporal containers can finish faster than the startup probe can check. The check interval comes from the docker client with rate limiting which queries the docker service at most once per second. This can create a race condition if the container can complete it's job in less or around 1 second.
Instead of using selenium driver to log in and accept the consent request use a simple python implementation which accepts all requests thus eliminating the need of web driver entirely. Fixes trinodb#6991
a79ca06 to
d842185
Compare
Resolves: #10220