[[authentication-client]] = - WildFly Elytron The __ element can be added to the wildfly-config.xml configuration to define configuration in relation to authentication configuration for outbound connections and SSL configuration for outbound connections e.g. [source, xml] ---- ... ---- _Note: A single wildfly-config.xml could be used by multiple projects using multiple versions of Wildfly Elytron, newer versions of WildFly Elytron will introduce new configuration using later namespace versions however they will still continue to support the previously released schemas until advertised otherwise. For the configuration to be compatible with this either use a schema and namespace compatible with all the versions in use, or multiple authentication-client elements can be added, these should be added ordered by namespace youngest to oldest. If a configuration with a later namespace is discovered by a newer WildFly Elytron client it will be used and parsing will not look for an older version as well._ The __ configuration can contain the following sections: - :: Definitions of credential stores to be referenced from elsewhere in the configuration. :: Definitions of KeyStores to be referenced elsewhere in the configuration. :: Rules to be applied for outbound connections to match against an appropriate authentication configuration. :: The individual authentication configurations that will be matched by the authentication rules. :: Flag to enable integration with the [java.net.Authenticator|https://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html]. :: Rules to be applied for outbound connections to match against an appropriate SSL context configuration. :: Individual SSL context definitions that will be matched by the ssl context rules. :: Definition of how [java.security.Provider|https://docs.oracle.com/javase/8/docs/api/java/security/Provider.html] instances will be discovered. == The element can be used to define individual named credential stores that can subsequently be used elsewhere in the configuration to reference stored credentials as an alternative to the credentials being embedded in the configuration. [source, xml] ---- ... ---- In addition to the name an individual definition can contain the following optional attributes: - type:: The type of the credential store, e.g.KeyStoreCredentialStore. provider:: The name of the [java.security.Provider|https://docs.oracle.com/javase/8/docs/api/java/security/Provider.html] to use to load the credential store. The following child elements can also be added to configure the credential store. :: Definition of configuration attributes used to initialise the credential store. e.g. [source, xml] ---- ---- The element can be repeated as many times as is required for the configuration. [[client-credentials-type]] :: One or more credentials to be assembled into a protection parameter when initialising the credential store. The element can contain one more more child elements, which of these are actually supported will depend on the credential store implementation: - [source, xml] ---- ... ... ... ---- The potential child elements of are: - :: Defines a reference to an entry within a KeyStore for an entry to use. The overall structure of this element is: - [source, xml] ---- ... ---- This structure is identical to the structure use in [|#key-store-credential]. :: Reference to a credential stored in a credential store. :: A password specified in the clear. :: A public and private key pair. * :: A pem encoded private key and corresponding certificate. ...:: A pem encoded public key. * :: A bearer token ...:: An oath2 bearer token. The full structure of this element is: - [source, xml] ---- ---- == The element can be used to define individual key-store definitions that can subsequently be referenced from alternative locations within the configuration. [source, xml] ---- ... ... ---- An individual definition must contain exactly one of the following elements to define where to load the store from. *:: Load from file where 'name' is the name of the file. :: Load the file from the URI specified. :: Load as a resource from the Thread context classloader where 'name' is the name of the resource to load. Exactly one of the following elements must also be present to specify the protection parameter for initialisation of the KeyStore. key-store-clear-password password="..." />:: A password specified in the clear. ...:: A reference to another KeyStore to obtain an Entry to use as the protection parameter to access this KeyStore. [[key-store-credential]] The structure of the element is. [source, xml] ---- ... ---- This element contains two attributes: - key-store-name:: _(Mandatory)_ - Name of the KeyStore being referenced to load the entry from. alias:: _(Optional)_ - The alias of the entry to load from the referenced KeyStore, this can only be omitted for KeyStores that contain only a single entry. Java KeyStores also make use of a protection parameter when accessing a single entry in addition to the protection parameter to load the KeyStore, exactly one of the following elements must be present to specify the protection parameter of the entry being loaded. :: A password specified in the clear. :: Reference to a credential stored in a credential store. ...:: A reference to another KeyStore to obtain an Entry to use as the protection parameter to access the alias. The is exactly the same, this means theoretically a chain of references could be used to lead to the unlocking of the required alias. [[Rules]] == and When either an authentication-configuration or an ssl-context is required the URI of the resources being accessed as well as an optional abstract type and abstract type authority and matched against the rules defined in the configuration to identify which authentication-configuration or ssl-context should be used. The rules to match instances are defined within the element. [source, xml] ---- ... ... ---- The rules to match against the definitions are contains within the element. [source, xml] ---- ... ... ---- Overall this means that authentication configuration matching is independent of SSLContext matching. By separating the rules from the configurations is means multiple rules can be defined that match against the same configuration. The rules applied so first match wins and not most specific match wins, to achieve a most specific match wins configuration place the most specific rules at the beginning leaving the more general matches towards the end. For both the and the the structure of the rules is identical other than one references an authentication configuration and the other references an SSLContext. [source, xml] ---- ---- Where multiple matches are defined within a rule they must all match for the rule to apply. If a rule is defined with no match elements then it becomes a match all rule and will match anything, these can be useful at the end of the configuration to ensure something matches. The individual match elements are: - :: user-info can be embedded within a URI, this rule matches when there is no user-info. - Matches when the user-info embedded in the URI matches the name specified within this element. - Matches the protocol within the URI against the name specified in this match element. - Matches the host name from within the URI against the name specified in this match element. - Matches the path from the URI against the name specified in this match element. - Matches the port number specified within the URI against the number in this match element. This only matches against the number specified within the URI and not against any default derrived from the protocol. " - Matches the scheme specific part of the URI against the name specified within this element. * :: Matches where the protocol of the URI is 'domain' and the scheme specific part of the URI is the name specified within this match element. :: Matches the abstract type and/or authority against the values specified within this match element. == The element contains named configurations that can then be matched from the [source, xml] ---- ... ... ---- The elements within the element provide the following features: - The first three elements override the destination. :: Override the host name for the authenticated call. :: Override the port number for the authenticated call. :: Override the protocol for the authenticated call. The next two are mutually exclusive and can be used to set the name for authentication or switch to anonymous authentication. :: Set the user name to use for authentication. :: Switch to anonymous authentication. :: Specify the name of the realm that will be selected by the SASL mechanism if required. :: A regular expression pattern and replacement to re-write the user name used for authentication. :: A SASL mechanism selector using the syntax from [org.wildfly.security.sasl.SaslMechanismSelector,fromString()|https://github.com/wildfly-security/wildfly-elytron/blob/1.1.4.Final/src/main/java/org/wildfly/security/sasl/SaslMechanismSelector.java#L544] ...:: One or more properties defined as to be passed to the authentication mechanisms. ...:: One or more credentials available for use during authentication. The content of this element is the same as documented for [|#client-credentials-type] [source, xml] ---- ... ... ... ---- :: Specify the name that should be used for authorization if different from the authentication identity. :: This element is described in more detail within [|#Providers] and overrides the default or inherited provider discovery with a definition specific to this authentication configuration definition. The final two elements are mutually exclusive and define how the SASL mechanism factories will be discovered for authentication. :: The [java.security.Provider|https://docs.oracle.com/javase/8/docs/api/java/security/Provider.html] instances either inherited or defined in this configuration will be used to locate the available SASL client factories. :: SASL client factories will be discovered using service loader discovery on the specified module or if not specified using the ClassLoader loading the configuration. == This element contains no specific configuration, however if present the [org.wildfly.security.auth.util.ElytronAuthenticator|http://wildfly-security.github.io/wildfly-elytron/1.1.x/org/wildfly/security/auth/util/ElytronAuthenticator.html] will be registered with [java.net.Authenticator.setDefault(Authenticator)|https://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html#setDefault-java.net.Authenticator-] meaning that the WildFly Elytron authentication client configuration can be used for authentication where the JDK APIs are used for HTTP calls which require authentication. There are some limitations within this integration as the JDK will cache the authentication JVM wide from the first call so is better used in stand alone processes that don't require different credentials for different calls to the same URI, [[SSLContexts]] == The element holds individual names SSLContext definitions that can subsequently be matched by the [|#Rules]. [source, xml] ---- ... ... ---- The element simply takes the SSLContext obtainable from [javax.net.ssl.SSLContext.getDefault()|https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html#getDefault--] and assigns it a name so it can referenced from the [|#Rules]. This element can be repeated meaning the default SSLContext can be referenced using different names. The element is used to define a named configured SSLContext, each of the child elements is optional and can be specified at most once to build up the configuration of the SSLContext. :: Defines a reference to an entry within a KeyStore for the key and certificate to use in this SSLContext. The overall structure of this element is: - [source, xml] ---- ... ---- This structure is identical to the structure use in [|#key-store-credential], the only difference being it is now to obtain the entry for the key and certificate, the nested elements however remain the protection parameter to unlock the entry. :: A reference to a KeyStore that will be used to initialise the TrustManager. :: Configuration to filter the enabled cipher suites, the format of the selector is [org.wildfly.security.ssl.CipherSuiteSelector.fromString(selector)|http://wildfly-security.github.io/wildfly-elytron/1.1.x/org/wildfly/security/ssl/CipherSuiteSelector.html#fromString-java.lang.String-]. The following would be a cipher suite selector performing the default filtering. [source, xml] ---- ---- :: used to define a space separated list of the protocols to be supported. :: Once the available providers have been identified only the provider with the name defined on this element will be used. :: This element is described in more detail within [|#Providers] and overrides the default or inherited provider discovery with a definition specific to this SSLContext definition. :: The presence of this element enabled checking the peer's certificate against a certificate revocation list, this element defines both a path to the certificate revocation list and also specifies the maximum number of non-self-issued intermediate certificates that may exist in a certification path [[Providers]] == The __ element is used to define how [java.security.Provider|https://docs.oracle.com/javase/8/docs/api/java/security/Provider.html] instances are located when required. The other configuration sections of __ are independent of each other, the __ configuration however applies to the current element and it's children unless overridden, this configuration can be specified in the following locations. [source, xml] ---- ... ... ... ... ... ... ---- If an individual , , or contains a definition that that definition will apply specifically to that instance. If a configured item does not contain a definition but a top level is defined within then that will be used instead. The element can be defined as: - [source, xml] ---- ---- Both the child elements are optional, can appear in any order and can be repeated although repeating would not really be beneficial. :: The providers from [java.security.Security.getProviders()|https://docs.oracle.com/javase/8/docs/api/java/security/Security.html#getProviders--] :: Providers loaded using service loader discovery from the module specified, if no module is specified the ClassLoader which loaded the authentication client is used. Where no configuration exists the default behaviour is the equivalent of: - [source, xml] ---- ---- This gives the WildFly Elytron Provider priority over any globally registered Providers but also allows for the globally registered providers to be used.