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

Add quarkus.oidc.proxy config #8120

Merged
merged 1 commit into from
Mar 25, 2020
Merged

Conversation

dxps
Copy link
Contributor

@dxps dxps commented Mar 24, 2020

One addition to oidc extension: ability to use a proxy for talking with OIDC provider.
The following configuration items were added and can be used for this purpose:

  • quarkus.oidc.proxy.host
  • quarkus.oidc.proxy.port
  • quarkus.oidc.proxy.username
  • quarkus.oidc.proxy.password
  • quarkus.oidc.proxy.type (update: ignored for now)

This refers to issue 8088.

Waiting for Quarkus team review and feedback.
Thanks.

@sberyozkin
Copy link
Member

@DEVisions Many thanks for this PR, minor updates are suggested, cheers

@dxps
Copy link
Contributor Author

dxps commented Mar 24, 2020

@sberyozkin Many thanks for the feedback, Sergey! Changes submitted. I hope it's ok now.
Sorry for the last two sloppy commits.

@dxps dxps changed the title defining and exposing quarkus.oidc.proxy config Add quarkus.oidc.proxy config Mar 24, 2020
@sberyozkin
Copy link
Member

@DEVisions It all looks perfect to me now, as far as I recall the curly braces should be used all the time, so please tweak that and it should be ready to go.
There is some strange JDK11 compilation error which is not related to your PR.
Can you please do another minor update re those curly braces, squash the commits, and also fetch and rebase upstream/master and force-push ?
Thanks

@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

@sberyozkin We should be good now, right? 😊 Thanks

@gastaldi
Copy link
Contributor

Please squash your commits into a single one

@sberyozkin
Copy link
Member

sberyozkin commented Mar 25, 2020

Hi @DEVisions It looks nice and ready to go :-), one more thing, @stuartwdouglas recommends avoiding using lambdas in the recorder in general due to them being a bit suboptimal. Can you please give me a favour and update that toProxyOptions with simple if proxy.username.isPresent() and the same for password ? You can just use .get() for host and port because the check that both of these props are set has already been done.

And squash as George has said.
Cheers

@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

Hi @sberyozkin , Sure. You mean like this:

private ProxyOptions toProxyOptions(OidcTenantConfig.Proxy proxyConfig) {
        JsonObject jsonOptions = new JsonObject();
        jsonOptions.put("host", proxyConfig.host.get());
        jsonOptions.put("port", proxyConfig.port.getAsInt());
        if (proxyConfig.username.isPresent()) {
            jsonOptions.put("username", proxyConfig.username.get());
        }
        if (proxyConfig.password.isPresent()) {
            jsonOptions.put("password", proxyConfig.password.get());
        }
        return new ProxyOptions(jsonOptions);
    }

And I'll try to do the squashing now...

@gastaldi
Copy link
Contributor

Be aware that host and port are optional too

@gastaldi
Copy link
Contributor

Perhaps it's better to move the optional checks from the Recorder class to this method. I forgot you were performing the optional test there

@gastaldi
Copy link
Contributor

gastaldi commented Mar 25, 2020

It would be nice to also have a small unit test to ensure that this method works

@dxps dxps force-pushed the 8088-oidc-proxy branch from 7bd30ed to 5b0ee2c Compare March 25, 2020 12:12
@boring-cyborg boring-cyborg bot added area/arc Issue related to ARC (dependency injection) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle area/maven area/platform Issues related to definition and interaction with Quarkus Platform labels Mar 25, 2020
@dxps dxps force-pushed the 8088-oidc-proxy branch from 5b0ee2c to fb8f3ef Compare March 25, 2020 12:27
@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

Be aware that host and port are optional too

@gastaldi George, if both host and port are optional, therefore we "enable" the proxy if at least "host" is being defined in the config?

Sure, I'll include a unit test for toProxyOptions(OidcTenantConfig.Proxy proxyConfig) method.

@gastaldi
Copy link
Contributor

if both host and port are optional, therefore we "enable" the proxy if at least "host" is being defined in the config?

Yes, that makes sense, and make sure to set a default value of 80 for the port

@sberyozkin
Copy link
Member

sberyozkin commented Mar 25, 2020

@DEVisions @gastaldi so if we move the optional checks out of OidcRecorder to this method then setting a host is enough (with a default 80 port) to return ProxyOptions and if host is not set then null is returned ? That is good

@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

@sberyozkin Actually, the enablement is done in .createTenantContext() as:

        Optional<ProxyOptions> proxyOpt = toProxyOptions(oidcConfig.getProxy());
        if (proxyOpt.isPresent()) {
            options.setProxyOptions(proxyOpt.get());
        }

And the rules are now moved into toProxyOptions(OidcTenantConfig.Proxy).

Submitted the updates, including a unit test.

@dxps dxps force-pushed the 8088-oidc-proxy branch from fb8f3ef to 23b75d0 Compare March 25, 2020 13:23
@dxps dxps force-pushed the 8088-oidc-proxy branch from 23b75d0 to 1cc1309 Compare March 25, 2020 13:31
@dxps dxps force-pushed the 8088-oidc-proxy branch from 1cc1309 to a32122c Compare March 25, 2020 13:37
@dxps dxps force-pushed the 8088-oidc-proxy branch from a32122c to 73406e1 Compare March 25, 2020 13:39
@sberyozkin
Copy link
Member

boring-cyborg got over-excited and added lots of labels :-)

@dxps dxps force-pushed the 8088-oidc-proxy branch from 73406e1 to 500aa21 Compare March 25, 2020 14:01
@gastaldi gastaldi added this to the 1.4.0 milestone Mar 25, 2020
@gastaldi gastaldi added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 25, 2020
@sberyozkin
Copy link
Member

sberyozkin commented Mar 25, 2020

@DEVisions, nearly there :-), can you please do mvn process-sources in extensions/oidc and squash again ?

@dxps dxps force-pushed the 8088-oidc-proxy branch from 500aa21 to ae20df8 Compare March 25, 2020 16:09
@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

@sberyozkin Done! Are we there? ☺️

@sberyozkin
Copy link
Member

@DEVisions Hope so :-), it is already approved

@sberyozkin sberyozkin merged commit 19e0122 into quarkusio:master Mar 25, 2020
@sberyozkin
Copy link
Member

sberyozkin commented Mar 25, 2020

@DEVisions thanks for your PR. It will only be available in 1.4.0 though because only critical fixes go to 1.3.1.Final. 1.4.0 will be out soon enough too I guess :-)

@dxps dxps deleted the 8088-oidc-proxy branch March 25, 2020 19:57
@dxps
Copy link
Contributor Author

dxps commented Mar 25, 2020

@sberyozkin @gastaldi Thank you both for the support and quick feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle area/maven area/oidc area/platform Issues related to definition and interaction with Quarkus Platform triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants