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

Support Okta as OIDC #78

Closed
JasonTypesCodes opened this issue Jun 1, 2020 · 13 comments · Fixed by #85
Closed

Support Okta as OIDC #78

JasonTypesCodes opened this issue Jun 1, 2020 · 13 comments · Fixed by #85
Assignees
Labels
enhancement 💎 New feature or request

Comments

@JasonTypesCodes
Copy link
Contributor

See: jhipster/generator-jhipster#11715

@atomfrede
Copy link
Member

We need at least to overwrite application.properties with a dedicated heroku properties and change the issuer, clientsecret. And it looks like the redirect uris are different from the nes we have on the boot backend. If we could align them we can reuse the script, but adapting the script should also be no problem.

https://github.com/jhipster/generator-jhipster-micronaut/blob/master/generators/server/templates/src/main/resources/application.yml.ejs#L43

@atomfrede atomfrede mentioned this issue Jun 8, 2020
2 tasks
@atomfrede atomfrede self-assigned this Jun 9, 2020
@atomfrede
Copy link
Member

I will handle this together with #85

@atomfrede atomfrede added the enhancement 💎 New feature or request label Jun 9, 2020
@atomfrede
Copy link
Member

I have an apllication deployed via heroku and setup all in the heroku add on. The micronaut app send the redirect url as http instead of https (the skript configures https).

@JasonTypesCodes do you know it that can be changed?

@JasonTypesCodes
Copy link
Contributor Author

Which redirect url are you referring to? The one provided to the OIDC?

@atomfrede
Copy link
Member

Yes, the one provided to the OIDC, when clicking login. `https://....okta.com/oauth2/default/v1/authorize?scope=openid+email+profile&response_type=code&redirect_uri=http%3A%2F%2Fmhipster-5.herokuapp.com%2Foauth2%2Fcallback%2Foidc&state=....

@mraible Not sure, but at least right now checking the AccessToken instead the IdToken here does not work as the groups claim is only setup for the id token (as documented here).
Switching to tokenResponse.getIdToken() works at least without null pointer exception, but the app does think I am not logged in. The roles are correctly extracted from the token tough.

@JasonTypesCodes
Copy link
Contributor Author

@atomfrede I presume you are in a situation where there is something between the Micronaut server and the consumer and Micronaut is running in HTTP but the end user to connecting through something else using HTTPS.

One option is to run Micronaut with micronaut.ssl.enabled set to true

Another option is to add your own HttpHostResolver implementation. Something like this should work:

@Replaces(DefaultHttpHostResolver.class)
@Singleton
public class SSLEnforcingHostResolver extends DefaultHttpHostResolver {

    public static final String HTTP = "http://";
    public static final String HTTPS = "https://";

    public SSLEnforcingHostResolver(HttpServerConfiguration serverConfiguration, Provider<EmbeddedServer> embeddedServer) {
        super(serverConfiguration, embeddedServer);
    }

    @Nonnull
    @Override
    public String resolve(@Nullable HttpRequest request) {
        String host = super.resolve(request);
        if (host.startsWith(HTTP)) {
            return host.replaceAll(HTTP, HTTPS);
        }
        return host;
    }
}

You can also add the @Requires annotation to specify the environments to use it in.

@atomfrede
Copy link
Member

Thanks will give it a try. Hopefully setting the property is enough

@atomfrede
Copy link
Member

The custom host resolver works fine. Another question, which is not clear to me from the documentation. For spring boot we active e.g. heroku,prod profiles/environments. The datasource propoerties from heroku have precedence. When activating prod and heroku the properties from prod configuration are taken. I could overwrite them via system properties, but thats more complicated from the generator/template point of view.

@JasonTypesCodes
Copy link
Contributor Author

The order that the environments are specified should determine which property is loaded. See: https://docs.micronaut.io/latest/guide/index.html#_environment_priority

@atomfrede
Copy link
Member

Thanks @JasonTypesCodes seems to works. I think I provide a small improvement to the docs to make that easier to spot.

@atomfrede atomfrede linked a pull request Jun 15, 2020 that will close this issue
5 tasks
@atomfrede
Copy link
Member

@JasonTypesCodes Do you have started already to add the user sync with the idp? My first try does it in the user details mapper and works fine.

@JasonTypesCodes
Copy link
Contributor Author

@atomfrede All of my recent work is merged now. I did not add anything to sync user information with the idp.

@atomfrede
Copy link
Member

I provide a small proposal to sync the users such that it would work with users created in keycloak/okta only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💎 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants