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

PAYARA-2718 Added Microprofile Config support to OAuth definition ann… #2704

Merged
merged 7 commits into from
May 29, 2018

Conversation

Cousjava
Copy link
Contributor

@Cousjava Cousjava commented May 3, 2018

…otation

@Cousjava Cousjava added this to the Payara 5.182 milestone May 3, 2018
@Cousjava
Copy link
Contributor Author

Cousjava commented May 3, 2018

Jenkins test please

@payara-ci
Copy link
Contributor

Quick build and test passed!

@Cousjava Cousjava requested a review from arjantijms May 3, 2018 09:58
*/
public OAuth2AuthenticationMechanism setDefinition(OAuth2AuthenticationDefinition definition) {;
public OAuth2AuthenticationMechanism setDefinition(OAuth2AuthenticationDefinition definition) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could reduce the complexity of this method with a utility method that does the check of which config to use if present. Especially as they are all Strings.
something like
authConfig = getConfig(definition.authEndpoint())

<version>${microprofile-config.version}</version>
<type>jar</type>
</dependency>
<dependency>
Copy link
Contributor

@MarkWareham MarkWareham May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add <scope>provided</scope> here to prevent problems

@Cousjava
Copy link
Contributor Author

Jenkins test please

@payara-ci
Copy link
Contributor

Quick build and test passed!

Copy link
Contributor

@smillidge smillidge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clean out the Payara Embedded changes from this PR

*/
public OAuth2AuthenticationMechanism setDefinition(OAuth2AuthenticationDefinition definition) {;
public OAuth2AuthenticationMechanism setDefinition(OAuth2AuthenticationDefinition definition) {
Config provider = Globals.getDefaultBaseServiceLocator().getService(ConfigProviderResolverImpl.class).getConfig();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just use Microprofile config apis to get the Config service. No need to use the internal service.

In fact you could just Optional inject the values.

<optional>true</optional>
</dependency>
<!-- phomehome package -->
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does any of this have to do with the name on the PR

@Cousjava Cousjava force-pushed the PAYARA-2718-config branch from edab05c to 1e7a5dd Compare May 17, 2018 08:20
@Cousjava
Copy link
Contributor Author

Jenkins test please

@payara-ci
Copy link
Contributor

Quick build and test passed!

@arjantijms
Copy link
Contributor

The general approach needs some changes. The code should not directly treat the annotation attribute as a potential MP Config key. The convention/pattern that has emerged is to use global keys that override. For instance in MP JWT 1.1 (draft):

9.3.1. mp.jwt.verify.publickey
The mp.jwt.verify.publickey config property allows the Public Key text itself to be supplied as a string. The Public Key will be parsed from the supplied string in the order defined in section Supported Public Key Formats.

Where mp.jwt.verify.publickey is a global well known key.

MP Fault tolerance uses something similar, but based on composite keys:

https://github.com/eclipse/microprofile-fault-tolerance/blob/master/spec/src/main/asciidoc/configuration.asciidoc

Finally, the issue originally asked for expression language (EL) support in the annotation attributes, which is consistent with EE Security. See https://javaee.github.io/javaee-spec/javadocs/javax/security/enterprise/package-summary.html

Since it's also a Payara annotation, which already uses the "${}" syntax, it might be best to only support the "#{}" syntax and treat that as resolve once / immediate-like.

@arjantijms arjantijms added the PR: DO NOT MERGE Don't merge PR until further notice label May 22, 2018
@Cousjava Cousjava force-pushed the PAYARA-2718-config branch from 1e7a5dd to c9803d1 Compare May 22, 2018 15:38
@Cousjava
Copy link
Contributor Author

Jenkins test please

@payara-ci
Copy link
Contributor

Quick build and test passed!

@Cousjava
Copy link
Contributor Author

Jenkins test please

@Cousjava Cousjava removed the PR: DO NOT MERGE Don't merge PR until further notice label May 25, 2018
@payara-ci
Copy link
Contributor

Quick build and test passed!

@arjantijms
Copy link
Contributor

Jenkins test

@payara-ci
Copy link
Contributor

Quick build and test passed!

String result = value;
Optional<String> configResult = provider.getOptionalValue(mpConfigKey, String.class);
if (configResult.isPresent()) {
result = configResult.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If config result is present, just return it. Don't let that value go through the processors.

(a concern was raised that this might introduce security loop holes, as the MP Config values can be set externally)

@arjantijms arjantijms added the PR: DO NOT MERGE Don't merge PR until further notice label May 29, 2018
@Cousjava Cousjava force-pushed the PAYARA-2718-config branch from 7e13b83 to 0859422 Compare May 29, 2018 08:13
@Cousjava
Copy link
Contributor Author

Jenkins test please

Copy link
Contributor

@arjantijms arjantijms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah!

@payara-ci
Copy link
Contributor

Quick build and test passed!

@Cousjava Cousjava merged commit 9088a2d into payara:master May 29, 2018
Cousjava added a commit to Cousjava/Payara that referenced this pull request May 30, 2018
payara#2704)

* PAYARA-2718 Added Microprofile Config support to OAuth definition annotation

* PAYARA-2718 added method to reduce duplication

* PAYARA-2718 Added EL# support

* Moved annotation to different package

* PAYARA-2718 Made keys well-known

* PAYARA-2718 return MP value if present directly
mulderbaba pushed a commit to kantor1974/Payara that referenced this pull request Jun 14, 2018
payara#2704)

* PAYARA-2718 Added Microprofile Config support to OAuth definition annotation

* PAYARA-2718 added method to reduce duplication

* PAYARA-2718 Added EL# support

* Moved annotation to different package

* PAYARA-2718 Made keys well-known

* PAYARA-2718 return MP value if present directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: DO NOT MERGE Don't merge PR until further notice
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants