Class AuthConfig.Builder
java.lang.Object
com.loomcache.common.config.AuthConfig.Builder
- Enclosing class:
AuthConfig
Builder for AuthConfig instances.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAdminRole(String name) Add an admin role with full permissions.addCertPermission(String cnPattern, String permissionLevel) Add a certificate CN pattern to permission level mapping.addJaasLoginModule(String className) addJaasLoginModule(String className, AuthConfig.LoginModuleControlFlag controlFlag, Map<String, String> options) addJaasRolePrincipalClassName(String className) Add a role with its permissions.Add a role with its permissions.Add a role with command permissions and fine-grained scoped permissions.addRole(String name, Set<String> permissions, Set<AuthConfig.PermissionConfig> permissionConfigs, Set<AuthConfig.EndpointConfig> endpoints) Add a role with command permissions, fine-grained scoped permissions, and endpoints.addRoleEndpoint(String name, String endpoint) Add a CIDR-bounded endpoint restriction to a role.addRoleEndpoints(String name, Set<String> endpoints) Add CIDR-bounded endpoint restrictions to a role, creating the role if needed.addRolePermissionConfig(String name, AuthConfig.PermissionConfig permissionConfig) Add a fine-grained permission config to a role, creating the role if needed.addTokenHash(String sha256Hex, String username, Set<String> roleNames) addTrustedGatewayAddress(String address) Add a trusted gateway source address.build()Build the AuthConfig instance.enabled(boolean enabled) Enable or disable authorization.gatewayTrust(boolean trust) Set whether to trust gateway-forwarded headers.jaasEnabled(boolean enabled) jaasLoginContextName(String loginContextName) jaasRolePrincipalClassNames(Set<String> classNames) kerberosControlFlag(AuthConfig.LoginModuleControlFlag controlFlag) kerberosControlFlag(String controlFlag) kerberosDebug(boolean debug) kerberosDoNotPrompt(boolean doNotPrompt) kerberosEnabled(boolean enabled) kerberosIsInitiator(boolean isInitiator) kerberosKeyTab(@Nullable String keyTab) kerberosLoginModuleClassName(String className) kerberosOption(String name, String value) kerberosOptions(Map<String, String> options) kerberosPrincipal(@Nullable String principal) kerberosRefreshKrb5Config(boolean refreshKrb5Config) kerberosRenewTgt(boolean renewTgt) kerberosStoreKey(boolean storeKey) kerberosTicketCache(@Nullable String ticketCache) kerberosUseKeyTab(boolean useKeyTab) kerberosUseTicketCache(boolean useTicketCache) ldapAuthIdentity(@Nullable String authIdentity) ldapAuthzIdentity(@Nullable String authzIdentity) ldapControlFlag(AuthConfig.LoginModuleControlFlag controlFlag) ldapControlFlag(String controlFlag) ldapEnabled(boolean enabled) ldapOption(String name, String value) ldapOptions(Map<String, String> options) ldapUserFilter(@Nullable String userFilter) ldapUserProvider(String userProvider) ldapUseSsl(boolean useSsl) rolePrefix(String prefix) Set the role prefix to strip.roleSeparator(String separator) Set the separator for multiple roles.rolesHeader(String header) Set the header name for roles.tokenEnabled(boolean enabled) trustedGatewayAddresses(Set<String> addresses) Replace the trusted gateway source address allow-list.userHeader(String header) Set the header name for username.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
enabled
Enable or disable authorization.- Parameters:
enabled- true to enable authorization- Returns:
- this builder
-
gatewayTrust
Set whether to trust gateway-forwarded headers.- Parameters:
trust- true to trust forwarded headers- Returns:
- this builder
-
userHeader
Set the header name for username.- Parameters:
header- the header name (must not be null)- Returns:
- this builder
-
rolesHeader
Set the header name for roles.- Parameters:
header- the header name (must not be null)- Returns:
- this builder
-
rolePrefix
Set the role prefix to strip.- Parameters:
prefix- the prefix (must not be null)- Returns:
- this builder
-
roleSeparator
Set the separator for multiple roles.- Parameters:
separator- the separator (must not be null)- Returns:
- this builder
-
trustedGatewayAddresses
Replace the trusted gateway source address allow-list.- Parameters:
addresses- source IP addresses/hostnames that may forward auth headers- Returns:
- this builder
-
addTrustedGatewayAddress
Add a trusted gateway source address.- Parameters:
address- source IP address/hostname- Returns:
- this builder
-
addRole
Add a role with its permissions.- Parameters:
name- the role name (must not be null)permissions- the set of permissions (must not be null)- Returns:
- this builder
-
addRole
public AuthConfig.Builder addRole(String name, Set<String> permissions, Set<AuthConfig.PermissionConfig> permissionConfigs) Add a role with command permissions and fine-grained scoped permissions.- Parameters:
name- the role name (must not be null)permissions- command permissions (must not be null)permissionConfigs- scoped permission configs (must not be null)- Returns:
- this builder
-
addRolePermissionConfig
public AuthConfig.Builder addRolePermissionConfig(String name, AuthConfig.PermissionConfig permissionConfig) Add a fine-grained permission config to a role, creating the role if needed.- Parameters:
name- the role name (must not be null)permissionConfig- scoped permission config (must not be null)- Returns:
- this builder
-
addRoleEndpoints
Add CIDR-bounded endpoint restrictions to a role, creating the role if needed. An empty endpoint set leaves the role unbounded.- Parameters:
name- the role name (must not be null)endpoints- endpoint CIDRs or "*" (must not be null)- Returns:
- this builder
-
addRoleEndpoint
Add a CIDR-bounded endpoint restriction to a role.- Parameters:
name- the role name (must not be null)endpoint- endpoint CIDR or "*" (must not be null)- Returns:
- this builder
-
addRole
public AuthConfig.Builder addRole(String name, Set<String> permissions, Set<AuthConfig.PermissionConfig> permissionConfigs, Set<AuthConfig.EndpointConfig> endpoints) Add a role with command permissions, fine-grained scoped permissions, and endpoints.- Parameters:
name- the role name (must not be null)permissions- command permissions (must not be null)permissionConfigs- scoped permission configs (must not be null)endpoints- endpoint CIDRs or "*" (must not be null)- Returns:
- this builder
-
addRole
Add a role with its permissions.- Parameters:
name- the role name (must not be null)permissions- the permissions (must not be empty)- Returns:
- this builder
-
addAdminRole
Add an admin role with full permissions.- Parameters:
name- the role name (must not be null)- Returns:
- this builder
-
addCertPermission
Add a certificate CN pattern to permission level mapping.- Parameters:
cnPattern- the CN pattern (exact or wildcard like "cluster-*", must not be null)permissionLevel- the permission level string: "READ_ONLY", "READ_WRITE", or "ADMIN" (must not be null)- Returns:
- this builder
- Throws:
IllegalArgumentException- if permissionLevel is not a valid level
-
jaasEnabled
-
jaasLoginContextName
-
addJaasLoginModule
-
addJaasLoginModule
-
addJaasLoginModule
public AuthConfig.Builder addJaasLoginModule(String className, AuthConfig.LoginModuleControlFlag controlFlag, Map<String, String> options) -
jaasRolePrincipalClassNames
-
addJaasRolePrincipalClassName
-
ldapEnabled
-
ldapUserProvider
-
ldapAuthIdentity
-
ldapUserFilter
-
ldapAuthzIdentity
-
ldapUseSsl
-
ldapControlFlag
-
ldapControlFlag
-
ldapOption
-
ldapOptions
-
kerberosEnabled
-
kerberosLoginModuleClassName
-
kerberosPrincipal
-
kerberosKeyTab
-
kerberosUseKeyTab
-
kerberosStoreKey
-
kerberosUseTicketCache
-
kerberosTicketCache
-
kerberosRenewTgt
-
kerberosDoNotPrompt
-
kerberosIsInitiator
-
kerberosRefreshKrb5Config
-
kerberosDebug
-
kerberosControlFlag
-
kerberosControlFlag
-
kerberosOption
-
kerberosOptions
-
tokenEnabled
-
addToken
-
addToken
-
addTokenHash
-
build
Build the AuthConfig instance.- Returns:
- a new AuthConfig
- Throws:
IllegalArgumentException- if enabled but no role, certificate, or JAAS mapping is defined
-