Skip to content

Commit

Permalink
PAYARA-2718 Added Microprofile Config support to OAuth definition ann… (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
Cousjava authored May 29, 2018
1 parent 8bdf3b8 commit 9088a2d
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 93 deletions.
2 changes: 1 addition & 1 deletion api/payara-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
fish.payara.notification.eventbus,
fish.payara.notification.healthcheck,
fish.payara.notification.requesttracing,
fish.payara.security.oauth2.annotation,
fish.payara.security.annotations,
fish.payara.security.oauth2.api
</Export-Package>
</instructions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.security.oauth2.annotation;
package fish.payara.security.annotations;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
Expand All @@ -55,49 +55,85 @@
*/
@Target({TYPE, METHOD})
@Retention(RUNTIME)
public @interface OAuth2AuthenticationDefinition {
public @interface OAuth2AuthenticationDefinition{

/**
* The Microprofile Config key for the auth endpoint is <code>{@value}</code>
*/
public static final String OAUTH2_MP_AUTH_ENDPOINT="payara.security.oauth2.authEndpoint";

/**
* Required. The URL for the OAuth2 provider to provide authentication
* <p>
* This must be a https endpoint
* This must be a https endpoint.
* </p>
* To set this using Microprofile Config use {@code payara.security.oauth2.authEndpoint}.
* @return
*/
@NotNull
String authEndpoint();

/**
* The Microprofile Config key for the token Endpoint is <code>{@value}</code>
*/
public static final String OAUTH2_MP_TOKEN_ENDPOINT="payara.security.oauth2.tokenEndpoint";

/**
* Required. The URL for the OAuth2 provider to give the authorisation token
* <p>
* To set this using Microprofile Config use {@code payara.security.oauth2.tokenEndpoint}
* @return
*/
@NotNull
String tokenEndpoint();

/**
* The Microprofile Config key for the clientId is <code>{@value}</code>
*/
public static final String OAUTH2_MP_CLIENT_ID="payara.security.oauth2.clientId";

/**
* Required. The client identifier issued when the application was registered
* <p>
* To set this using Microprofile Config use {@code payara.security.oauth2.cliendId}
* @return the client identifier
*/
@NotNull
String clientId();

/**
* The Microprofile Config key for the client secret is <code>{@value}</code>
*/
public static final String OAUTH2_MP_CLIENT_SECRET="payara.security.oauth2.clientSecret";

/**
* Required. The client secret
* <p>
* It is recommended to set this using an alias.
* </p>
* To set this using Microprofile Config use {@code payara.security.oauth2.clientSecret}
* @return
* @see <a href="https://docs.payara.fish/documentation/payara-server/password-aliases/password-aliases-overview.html">Payara Password Aliases Documentation</a>
*/
@NotNull
String clientSecret();

/**
* The Microprofile Config key for the redirect URI is <code>{@value}</code>
*/
public static final String OAUTH2_MP_REDIRECT_URI = "payara.security.oauth2.redirectURI";

/**
* The callback URI.
* <p>
* If supplied this must be equal to one set in the OAuth2 Authentication provider
* If supplied this must be equal to one set in the OAuth2 Authentication provider.
* <p>
* To set this using Microprofile Config use {@code payara.security.oauth2.redirectURI}
* @return
*/
String redirectURI() default "";

/**
* The Microprofile Config key for the scope is <code>{@value}</code>
*/
public static final String OAUTH2_MP_SCOPE = "payara.security.oauth2.scope";

/**
* The scope that will be requested from the OAuth provider
* @return
Expand Down
12 changes: 12 additions & 0 deletions appserver/payara-appserver-modules/security-oauth2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>${microprofile-config.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>fish.payara.nucleus.microprofile.config</groupId>
<artifactId>microprofile-config-service</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit 9088a2d

Please sign in to comment.