Class TestConfigs

java.lang.Object
org.pac4j.testkit.TestConfigs

public final class TestConfigs extends Object
Provides standard pac4j Config objects for each authentication mechanism.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.pac4j.core.config.Config
    JWT config where /protected requires BOTH ROLE_USER and ROLE_ADMIN.
    static org.pac4j.core.config.Config
    HTTP Basic authentication.
    static org.pac4j.core.config.Config
    JWT (Bearer token) AND API Key (X-Api-Key) chained on the same endpoint.
    static org.pac4j.core.config.Config
    API key via X-Api-Key header.
    static org.pac4j.core.config.Config
    Form-based authentication with username/password POST.
    static org.pac4j.core.config.Config
    JWT via Authorization: Bearer token header.
    static org.pac4j.core.config.Config
    JWT config where /protected allows GET but denies POST via HttpMethodMatcher.
    static org.pac4j.core.config.Config
    oidcConfig(String mockOAuthServerUrl)
    OAuth2/OIDC authorization code flow via mock-oauth2-server.
    static org.pac4j.core.config.Config
    JWT config where /protected requires auth but /other is public via PathMatcher.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • jwtConfig

      public static org.pac4j.core.config.Config jwtConfig()
      JWT via Authorization: Bearer token header.
    • formConfig

      public static org.pac4j.core.config.Config formConfig()
      Form-based authentication with username/password POST.
    • basicAuthConfig

      public static org.pac4j.core.config.Config basicAuthConfig()
      HTTP Basic authentication.
    • chainedConfig

      public static org.pac4j.core.config.Config chainedConfig()
      JWT (Bearer token) AND API Key (X-Api-Key) chained on the same endpoint. JWT tried first.
    • directConfig

      public static org.pac4j.core.config.Config directConfig()
      API key via X-Api-Key header.
    • allRolesAuthorizerConfig

      public static org.pac4j.core.config.Config allRolesAuthorizerConfig()
      JWT config where /protected requires BOTH ROLE_USER and ROLE_ADMIN.
    • methodMatcherConfig

      public static org.pac4j.core.config.Config methodMatcherConfig()
      JWT config where /protected allows GET but denies POST via HttpMethodMatcher.
    • pathMatcherConfig

      public static org.pac4j.core.config.Config pathMatcherConfig()
      JWT config where /protected requires auth but /other is public via PathMatcher.
    • oidcConfig

      public static org.pac4j.core.config.Config oidcConfig(String mockOAuthServerUrl)
      OAuth2/OIDC authorization code flow via mock-oauth2-server.
      Parameters:
      mockOAuthServerUrl - base URL of the running mock-oauth2-server (e.g. http://localhost:12345)