Skip to content
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

Compilation fails if JWT auth is selected #42

Closed
JasonTypesCodes opened this issue May 14, 2020 · 7 comments · Fixed by #58
Closed

Compilation fails if JWT auth is selected #42

JasonTypesCodes opened this issue May 14, 2020 · 7 comments · Fixed by #58
Assignees
Labels
bug 🐞 Something isn't working

Comments

@JasonTypesCodes
Copy link
Contributor

This was likely introduced with the OAuth support:

[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ jhipster ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 64 source files to /home/schindlerj/src/temp/jhipster/base-test/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/schindlerj/src/temp/jhipster/base-test/src/main/java/io/github/jhipster/sample/security/KeycloakEndSessionEndpoint.java:[7,43] package io.micronaut.security.oauth2.client does not exist
[ERROR] /home/schindlerj/src/temp/jhipster/base-test/src/main/java/io/github/jhipster/sample/security/ApiLogoutController.java:[10,36] package io.micronaut.security.oauth2 does not exist
[ERROR] /home/schindlerj/src/temp/jhipster/base-test/src/main/java/io/github/jhipster/sample/security/JHipsterOpenIdUserDetailsMapper.java:[7,50] package io.micronaut.security.oauth2.configuration does not exist
@JasonTypesCodes JasonTypesCodes added the bug 🐞 Something isn't working label May 14, 2020
ZacharyKlein added a commit that referenced this issue May 14, 2020
@ZacharyKlein
Copy link
Contributor

@JasonTypesCodes This should be fixed now. I moved the listed classes to a conditional block for oauth2

@JasonTypesCodes
Copy link
Contributor Author

New error now:

[INFO] ERROR in /home/schindlerj/src/temp/jhipster/base-test/src/main/webapp/app/layouts/navbar/navbar.component.ts(58,5):
[INFO] TS2554: Expected 1 arguments, but got 0.

It looks like the login method on the LoginService is expecting a Login credentials as input.

@mraible
Copy link
Contributor

mraible commented May 14, 2020

I'm curious - why is there a Keycloak-specific class (KeycloakEndSessionEndpoint)? We try to make our OAuth implementation IdP-agnostic.

@jameskleeh
Copy link

@mraible Because end session implementation is not part of the open id spec, thus vendor specific details have to be provided. Micronaut security does not currently have an implementation specific to Keycloak

@sdelamo
Copy link

sdelamo commented May 14, 2020

Since the redirect parameters are being populated from Javascript. We probably should be able to replace KeycloackEndSessionEndpoint with:

package <%=packageName%>.security;

import io.micronaut.http.HttpRequest;
import io.micronaut.http.server.util.HttpHostResolver;
import io.micronaut.http.uri.UriBuilder;
import io.micronaut.security.authentication.Authentication;
import io.micronaut.security.oauth2.client.OpenIdProviderMetadata;
import io.micronaut.security.oauth2.configuration.endpoints.EndSessionConfiguration;
import io.micronaut.security.oauth2.endpoint.endsession.request.EndSessionEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import javax.inject.Named;
import java.net.URI;

@Named("oidc")
public class OidcEndSessionEndpoint implements EndSessionEndpoint {
    private static final Logger LOG = LoggerFactory.getLogger(OidcEndSessionEndpoint.class);

    private final OpenIdProviderMetadata openIdProviderMetadata;

    public OidcEndSessionEndpoint(@Named("oidc") OpenIdProviderMetadata openIdProviderMetadata) {
        this.openIdProviderMetadata = openIdProviderMetadata;
    }

    @Nullable
    @Override
    public String getUrl(HttpRequest originating, Authentication authentication) {
        return openIdProviderMetadata.getEndSessionEndpoint();
    }
}

@mraible
Copy link
Contributor

mraible commented May 14, 2020

You might be able use something similar to what we use for Spring Boot. We just have a LogoutController that returns the logout endpoint URI and ID token. This works with both Keycloak and Okta.

Spring Security supports RP-Initiated Logout, but I've been unable to get this to work when adding a JS client to the mix. Also, it requires that you hard-code the post-logout-redirect-uri, which I think is inconvenient.

@JasonTypesCodes
Copy link
Contributor Author

I created #45 for the Keycloak implementation

@JasonTypesCodes JasonTypesCodes self-assigned this May 15, 2020
JasonTypesCodes added a commit that referenced this issue May 15, 2020
Fixes errors in Angular client when not using OAuth2 (#42)
JasonTypesCodes pushed a commit that referenced this issue May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants