-
Notifications
You must be signed in to change notification settings - Fork 0
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 stateless authentication (Quarkus OIDC) #30
Comments
I've spent a few hours trying to get OIDC working with Quakus + Hilla. For notes, I've set up my config as such:
This has enabled the app to automatically redirect to the OAuth RS to authorize, and the application receives and stores the auth. I've had to add an Endpoint, one I'm calling @BrowserCallable
@AnonymousAllowed
@AllArgsConstructor
public class AuthenticationApi {
private final SingleSignOnContext context;
private final UserInfo userInfo;
private final SecurityIdentity securityIdentity;
public @Nonnull SingleSignOnData fetchAll() {
return context.getSingleSignOnData();
}
public String token() {
return Optional.ofNullable(securityIdentity.getCredential(AccessTokenCredential.class)).map(token -> token.getToken()).orElse(null);
}
public @Nonnull List<@Nonnull String> getRegisteredProviders() {
return context.getRegisteredProviders();
}
public OidcUser getAuthenticatedUser() {
return context.getSingleSignOnData().isAuthenticated() ? OidcUser.fromUserInfo(userInfo) : null;
}
} Of interest is the import { Middleware, MiddlewareContext, MiddlewareNext } from '@hilla/frontend';
import { AuthenticationApi } from 'Frontend/generated/endpoints';
export const AuthenticatedRequestMiddleware: Middleware = async function(
context: MiddlewareContext,
next: MiddlewareNext
) {
if (!context.request.url.includes("AuthenticationApi")) {
const token = await AuthenticationApi.token()
context.request.headers.append("Authorization", "Bearer " + token)
}
return await next(context);
}; With the above, sadly, it's making a new call to get the token, so I should store it in a cache (or The conundrum however appears at the controller level: per Quarkus' documentation, the I suppose the only way around this right now is to use RBAC: |
Hi @UbiquitousBear, thank you for giving a try to quarkus-hilla and for the feedback. To better understand the problem, is the issue related to calls to |
If the problem is the
This should probably be done automatically by quarkus-hilla in some way. |
@mcollovati To clarify, I believe there's two different definitions for On a different note, is it possible to define a custom annotation as such:
Any use this on |
That's indeed true. What we can do is to introduce a build step that converts the About the meta annotations, I don't know if this works out-of-the-box in a plain Hilla project. |
@mcollovati what are we defining as Stateless here; that requests are made without the sessions cookie? |
@UbiquitousBear we define it as not be bound to a server side session/context (e.g. this definition) in terms of authentication/authorization. I named the ticket this way, because I wasn't sure what other auth mechanisms are available, so it is a bit missleading. Cookie/Header based auth per request is basically always stateless, as long it is not bound to a specific server side session or context. Hilla is designed to be stateless and as we are replacing Spring Boot internals with equivalent Quarkus code, it should work. We just haven't tested it ourself nor added tests for it. So we can't guarantee for it. |
What does it look like? It is already a key functionality that everything should work statelessly. Is work still being done at this point or is there already a definitive solution? Thank you very much for your work! |
Hi @vexa, thanks for the interest! We still hadn't the time to test it. It could work out of the box, but we can't gurantee it. I am self interested in using it in my own projects, but can't say when I will dig into it. It is still on our todo list. |
In the first, check if it working OOB.
The text was updated successfully, but these errors were encountered: