Package io.vertx.rxjava3.ext.auth.oauth2
Class OAuth2Auth
- java.lang.Object
-
- io.vertx.rxjava3.ext.auth.authentication.AuthenticationProvider
-
- io.vertx.rxjava3.ext.auth.oauth2.OAuth2Auth
-
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate
public class OAuth2Auth extends AuthenticationProvider implements io.vertx.lang.rx.RxDelegate
Factory interface for creating OAuth2 basedAuthenticationProviderinstances.NOTE: This class has been automatically generated from the
originalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<OAuth2Auth>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description OAuth2Auth(OAuth2Auth delegate)OAuth2Auth(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringauthorizeURL(OAuth2AuthorizationURL url)The client sends the end-user's browser to this endpoint to request their authentication and consent.voidclose()Releases any resources or timers used by this instance.static OAuth2Authcreate(Vertx vertx)Create a OAuth2 auth provider.static OAuth2Authcreate(Vertx vertx, OAuth2Options config)Create a OAuth2 auth providerStringendSessionURL(User user)The logout (end-session) endpoint is specified in OpenID Connect Session Management 1.0.StringendSessionURL(User user, JsonObject params)The logout (end-session) endpoint is specified in OpenID Connect Session Management 1.0.booleanequals(Object o)OAuth2AuthgetDelegate()inthashCode()CompletablejWKSet()Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens.OAuth2AuthmissingKeyHandler(Handler<String> handler)Handled to be called when a key (mentioned on a JWT) is missing from the current config.static OAuth2AuthnewInstance(OAuth2Auth arg)Single<User>refresh(User user)Refresh the current User (access token).Completablerevoke(User user)Revoke an obtained access token.Completablerevoke(User user, String tokenType)Revoke an obtained access or refresh token.CompletablerxJWKSet()Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens.Single<User>rxRefresh(User user)Refresh the current User (access token).CompletablerxRevoke(User user)Revoke an obtained access token.CompletablerxRevoke(User user, String tokenType)Revoke an obtained access or refresh token.Single<JsonObject>rxUserInfo(User user)Retrieve profile information and other attributes for a logged-in end-user.StringtoString()Single<JsonObject>userInfo(User user)Retrieve profile information and other attributes for a logged-in end-user.-
Methods inherited from class io.vertx.rxjava3.ext.auth.authentication.AuthenticationProvider
authenticate, newInstance, rxAuthenticate
-
-
-
-
Field Detail
-
__TYPE_ARG
public static final io.vertx.lang.rx.TypeArg<OAuth2Auth> __TYPE_ARG
-
-
Constructor Detail
-
OAuth2Auth
public OAuth2Auth(OAuth2Auth delegate)
-
OAuth2Auth
public OAuth2Auth(Object delegate)
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toStringin classAuthenticationProvider
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classAuthenticationProvider
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAuthenticationProvider
-
getDelegate
public OAuth2Auth getDelegate()
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate- Overrides:
getDelegatein classAuthenticationProvider
-
create
public static OAuth2Auth create(Vertx vertx)
Create a OAuth2 auth provider.- Parameters:
vertx- the Vertx instance- Returns:
- the auth provider
-
create
public static OAuth2Auth create(Vertx vertx, OAuth2Options config)
Create a OAuth2 auth provider- Parameters:
vertx- the Vertx instanceconfig- the config- Returns:
- the auth provider
-
jWKSet
public Completable jWKSet()
Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens.- Returns:
- Future result.
-
rxJWKSet
public Completable rxJWKSet()
Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens.- Returns:
- Future result.
-
missingKeyHandler
public OAuth2Auth missingKeyHandler(Handler<String> handler)
Handled to be called when a key (mentioned on a JWT) is missing from the current config. Users are advised to calljWKSet()but being careful to implement some rate limiting function.This method isn't generic for several reasons. The provider is not aware of the capabilities of the backend IdP in terms of max allowed API calls. Some validation could be done at the key id, which only the end user is aware of.
A base implementation for this handler is:
// are we already updating the jwks? private final AtomicBoolean updating = new AtomicBoolean(false); // default missing key handler, will try to reload with debounce oauth2.missingKeyHandler(keyId -> { if (updating.compareAndSet(false, true)) { // Refreshing JWKs due missing key jWKSet(done -> { updating.compareAndSet(true, false); if (done.failed()) { done.cause().printStackTrace();}); } }); }This handler will purely debounce calls and allow only a single request to
jWKSet()at a time. No special handling is done to avoid requests on wrong key ids or prevent to many requests to the IdP server. Users should probably also account for the number of errors to present DDoS the IdP.- Parameters:
handler-- Returns:
- Future result.
-
authorizeURL
public String authorizeURL(OAuth2AuthorizationURL url)
The client sends the end-user's browser to this endpoint to request their authentication and consent. This endpoint is used in the code and implicit OAuth 2.0 flows which require end-user interaction.- Parameters:
url- Base URL with path together with other parameters to be included in the final URL.- Returns:
- the url to be used to authorize the user.
-
refresh
public Single<User> refresh(User user)
Refresh the current User (access token).- Parameters:
user- the user (access token) to be refreshed.- Returns:
- future result
-
rxRefresh
public Single<User> rxRefresh(User user)
Refresh the current User (access token).- Parameters:
user- the user (access token) to be refreshed.- Returns:
- future result
-
revoke
public Completable revoke(User user, String tokenType)
Revoke an obtained access or refresh token. More info https://tools.ietf.org/html/rfc7009.- Parameters:
user- the user (access token) to revoke.tokenType- the token type (either access_token or refresh_token).- Returns:
- future result
-
rxRevoke
public Completable rxRevoke(User user, String tokenType)
Revoke an obtained access or refresh token. More info https://tools.ietf.org/html/rfc7009.- Parameters:
user- the user (access token) to revoke.tokenType- the token type (either access_token or refresh_token).- Returns:
- future result
-
revoke
public Completable revoke(User user)
Revoke an obtained access token. More info https://tools.ietf.org/html/rfc7009.- Parameters:
user- the user (access token) to revoke.- Returns:
- future result
-
rxRevoke
public Completable rxRevoke(User user)
Revoke an obtained access token. More info https://tools.ietf.org/html/rfc7009.- Parameters:
user- the user (access token) to revoke.- Returns:
- future result
-
userInfo
public Single<JsonObject> userInfo(User user)
Retrieve profile information and other attributes for a logged-in end-user. More info https://openid.net/specs/openid-connect-core-1_0.html#UserInfo- Parameters:
user- the user (access token) to fetch the user info.- Returns:
- future result
-
rxUserInfo
public Single<JsonObject> rxUserInfo(User user)
Retrieve profile information and other attributes for a logged-in end-user. More info https://openid.net/specs/openid-connect-core-1_0.html#UserInfo- Parameters:
user- the user (access token) to fetch the user info.- Returns:
- future result
-
endSessionURL
public String endSessionURL(User user, JsonObject params)
The logout (end-session) endpoint is specified in OpenID Connect Session Management 1.0. More info: https://openid.net/specs/openid-connect-session-1_0.html.- Parameters:
user- the user to generate the url forparams- extra parameters to apply to the url- Returns:
- the url to end the session.
-
endSessionURL
public String endSessionURL(User user)
The logout (end-session) endpoint is specified in OpenID Connect Session Management 1.0. More info: https://openid.net/specs/openid-connect-session-1_0.html.- Parameters:
user- the user to generate the url for- Returns:
- the url to end the session.
-
close
public void close()
Releases any resources or timers used by this instance. Users are expected to call this method when the provider isn't needed any more to return the used resources back to the platform.
-
newInstance
public static OAuth2Auth newInstance(OAuth2Auth arg)
-
-