Blame README

Packit 728676
mod_auth_gssapi
Packit 728676
===============
Packit 728676
Packit 728676
Intro
Packit 728676
-----
Packit 728676
Packit 728676
This module has been built as a replacement for the aging mod_auth_kerb.
Packit 728676
Its aim is to use only GSSAPI calls and be as much as possible agnostic
Packit 728676
of the actual mechanism used.
Packit 728676
Packit 728676
Dependencies
Packit 728676
------------
Packit 728676
Packit 728676
A modern version of MIT's Krb5 distribution or any GSSAPI implementation
Packit 728676
that supports the [credential store
Packit 728676
extension](http://k5wiki.kerberos.org/wiki/Projects/Credential_Store_extensions)
Packit 728676
is necessary to achieve full functionality. Reduced functionality is
Packit 728676
provided without these extensions.
Packit 728676
Packit 728676
    MIT krb5 (>=1.11)
Packit 728676
    Apache httpd (>=2.4.11)
Packit 728676
Packit 728676
### Tests
Packit 728676
Packit 728676
To run tests, you also need:
Packit 728676
Packit 728676
* The Kerberos 5 Key-Distribution-Center (`krb5-kdc` package on Debian,
Packit 728676
  `krb5-server` on Fedora)
Packit 728676
* Packages `mod_session`, `krb5-workstation`, `python-requests-kerberos`,
Packit 728676
  and `python-gssapi` on Fedora
Packit 728676
* Some tests require `krb5-pkinit` package on fedora and krb5 >= 1.15.
Packit 728676
* [nss_wrapper](https://cwrap.org/nss_wrapper.html), packaged in Fedora
Packit 728676
* [socket_wrapper](https://cwrap.org/socket_wrapper.html), packaged in Fedora
Packit 728676
Packit 728676
Installation
Packit 728676
------------
Packit 728676
Packit 728676
    autoreconf -fi
Packit 728676
    ./configure
Packit 728676
    make
Packit 728676
    make install
Packit 728676
Packit 728676
Packit 728676
Configuration
Packit 728676
-------------
Packit 728676
Packit 728676
Apache authentication modules are usually configured per location, see the
Packit 728676
[mod_authn_core](https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html)
Packit 728676
documentation for the common directives
Packit 728676
Packit 728676
### Basic configuration
Packit 728676
Packit 728676
The simplest configuration scheme specifies just one directive, which is the
Packit 728676
location of the keytab.
Packit 728676
Packit 728676
#### Example
Packit 728676
    <Location /private>
Packit 728676
        AuthType GSSAPI
Packit 728676
        AuthName "GSSAPI Single Sign On Login"
Packit 728676
        GssapiCredStore keytab:/etc/httpd.keytab
Packit 728676
        Require valid-user
Packit 728676
    </Location>
Packit 728676
Packit 728676
Your Apache server need read access to the keytab configured.
Packit 728676
If your Kerberos implementation does not support the credential store
Packit 728676
extensions you can also simply set the KRB5_KTNAME environment variable in the
Packit 728676
Apache init script and skip the GssapiCredStore option completely.
Packit 728676
Packit 728676
Packit 728676
Environment Variables
Packit 728676
---------------------
Packit 728676
Packit 728676
(Note: these are not process environment variables, but rather Apache
Packit 728676
environment variables, as described
Packit 728676
[in the apache docs](https://httpd.apache.org/docs/2.4/env.html).)
Packit 728676
Packit 728676
### gssapi-no-negotiate
Packit 728676
Packit 728676
This environment variable is used to suppress setting Negotiate headers.  Not
Packit 728676
sending these headers is useful to work around browsers that do not handle
Packit 728676
them properly (and incorrectly show authentication popups to users).
Packit 728676
Packit 728676
#### Example
Packit 728676
Packit 728676
For instance, to suppress negotiation on Windows browsers, one could set:
Packit 728676
Packit 728676
    BrowserMatch Windows gssapi-no-negotiate
Packit 728676
Packit 728676
Packit 728676
Packit 728676
Configuration Directives
Packit 728676
------------------------
Packit 728676
Packit 728676
### Alphabetic List of Directives
Packit 728676
Packit 728676
[GssapiAcceptorName](#gssapiacceptorname)
Packit 728676
[GssapiAllowedMech](#gssapiallowedmech)
Packit 728676
[GssapiBasicAuth](#gssapibasicauth)
Packit 728676
[GssapiBasicAuthMech](#gssapibasicauthmech)
Packit 728676
[GssapiConnectionBound](#gssapiconnectionbound)
Packit 728676
[GssapiCredStore](#gssapicredstore)
Packit 728676
[GssapiDelegCcacheDir](#gssapidelegccachedir)
Packit 728676
[GssapiDelegCcacheEnvVar](#gssapidelegccacheenvvar)
Packit 728676
[GssapiDelegCcachePerms](#gssapidelegccacheperms)
Packit 728676
[GssapiDelegCcacheUnique](#gssapidelegccacheunique)
Packit 728676
[GssapiImpersonate](#gssapiimpersonate)
Packit 728676
[GssapiLocalName](#gssapilocalname)
Packit 728676
[GssapiNameAttributes](#gssapinameattributes)
Packit 728676
[GssapiNegotiateOnce](#gssapinegotiateonce)
Packit 728676
[GssapiPublishErrors](#gssapipublisherrors)
Packit 728676
[GssapiRequiredNameAttributes](#gssapirequirednameattributes)
Packit 728676
[GssapiSessionKey](#gssapisessionkey)
Packit 728676
[GssapiSignalPersistentAuth](#gssapisignalpersistentauth)
Packit 728676
[GssapiSSLonly](#gssapisslonly)
Packit 728676
[GssapiUseS4U2Proxy](#gssapiuses4u2proxy)
Packit 728676
[GssapiUseSessions](#gssapiusesessions)
Packit 728676
Packit 728676
Packit 728676
### GssapiSSLonly
Packit 728676
Packit 728676
Forces the authentication attempt to fail if the connection is not being
Packit 728676
established over TLS
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiSSLonly On
Packit 728676
Packit 728676
Packit 728676
### GssapiLocalName
Packit 728676
Packit 728676
Tries to map the client principal to a local name using the gss_localname()
Packit 728676
call. This requires configuration in the /etc/krb5.conf file in order to allow
Packit 728676
proper mapping for principals not in the default realm (for example a user
Packit 728676
coming from a trusted realm).
Packit 728676
See the 'auth_to_local' option in the [realms] section of krb5.conf(5)
Packit 728676
Packit 728676
When this options is used the resolved name is set in the REMOTE_USER variable
Packit 728676
however the complete client principal name is also made available in the
Packit 728676
GSS_NAME variable.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiLocalName on
Packit 728676
Packit 728676
Packit 728676
### GssapiConnectionBound
Packit 728676
Packit 728676
When using GSS mechanisms that require more than one round-trip to complete
Packit 728676
authentication (like NTLMSSP) it is necessary to bind to the authentication to
Packit 728676
the connection in order to keep the state between round-trips. With this option
Packit 728676
enable incomplete context are store in the connection and retrieved on the next
Packit 728676
request for continuation.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiConnectionBound On
Packit 728676
Packit 728676
Packit 728676
### GssapiSignalPersistentAuth
Packit 728676
Packit 728676
For clients that make use of Persistent-Auth header, send the header according
Packit 728676
to GssapiConnectionBound setting.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiSignalPersistentAuth On
Packit 728676
Packit 728676
Packit 728676
### GssapiUseSessions
Packit 728676
Packit 728676
In order to avoid constant and costly re-authentication attempts for every
Packit 728676
request, mod_auth_gssapi offers a cookie based session method to maintain
Packit 728676
authentication across multiple requests. GSSAPI uses the mod_sessions module
Packit 728676
to handle cookies so that module needs to be activated and configured.
Packit 728676
GSSAPI uses a secured (encrypted + MAC-ed) payload to maintain state in the
Packit 728676
session cookie. The session cookie lifetime depends on the lifetime of the
Packit 728676
GSSAPI session established at authentication.
Packit 728676
**NOTE**: It is important to correctly set the SessionCookieName option.
Packit 728676
See the
Packit 728676
[mod_sessions](http://httpd.apache.org/docs/current/mod/mod_session.html)
Packit 728676
documentation for more information.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiUseSessions On
Packit 728676
    Session On
Packit 728676
    SessionCookieName gssapi_session path=/private;httponly;secure;
Packit 728676
Packit 728676
Packit 728676
### GssapiSessionKey
Packit 728676
Packit 728676
When GssapiUseSessions is enabled a key use to encrypt and MAC the session
Packit 728676
data will be automatically generated at startup, this means session data will
Packit 728676
become unreadable if the server is restarted or multiple servers are used and
Packit 728676
the client is load balanced from one to another. To obviate this problem the
Packit 728676
admin can choose to install a permanent key in the configuration so that
Packit 728676
session data remain accessible after a restart or by multiple servers
Packit 728676
sharing the same key.
Packit 728676
Packit 728676
Two schemes to read persistent keys are provided, 'key' and 'file'.
Packit 728676
Packit 728676
- 'key'
Packit 728676
    A key is read from the configuration directive.
Packit 728676
    The key must be a base64 encoded raw key of 32 bytes of length.
Packit 728676
Packit 728676
- 'file'
Packit 728676
    A file on the file system is used to store the key. If the file does not
Packit 728676
    exists one is created with a randomly generated key during the first
Packit 728676
    execution.
Packit 728676
Packit 728676
Packit 728676
#### Examples
Packit 728676
    GssapiSessionKey key:VGhpcyBpcyBhIDMyIGJ5dGUgbG9uZyBzZWNyZXQhISE=
Packit 728676
    GssapiSessionKey file:/var/lib/httpd/secrets/session.key
Packit 728676
Packit 728676
Packit 728676
### GssapiCredStore
Packit 728676
Packit 728676
The GssapiCredStore option allows to specify multiple credential related
Packit 728676
options like keytab location, client_keytab location, ccache location etc.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiCredStore keytab:/etc/httpd.keytab
Packit 728676
    GssapiCredStore ccache:FILE:/var/run/httpd/krb5ccache
Packit 728676
Packit 728676
Packit 728676
### GssapiDelegCcacheDir
Packit 728676
Packit 728676
If delegation of credentials is desired credentials can be exported in a
Packit 728676
private directory accessible by the Apache process.
Packit 728676
The delegated credentials will be stored in a file named after the client
Packit 728676
principal and a request environment variable (`KRB5CCNAME` by default) will be
Packit 728676
set to point to that file.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiDelegCcacheDir /var/run/httpd/clientcaches
Packit 728676
Packit 728676
A user foo@EXAMPLE.COM delegating its credentials would cause the server to
Packit 728676
create a ccache file named /var/run/httpd/clientcaches/foo@EXAMPLE.COM
Packit 728676
Packit 728676
Packit 728676
### GssapiDelegCcacheUnique
Packit 728676
Packit 728676
Enables using unique ccache names for delegation.  ccache files will be placed
Packit 728676
in GssapiDelegCcacheDir and named using the principal and a six-digit unique
Packit 728676
suffix.
Packit 728676
Packit 728676
**Note:** Consuming application must delete the ccache otherwise it will
Packit 728676
litter the filesystem if sessions are used.  An example sweeper can be found
Packit 728676
in the contrib directory.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiDelegCcacheUnique On
Packit 728676
Packit 728676
Packit 728676
### GssapiDelegCcacheEnvVar
Packit 728676
Packit 728676
Set the name of the request environment variable that will receive the
Packit 728676
credential cache name.  If unspecified, defaults to `KRB5CCNAME`.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiDelegCcacheEnvVar AJP_KRB5CCNAME
Packit 728676
Packit 728676
Packit 728676
### GssapiUseS4U2Proxy
Packit 728676
Packit 728676
Enables the use of the s4u2Proxy Kerberos extension also known as
Packit 728676
[constrained delegation](https://ssimo.org/blog/id_011.html)
Packit 728676
This option allows an application running within Apache to operate on
Packit 728676
behalf of the user against other servers by using the provided ticket
Packit 728676
(subject to KDC authorization).
Packit 728676
This options requires GssapiDelegCcacheDir to be set. The ccache will be
Packit 728676
populated with the user's provided ticket which is later used as evidence
Packit 728676
ticket by the application.
Packit 728676
Packit 728676
**Note:** This flag has no effect when Basic-Auth is used since user's
Packit 728676
credentials are delegated anyway when GssapiDelegCcacheDir is set.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiUseS4U2Proxy On
Packit 728676
    GssapiCredStore keytab:/etc/httpd.keytab
Packit 728676
    GssapiCredStore client_keytab:/etc/httpd.keytab
Packit 728676
    GssapiCredStore ccache:FILE:/var/run/httpd/krb5ccache
Packit 728676
    GssapiDelegCcacheDir /var/run/httpd/clientcaches
Packit 728676
Packit 728676
**NOTE:** The client keytab is necessary to allow GSSAPI to initiate via keytab
Packit 728676
on its own. If not present an external mechanism needs to kinit with the
Packit 728676
keytab and store a ccache in the configured ccache file.
Packit 728676
Packit 728676
Packit 728676
### GssapiBasicAuth
Packit 728676
Packit 728676
Allows the use of Basic Auth in conjunction with Negotiate.
Packit 728676
If the browser fails to use Negotiate it will instead fallback to Basic and
Packit 728676
the username and password will be used to try to acquire credentials in the
Packit 728676
module via GSSAPI. If credentials are acquired successfully then they are
Packit 728676
validated against the server's keytab.
Packit 728676
Packit 728676
- **Enable with:** GssapiBasicAuth On
Packit 728676
- **Default:** GssapiBasicAuth Off
Packit 728676
Packit 728676
#### Example
Packit 728676
    <Location /gssapi>
Packit 728676
      AuthType GSSAPI
Packit 728676
      AuthName "Login"
Packit 728676
      GssapiBasicAuth On
Packit 728676
      GssapiCredStore keytab:/etc/httpd/http.keytab
Packit 728676
      Require valid-user
Packit 728676
    </Location>
Packit 728676
Packit 728676
Packit 728676
### GssapiAllowedMech
Packit 728676
Packit 728676
List of allowed mechanisms. This is useful to restrict the mechanism that
Packit 728676
can be used when credentials for multiple mechanisms are available.
Packit 728676
By default no mechanism is set, this means all locally available mechanisms
Packit 728676
are allowed.  The recognized mechanism names are: krb5, iakerb, ntlmssp
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiAllowedMech krb5
Packit 728676
    GssapiAllowedMech ntlmssp
Packit 728676
Packit 728676
Packit 728676
### GssapiBasicAuthMech
Packit 728676
Packit 728676
List of mechanisms against which Basic Auth is attempted. This is useful to
Packit 728676
restrict the mechanisms that can be used to attempt password auth.
Packit 728676
By default no mechanism is set, this means all locally available mechanisms
Packit 728676
are allowed, unless GssapiAllowedMech is set, in which case those are used.
Packit 728676
GssapiBasicAuthMech always takes precedence over GssapiAllowedMech.
Packit 728676
The recognized mechanism names are: krb5, iakerb, ntlmssp
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiBasicAuthMech krb5
Packit 728676
Packit 728676
Packit 728676
### GssapiNameAttributes
Packit 728676
Packit 728676
Enables the module to source Name Attributes from the client name
Packit 728676
(authorization data associated with the established context) and exposes them
Packit 728676
as environment variables.
Packit 728676
Packit 728676
Value format: ENV_VAR_NAME ATTRIBUTE_NAME
Packit 728676
Packit 728676
This option can be specified multiple times, once for each attribute to expose.
Packit 728676
The Special value "json" is used to expose all attributes in a json formatted
Packit 728676
string via the special environment variable GSS_NAME_ATTRS_JSON
Packit 728676
The environment variable GSS_NAME_ATTR_ERROR is set with the Gssapi returned
Packit 728676
error string in case the inquire name function fails to retrieve attributes,
Packit 728676
and with the string "0 attributes found", if no attributes are set.
Packit 728676
Packit 728676
**Note**: These variables are NOT saved in the session data stored in the
Packit 728676
cookie so they are available only on the first authenticated request when
Packit 728676
GssapiUseSessions is used.
Packit 728676
Packit 728676
**Note:** It is recommended but not required to use only capital letters and
Packit 728676
underscores for environment variable names.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiNameAttributes json
Packit 728676
    GssapiNameAttributes RADIUS_NAME urn:ietf:params:gss:radius-attribute_1
Packit 728676
Packit 728676
Packit 728676
### GssapiRequiredNameAttributes
Packit 728676
Packit 728676
This option allows specifying one or more Name Attributes that the client must
Packit 728676
possess in order to be authorized to access the location. The required Name
Packit 728676
Attributes are specified by name=value pairs (name being the ATTRIBUTE_NAME as
Packit 728676
mentioned above, and value being a Null-terminated string. Alternately, if a
Packit 728676
Name Attribute produces binary values or is expected to contain a space
Packit 728676
character, the desired value can be specified by a ':=' and a base64-encoded
Packit 728676
string).
Packit 728676
Packit 728676
A combination of Name Attributes (including multiple values from a single Name
Packit 728676
Attribute type) can be specified with an expression that separates each
Packit 728676
name=value pair with the "and" or "or" logical operators.  Operator precedence
Packit 728676
can be influenced by parenthesized statements.
Packit 728676
Packit 728676
	foo=bar
Packit 728676
	foo:=YmFy
Packit 728676
	foo=bar or foo=baz
Packit 728676
	foo=bar and foo=baz and bar=baz
Packit 728676
	(foo=bar and foo=baz) or bar:=YmFy
Packit 728676
Packit 728676
If the Name Attributes associated with the client do not satisfy the given
Packit 728676
expression, or no Name Attributes are present, a 403 response is returned.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiRequiredNameAttributes "auth-indicators=high"
Packit 728676
    GssapiRequiredNameAttributes "auth-indicators=high or other-attr=foo"
Packit 728676
    GssapiRequiredNameAttributes "((auth-indicators=low and auth-indicators=med) or auth-indicators=high)"
Packit 728676
Packit 728676
Packit 728676
### GssapiNegotiateOnce
Packit 728676
Packit 728676
When this option is enabled the Negotiate header will not be resent if
Packit 728676
Negotiation has already been attempted but failed.
Packit 728676
Packit 728676
Normally when a client fails to use Negotiate authentication, a HTTP 401
Packit 728676
response is returned with a WWW-Authenticate: Negotiate header, implying that
Packit 728676
the client can retry to use Negotiate with different credentials or a
Packit 728676
different mechanism.
Packit 728676
Packit 728676
Consider enabling GssapiNegotiateOnce when only one single sign on mechanism
Packit 728676
is allowed, or when GssapiBasicAuth is enabled.
Packit 728676
Packit 728676
**NOTE:** if the initial Negotiate attempt fails, some browsers will fallback
Packit 728676
to other Negotiate mechanisms, prompting the user for login credentials and
Packit 728676
reattempting negotiation. This situation can mislead users - for example if
Packit 728676
krb5 authentication failed and no other mechanisms are allowed, a user could
Packit 728676
be prompted for login information even though any login information provided
Packit 728676
cannot succeed. When this occurs, some browsers will not fall back to a Basic
Packit 728676
Auth mechanism. Enable GssapiNegotiateOnce to avoid this situation.
Packit 728676
Packit 728676
- **Enable with:** GssapiNegotiateOnce On
Packit 728676
- **Default:** GssapiNegotiateOnce Off
Packit 728676
Packit 728676
Packit 728676
### GssapiImpersonate
Packit 728676
Packit 728676
This option can be used even if AuthType GSSAPI is not used for given
Packit 728676
Location or LocationMatch, to obtain service ticket for a user that was
Packit 728676
already authenticated by different module.
Packit 728676
Packit 728676
The principal of the user is retrieved from the internal r->user
Packit 728676
identifier which typically holds the username from the authentication
Packit 728676
results.
Packit 728676
Packit 728676
Make sure the server principal is set to allow to acquire forwardable
Packit 728676
tickets to itself from arbitrary users, for use with constrained
Packit 728676
delegation, for example with the option +ok_to_auth_as_delegate.
Packit 728676
Packit 728676
- **Enable with:** GssapiImpersonate On
Packit 728676
- **Default:** GssapiImpersonate Off
Packit 728676
Packit 728676
Packit 728676
### GssapiDelegCcachePerms
Packit 728676
Packit 728676
This option is used to set alternative ownership and permission for delegated
Packit 728676
ccache files stored in the GssapiDelegCcacheDir location. It is a multivalue
Packit 728676
configuration directive that can accept the following three settings:
Packit 728676
- mode
Packit 728676
- uid
Packit 728676
- gid
Packit 728676
If a setting is not present the relative file property will not be modified and
Packit 728676
the default owners and/or mode will be retained.
Packit 728676
Packit 728676
#### mode
Packit 728676
    This option allows to set the file mode, the format used is a numeric mode
Packit 728676
    with the same semantics of the chmod unix command for mapping numbers to
Packit 728676
    permissions.
Packit 728676
Packit 728676
#### uid
Packit 728676
    A user id number or name, an attempt to change the user owner of the file
Packit 728676
    to the uid number specified will be made. If a user name has been
Packit 728676
    specified, it will be resolved at startup time and the user's id number
Packit 728676
    stored internally for all subsequent operations.
Packit 728676
Packit 728676
#### gid
Packit 728676
    A group id number or name, an attempt to change the group owner of the
Packit 728676
    file to the gid number specified will be made. If a group name has been
Packit 728676
    specified, it will be resolved at startup time and the group's id number
Packit 728676
    stored internally for all subsequent operations.
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiDelegCcachePerms mode:0660 gid:webuiworkers
Packit 728676
Packit 728676
Packit 728676
### GssapiPublishErrors
Packit 728676
Packit 728676
This option is used to publish errors as Environment Variables for use by
Packit 728676
httpd processes.
Packit 728676
Packit 728676
A general error type is provided in the MAG_ERROR variable, and can have the
Packit 728676
following values: "GSS ERROR", "INTERNAL ERROR", "AUTH NOT ALLOWED"
Packit 728676
Additionally, in the variable named MAG_ERROR_TEXT there may be a free form
Packit 728676
error message.
Packit 728676
Packit 728676
When the error type is "GSS ERROR" the variables GSS_ERROR_MAJ and
Packit 728676
GSS_ERROR_MIN contain the numeric errors returned by GSSAPI, and the
Packit 728676
MAG_ERROR_TEXT will contain a GSS Error message, possibly prepended by
Packit 728676
an additional message that provides more context.
Packit 728676
Packit 728676
- **Enable with:** GssapiPublishErrors On
Packit 728676
- **Default:** GssapiPublishErrors Off
Packit 728676
Packit 728676
Packit 728676
### GssapiAcceptorName
Packit 728676
Packit 728676
This option is used to force the server to accept only for a specific name.
Packit 728676
Packit 728676
This allows, for example to select to use a specific credential when multiple
Packit 728676
keys are provided in a keytab.
Packit 728676
Packit 728676
A special value of {HOSTNAME} will make the code use the name apache sees in
Packit 728676
the httpd request to select the correct name to use. This may be useful to
Packit 728676
allow multiple names and multiple keys to be used on the same apache instance.
Packit 728676
Packit 728676
Note: By default no name is set and any name in a keytab or mechanism specific
Packit 728676
acceptor credential will be allowed.
Packit 728676
Packit 728676
Note: Global gssapi options set in krb5.conf like 'ignore_acceptor_hostname'
Packit 728676
may affect the ability to restrict names.
Packit 728676
Packit 728676
Note: The GSS_C_NT_HOSTBASED_SERVICE format is used for names (see example).
Packit 728676
Packit 728676
#### Example
Packit 728676
    GssapiAcceptorName HTTP@www.example.com
Packit 728676
Packit 728676