Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OAuth2Auth

Factory interface for creating OAuth2 based {@link AuthenticationProvider} instances.

Hierarchy

  • any
    • OAuth2Auth

Index

Methods

authorizeURL

  • 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

    • params: {}
      • [key: string]: any

    Returns string

  • 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

    Returns string

close

  • close(): void
  • 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.

    Returns void

endSessionURL

  • endSessionURL(user: User, params: {}): string
  • endSessionURL(user: User): string

jWKSet

  • jWKSet(): PromiseLike<void>
  • jWKSet(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): OAuth2Auth
  • Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens. The provider will refresh the keys according to: https://openid.net/specs/openid-connect-core-1_0.html#RotateEncKeys

    This means that the provider will look at the cache headers and will refresh when the max-age is reached. If the server does not return any cache headers it shall be up to the end user to call this method to refresh.

    To avoid the refresh to happen too late, this means that they keys will be invalid, if the OAuth2Options JWTOptions config contains a positive leeway, it will be used to request the refresh ahead of time.

    Key rotation can be controled by OAuth2Options.

    Returns PromiseLike<void>

  • Retrieve the public server JSON Web Key (JWK) required to verify the authenticity of issued ID and access tokens. The provider will refresh the keys according to: https://openid.net/specs/openid-connect-core-1_0.html#RotateEncKeys

    This means that the provider will look at the cache headers and will refresh when the max-age is reached. If the server does not return any cache headers it shall be up to the end user to call this method to refresh.

    To avoid the refresh to happen too late, this means that they keys will be invalid, if the OAuth2Options JWTOptions config contains a positive leeway, it will be used to request the refresh ahead of time.

    Key rotation can be controled by OAuth2Options.

    Parameters

    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns OAuth2Auth

missingKeyHandler

  • missingKeyHandler(handler: ((res: string) => void) | Handler<string>): OAuth2Auth
  • Handled to be called when a key (mentioned on a JWT) is missing from the current config. Users are advised to call {@link OAuth2Auth#jWKSet} 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 {@link OAuth2Auth#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: ((res: string) => void) | Handler<string>

    Returns OAuth2Auth

refresh

  • refresh(user: User): PromiseLike<User>
  • refresh(user: User, handler: ((res: AsyncResult<User>) => void) | Handler<AsyncResult<User>>): OAuth2Auth
  • Refresh the current User (access token).

    Parameters

    • user: User

    Returns PromiseLike<User>

  • Refresh the current User (access token).

    Parameters

    • user: User
    • handler: ((res: AsyncResult<User>) => void) | Handler<AsyncResult<User>>

    Returns OAuth2Auth

revoke

  • revoke(user: User, tokenType: string): PromiseLike<void>
  • revoke(user: User, tokenType: string, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): OAuth2Auth
  • revoke(user: User): PromiseLike<void>
  • revoke(user: User, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): OAuth2Auth
  • Revoke an obtained access or refresh token. More info https://tools.ietf.org/html/rfc7009.

    Parameters

    • user: User
    • tokenType: string

    Returns PromiseLike<void>

  • Revoke an obtained access or refresh token. More info https://tools.ietf.org/html/rfc7009.

    Parameters

    • user: User
    • tokenType: string
    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns OAuth2Auth

  • Revoke an obtained access token. More info https://tools.ietf.org/html/rfc7009.

    Parameters

    • user: User

    Returns PromiseLike<void>

  • Revoke an obtained access token. More info https://tools.ietf.org/html/rfc7009.

    Parameters

    • user: User
    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns OAuth2Auth

userInfo

  • userInfo(user: User): PromiseLike<{}>
  • userInfo(user: User, handler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): OAuth2Auth

Static create

  • Create a OAuth2 auth provider.

    Parameters

    • vertx: Vertx

    Returns OAuth2Auth

  • Create a OAuth2 auth provider

    Parameters

    Returns OAuth2Auth

Generated using TypeDoc