mod_auth_gssapi.git
3 years agoInclude RPM spec file in dist package. master v1.3.2-moonshot
Jennifer Richards [Fri, 3 Jun 2016 16:24:43 +0000 (16:24 +0000)]
Include RPM spec file in dist package.

3 years agoRelease 1.3.2 - NEAR Shoemaker launch v1.3.2
Simo Sorce [Thu, 18 Feb 2016 01:56:44 +0000 (20:56 -0500)]
Release 1.3.2 - NEAR Shoemaker launch

On February 17th, 1996 the NEAR Shoemaker probe is launched.
The first probe to soft-land on a Near Earth Asteroid (Eros).

Signed-off-by: Simo Sorce <simo@redhat.com>
3 years agoCleanup s4u2proxy in mag_auth_basic
Isaac Boukris [Tue, 16 Feb 2016 23:21:25 +0000 (01:21 +0200)]
Cleanup s4u2proxy in mag_auth_basic

It doesn't have any effect since we set GSS_C_DELEG_FLAG
when we initiate client credentials so we always get
delegated TGT regardless of constrained delegation.

This commit is not intended to change the current behaviour.

See #70

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #70
Closes #72

3 years agoAdd option to not send a Negotiate headers
James Groffen [Fri, 8 Jan 2016 06:31:50 +0000 (17:01 +1030)]
Add option to not send a Negotiate headers

If negotiation was attempted but failed do not send a new Negotiate header.
Useful when only one single sign on mechanism is allowed and to avoid
misleading login prompts in some browsers.

Added a test of the GssapiDontReauth option to the test suite.
Also added SPNEGO no auth test.

[SS: reworded and fixed commit subject/comment]
[SS: fixed whitespace errors and 80 column wrappings]

Reviewed-by: Simo Sorce <simo@redhat.com>
Close #65

3 years agoCorrected two typos in the README file.
James Groffen [Tue, 16 Feb 2016 23:24:42 +0000 (09:54 +1030)]
Corrected two typos in the README file.

Reviewed-by: Simo Sorce <simo@redhat.com>
Close #71

3 years agoMinor formatting changes to the README.
James Groffen [Fri, 15 Jan 2016 01:15:24 +0000 (11:45 +1030)]
Minor formatting changes to the README.

[Changes to original commit: removed trailing whitespace]

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #67

3 years agoFix potential loop when requesting attribute data.
Simo Sorce [Thu, 14 Jan 2016 15:24:17 +0000 (10:24 -0500)]
Fix potential loop when requesting attribute data.

If this function fail we are better off abandoning the whole quest, continueing
here may end us up in an infinite loop where the fucntion keeps failing w/o
changing attr.more

Thanks to Alejandro Perez for finding this flaw.

Signed-off-by: Simo Sorce <simo@redhat.com>
3 years agoFix build when cred store is not available.
Simo Sorce [Wed, 13 Jan 2016 14:40:21 +0000 (09:40 -0500)]
Fix build when cred store is not available.

Older distributions have versions of Kerberos that miss this feature.

Signed-off-by: Simo Sorce <simo@redhat.com>
3 years agoPrevent potential null pointer dereference
James Groffen [Fri, 8 Jan 2016 04:13:14 +0000 (14:43 +1030)]
Prevent potential null pointer dereference

This commit adds checks to ensure cfg->name_attributes is not null before
it is used in mag_get_name_attributes.

(Reworded commit message)

Reviewed-by: Simo Sorce <simo@redhat.com>
Close #64

3 years agoAdd code to set attribute names in the environment
Simo Sorce [Mon, 30 Nov 2015 22:53:42 +0000 (17:53 -0500)]
Add code to set attribute names in the environment

This code allows to specify which attributes in a name are interesting
to the application and set them as named environemnt variables.
Optionally the whole set of attributes can be exported in a json
formatted structure.

Signed-off-by: Simo Sorce <simo@redhat.com>
Close #62
Close #63

3 years agoMove setting request data to a separate file
Simo Sorce [Fri, 27 Nov 2015 22:28:23 +0000 (17:28 -0500)]
Move setting request data to a separate file

In preparation for the next commit.

Signed-off-by: Simo Sorce <simo@redhat.com>
3 years agoNegate established flag if session is expired.
davisd123 [Thu, 1 Oct 2015 04:50:06 +0000 (14:20 +0930)]
Negate established flag if session is expired.

If the session is expired, then set established to false to
force re-authentication.

Reviewed-by: Simo Sorce <simo@redhat.com>
Close #57

4 years agoRelease 1.3.1 - Viking 2 landing v1.3.1
Simo Sorce [Thu, 3 Sep 2015 17:22:17 +0000 (13:22 -0400)]
Release 1.3.1 - Viking 2 landing

On September 3rd, 1976 the Viking 2 lander separates from the orbiter and
lands at Utopia Planitia on Mars...

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoMention test dependencies in README
Dennis Schridde [Thu, 3 Sep 2015 15:59:38 +0000 (17:59 +0200)]
Mention test dependencies in README

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #56

4 years agoFix include path to asn1c for out-of-source builds
Dennis Schridde [Thu, 3 Sep 2015 15:38:24 +0000 (17:38 +0200)]
Fix include path to asn1c for out-of-source builds

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #55

4 years agoFix bug in handling Session Keys
Simo Sorce [Thu, 3 Sep 2015 16:58:51 +0000 (12:58 -0400)]
Fix bug in handling Session Keys

A check inversion in 86661d07812b010b8cf664c2dab596be15ff1e31 caused
the specified session key to be ignored and a crash when none was
specified.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAllow building without NTLMSSP support
Simo Sorce [Thu, 3 Sep 2015 14:19:07 +0000 (10:19 -0400)]
Allow building without NTLMSSP support

If gssapi/gssapi_ntlmssp.h is not available simply disable NTLMSSP.

Coauthored

Signed-off-by: Dennis Schridde <dennis.schridde@uni-heidelberg.de>
Signed-off-by: Simo Sorce <simo@redhat.com>
Closes #52
Closes #53
Closes #54

4 years agoUpdate and rename README to README.md
James Groffen [Wed, 19 Aug 2015 01:59:29 +0000 (11:29 +0930)]
Update and rename README to README.md

Add symlink to .md so the markdown is picked up.
Updated styling and fixed a couple of typos.

Simo: Changed rename into a symlink. Reworded commit message
Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #51

4 years agoAdd test for Proxy SPNEGO auth
Isaac Boukris [Sun, 9 Aug 2015 15:14:57 +0000 (18:14 +0300)]
Add test for Proxy SPNEGO auth

Add appropairate authorization headers to test with SPNEGO too as
discussed in #48

Requires recent version of python-gssapi module, see:
https://github.com/pythongssapi/python-gssapi/pull/74

Simo: Squashed original patches in one, removed trailing whitespaces
and reworded the commit message.

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #49

4 years agoDo not use /tmp as default for s4u2proxy
Simo Sorce [Mon, 31 Aug 2015 12:41:24 +0000 (08:41 -0400)]
Do not use /tmp as default for s4u2proxy

The /tmp directory can lead to bugs and DoS of the apache process
because any user on the system can block the creation of predictable
file names.

Simply error out if GssapiDelegCcacheDir is not explicitly set.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAllocate new keys at server startup.
Simo Sorce [Sun, 30 Aug 2015 18:31:44 +0000 (14:31 -0400)]
Allocate new keys at server startup.

This avoids a potential race condition if the first 2 request come in at the
same time. It also avoids issues with forked apapche processes which may end
up with different keys per fork.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFix incorrect free() usage
Simo Sorce [Sun, 30 Aug 2015 18:28:32 +0000 (14:28 -0400)]
Fix incorrect free() usage

This code has been changed to use apr pools for memory allocation, so the
error path is wrong as free() is not called on malloc()ed memory anymore.
Remove the calls to free(), the mempool is clean up by callers.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoMore basic-auth tests
Isaac Boukris [Sun, 2 Aug 2015 03:02:19 +0000 (06:02 +0300)]
More basic-auth tests

Add test for second user on the same connection with the password
of the first user and without auth at all.

Reviewed-by: Simo Sorce <simo@redhat.com>
Closes #48

4 years agoAdd test for Basic Proxy authentication
Isaac Boukris [Mon, 27 Jul 2015 02:49:44 +0000 (05:49 +0300)]
Add test for Basic Proxy authentication

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoSupport forward proxy authentication
Isaac Boukris [Mon, 27 Jul 2015 01:32:49 +0000 (04:32 +0300)]
Support forward proxy authentication

Proxy auth headers are a little different.

Sessions cannot be used as we cannot set a cookie.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoAdd test for basic auth with two different users over the same connection
Isaac Boukris [Sun, 26 Jul 2015 22:26:41 +0000 (01:26 +0300)]
Add test for basic auth with two different users over the same connection

Make sure each request is authenticated according to given credentials
even when GssapiConnectionBound is set.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoAvoid advertising NTLM if it isn't technically supported
Isaac Boukris [Sun, 26 Jul 2015 21:24:42 +0000 (00:24 +0300)]
Avoid advertising NTLM if it isn't technically supported

This lets browsers to fall back to basic auth if supported
(similar to 4e7967e797e5c8912a67c0de8f172bb95b5172ff).

Add boolean param to is_mech_allowed which denotes whether
the caller supports multiple step.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoFix checks on allowed mechs
Simo Sorce [Tue, 7 Jul 2015 17:23:57 +0000 (13:23 -0400)]
Fix checks on allowed mechs

We need to check if a mech is allowed against the desired_mechs set.
Otherwise in case the admin does not explicitly specify an allowed set
then all mechs are allowed, including NTLM. This causes annoying issues
with browsers like Firefox and Chrome/ium which end up popping up an
authentication dialog if they see NTLM is supported and they have no
Kerberos tickets around.
Authentication will then simply fail because NTLM is not actually supported.
By using desired_mechs we use a list of mechanism the machine actually
has a chance to support in the default case.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAdd basic auth test
Simo Sorce [Sat, 4 Jul 2015 15:11:16 +0000 (11:11 -0400)]
Add basic auth test

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAdd test target in Makefile
Simo Sorce [Sat, 4 Jul 2015 15:10:34 +0000 (11:10 -0400)]
Add test target in Makefile

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoUS Independence day release - 1.3.0 v1.3.0
Simo Sorce [Sat, 4 Jul 2015 14:41:54 +0000 (10:41 -0400)]
US Independence day release - 1.3.0

Let's celebrate with a new releae which is long overdue.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoRetrieve default mechs at server init
Isaac Boukris [Tue, 23 Jun 2015 01:13:20 +0000 (04:13 +0300)]
Retrieve default mechs at server init

This avoids the need to retrieve the list on every auth attempt,
and then free it every time.

Implemented by adding a server config struct and populating
it at server init with gss_indicate_mechs().

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoProperly check return error when filtering mechs
Simo Sorce [Wed, 24 Jun 2015 20:10:58 +0000 (16:10 -0400)]
Properly check return error when filtering mechs

We need to fail only if the input was an actual set and instead we
get back GSS_C_NO_OID_SET. In all other cases we are fine.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFail server startup on bad mechanisms
Isaac Boukris [Wed, 24 Jun 2015 00:42:06 +0000 (03:42 +0300)]
Fail server startup on bad mechanisms

This helps to detect mis-configurations early.
Configuration errors are considered fatal in apache anyway.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoSkip spnego filtering since we already filter it
Isaac Boukris [Tue, 23 Jun 2015 00:17:53 +0000 (03:17 +0300)]
Skip spnego filtering since we already filter it

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoAcquire server creds with given cred_usage rather than both
Isaac Boukris [Tue, 23 Jun 2015 00:15:31 +0000 (03:15 +0300)]
Acquire server creds with given cred_usage rather than both

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoAdd initial test framework
Simo Sorce [Tue, 23 Jun 2015 00:57:26 +0000 (20:57 -0400)]
Add initial test framework

Requires various python packages nd the cwrap project's scoket_wrapper
and nss_wrapper tools, as well as the krb5kdc and the httpd server and
related modules (like mod_session).

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoSupport allowing arbitrary mechanisms
Simo Sorce [Mon, 22 Jun 2015 14:20:48 +0000 (10:20 -0400)]
Support allowing arbitrary mechanisms

Use gss_str_to_oid so OIDs can be used to set arbitrary mechanism in
allow lists like GssapiAllowedMech or GssapiBasicAuthMech.

Closes #46

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAcquire creds only once for basic_auth
Simo Sorce [Sun, 21 Jun 2015 19:07:24 +0000 (15:07 -0400)]
Acquire creds only once for basic_auth

Instead of acquiring creds by looping at each round, use
gss_inquire_cred_by_mech() to work around the union_name issue and
get the correct per-mechanism server name.

Closes #45

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoSet krb5 ccache only if krb5 is used
Simo Sorce [Sun, 21 Jun 2015 19:06:15 +0000 (15:06 -0400)]
Set krb5 ccache only if krb5 is used

Check if the krb5 mechanism is present and only then set the cache, this
avoid wasteful operations if we are not even using krb5.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAdd GssapiBasicAuthMech option
Simo Sorce [Fri, 19 Jun 2015 21:11:42 +0000 (17:11 -0400)]
Add GssapiBasicAuthMech option

This option allows to set a different list of mechanisms to use
with Basic Auth (Basic Auth must be explicitly enabled) than the
list of mechs that are allowed with Negotiate or Raw GSSAPI Client
authentication.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFix Basic Auth with non-krb5 mechanisms
Simo Sorce [Tue, 16 Jun 2015 20:06:57 +0000 (16:06 -0400)]
Fix Basic Auth with non-krb5 mechanisms

Try each allowed mechanism explicitly in a loop including sourcing
the server name per mechanism to insure the proper name type is
used in the accept.
Otherwise secondary mechanims will fail to work.

Fixes #43

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoBetter handling of desired_mechs
Simo Sorce [Tue, 16 Jun 2015 19:07:37 +0000 (15:07 -0400)]
Better handling of desired_mechs

If no explicit allowed mechanism is set in configuration just ask
GSSAPI for a list of known mechanisms and use that. Do not try to
artificially acquire credentials as ultimatily all that does is
just call gss_inidicate_mechs() internally.

Do not store the result of gss_inidicate_mechs() on cfg->allowed_mechs
as that would lead to a leak given that cfg->allowed_mechs is allocated
on a memory pool, while gss_inidate_mechs()s results are not.

Closes #44

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoEnforce GssapiAllowedMech over raw gssapi mechs
Isaac Boukris [Sun, 14 Jun 2015 15:56:01 +0000 (18:56 +0300)]
Enforce GssapiAllowedMech over raw gssapi mechs

Implemented by aqcuiring creds only for allowed_mechs and by
explicity adding spnego to the allowed_mechs set (while still
restricting spengo only to the allowed mechanism as before).

4 years agoAlways require authentication with basic auth
Simo Sorce [Tue, 16 Jun 2015 17:34:21 +0000 (13:34 -0400)]
Always require authentication with basic auth

When connection bound authentication is used, we must deny access if
basci auth is used and a request does not have the basic auth header.
Basic auth authenticate each and every request, so if it is missing
this means such request is no more authenticated and we should not
allow access based on our cached metadata in this case.

Closes #41

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoMove most of basic_auth handling to a function
Simo Sorce [Sun, 14 Jun 2015 22:23:16 +0000 (18:23 -0400)]
Move most of basic_auth handling to a function

Consolidate and simplify AUTH BASIC Handling - Part 3.

By moving all the special operation one for auth basic into its own
segment we make the code simpler (less exceptions) and more readable.

Closes #39

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoSeparate basic auth loop from the main accept.
Simo Sorce [Sun, 14 Jun 2015 22:23:16 +0000 (18:23 -0400)]
Separate basic auth loop from the main accept.

Consolidate and simplify AUTH BASIC Handling - Part 2.

By moving all the special operation one for auth basic into its own
segment we make the code simpler (less exceptions) and more readable.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoMove the initial part of basic auth processing
Simo Sorce [Sun, 14 Jun 2015 22:23:16 +0000 (18:23 -0400)]
Move the initial part of basic auth processing

Consolidate and simplify AUTH BASIC Handling - Part 1.

By moving all the special operation one for auth basic into its own
segment we make the code simpler (less exceptions) and more readable.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoImprove mag_conn memory handling
Simo Sorce [Tue, 16 Jun 2015 13:36:34 +0000 (09:36 -0400)]
Improve mag_conn memory handling

Create a pool just for the mag_conn structure, so that we can clear up
all the memory used when a reset is necessary.
This also fixes a segfault introduced by a previous patch where we mistakenly
zeroed the whole structure including the memory pool pointer, which needs to
be preserved.

Closes #40

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFix re-authentication when connection bound is on
Simo Sorce [Sun, 14 Jun 2015 22:08:53 +0000 (18:08 -0400)]
Fix re-authentication when connection bound is on

When re-using a context on a connection, a re-authentication request
may end up trying to use an established context handler to establish
a new context. This will fail with an error in GSSAPI.
Make sure to completely clean up the connection data when a brand
new authentication needs to happen so that no data is mistakenly
carried over.

Note this may leak a small amount of data, but only if authentication is
successful, so it is probably fine as is.

Closes #38

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFix connection/session bound auth
Isaac Boukris [Sun, 14 Jun 2015 19:57:26 +0000 (22:57 +0300)]
Fix connection/session bound auth

A previous commit mistakenly removed the jump to the end with a successful
error.
Example scenario that is fixed with this patch:
$ curl -v -u usera:passa http://myhost/ http://myhost/ --ntlm

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoUse apr_pool_cleanup_register() to cleanup mc
Isaac Boukris [Sun, 14 Jun 2015 19:34:28 +0000 (22:34 +0300)]
Use apr_pool_cleanup_register() to cleanup mc

Instead of using apr_pool_userdata_set() since we don't use apr_pool_userdata_get() with the mag_conn_ptr apr_pool_cleanup_register() seem cleaner.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoMake sure to release the ctx when no 'mc' available
Isaac Boukris [Tue, 9 Jun 2015 19:55:53 +0000 (22:55 +0300)]
Make sure to release the ctx when no 'mc' available

And some other cleanup adjusments.

4 years agoWhen an authorization haeder is sent, recheck auth
Simo Sorce [Sat, 13 Jun 2015 21:44:32 +0000 (17:44 -0400)]
When an authorization haeder is sent, recheck auth

Except for BASIC AUTH, if a client send an authorization header it
means it wants to re-check authentication.
So, if an authorization header is sent, go through the regular
path and do not set request variables based on the session data.
In case of Basic Auth we still use session data if user/pwd match
the stored hash.

Closes #22

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoStore data in session as the last thing
Simo Sorce [Sat, 13 Jun 2015 22:44:18 +0000 (18:44 -0400)]
Store data in session as the last thing

mag_attempt_session() was being called too early.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAvoid segfault when skey is not set in config
Simo Sorce [Sat, 13 Jun 2015 22:52:53 +0000 (18:52 -0400)]
Avoid segfault when skey is not set in config

When the skey is generated on the fly, we will get an empty key on the very
first auth attempt. If that uses basic auth then we'll segfault when trying
to compute the hmac as we pass in a NULL key and immediately dereference it.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoActually store basic_hash in the session data
Simo Sorce [Sat, 13 Jun 2015 22:02:45 +0000 (18:02 -0400)]
Actually store basic_hash in the session data

Also fixes a segfault when mc->basic_hash.value is NULL

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoOptimize BASIC AUTH checks with sessions.
Simo Sorce [Sat, 13 Jun 2015 20:46:40 +0000 (16:46 -0400)]
Optimize BASIC AUTH checks with sessions.

If sessions are enbled store a MAC of the password and use it to check
if the password is the same on follow-up requests. If it is, avoid the
whole gssapi dance and use the session data instead.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoSplit HMAC_BUFFER out as a separate publi function
Simo Sorce [Sat, 13 Jun 2015 20:18:39 +0000 (16:18 -0400)]
Split HMAC_BUFFER out as a separate publi function

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoSet KRB5CCNAME on follow up requests with session
Simo Sorce [Sat, 11 Apr 2015 21:27:21 +0000 (17:27 -0400)]
Set KRB5CCNAME on follow up requests with session

If the original context establishment delegated credentials, set
the KRB5CCNAME variable to the proper file name for follow up
connections that uses the session to validate access.

Closes #18

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoUse a compiler to marshall/unmarshall the sessions
Simo Sorce [Tue, 9 Jun 2015 17:30:57 +0000 (13:30 -0400)]
Use a compiler to marshall/unmarshall the sessions

This way changes are easier, all is needed is to change the session.asn1
file to add or remove elements, and different session types can also be
supported at the same time.

4 years agoDisable connection-bound for basic-auth
Isaac Boukris [Sun, 7 Jun 2015 21:52:30 +0000 (00:52 +0300)]
Disable connection-bound for basic-auth

Clients don't expect this and therefore might inappropriately reuse the
connection for another user identity (with or without creds).

This is currently more of an issue due to issue 22, example:
curl -v http://myhost/ -u usera:passa --next http://myhost/ -u userb:passb

Closes #36

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoFix segfault if req->main is NULL
Simo Sorce [Sat, 6 Jun 2015 14:18:43 +0000 (10:18 -0400)]
Fix segfault if req->main is NULL

Seen in the wild.

Closes #35

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoAllow raw NTLM authentication
Simo Sorce [Mon, 25 May 2015 15:04:08 +0000 (17:04 +0200)]
Allow raw NTLM authentication

Some clients may decide to use raw NTLM authentication instead
of wrapping it into a Negotiate (SPNEGO) authentication request.
If the NTLMSSP mechanism is allowed/supported then allow this request
to be processed.

Closes #23

4 years agoAdd GssapiAllowedMech option
Simo Sorce [Mon, 25 May 2015 14:46:23 +0000 (16:46 +0200)]
Add GssapiAllowedMech option

This option allows the admin to list the mechanisms that can be used for
authentication. An empty list allows any locally supported mechanisms.

4 years agoMove acquire_cred functions into a helper
Simo Sorce [Mon, 1 Jun 2015 21:48:15 +0000 (17:48 -0400)]
Move acquire_cred functions into a helper

This makes the code more readable and easier to deal with.
Side effect: now we always acquire credentials

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoMore work on keeping cred_store functions optional
Simo Sorce [Mon, 1 Jun 2015 21:55:34 +0000 (17:55 -0400)]
More work on keeping cred_store functions optional

Some more definitions that depend on cred_store functions were
not properly ifdef-ed

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFix conditional support for gss_acquire_cred_from
Simo Sorce [Mon, 1 Jun 2015 19:22:18 +0000 (15:22 -0400)]
Fix conditional support for gss_acquire_cred_from

This function is supported only on some GSSAPI versions.
Keep it optional.

Signed-off-by: Simo Sorce <simo@redhat.com>
4 years agoFind the right server name when using basic auth
Simo Sorce [Mon, 25 May 2015 13:53:44 +0000 (15:53 +0200)]
Find the right server name when using basic auth

When S4U2Proxy is used in combination with Basic Auth, the gss_inquire_cred()
call will return the client name instead of the server name we need.
Detect this case and aquire a separate set of credentials in that case.

Fixes #28

4 years agoIgnore generated files.
Joe Orton [Sat, 23 May 2015 11:15:53 +0000 (12:15 +0100)]
Ignore generated files.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoExport only the symbol named auth_gssapi_module
Joe Orton [Sat, 23 May 2015 12:04:43 +0000 (13:04 +0100)]
Export only the symbol named auth_gssapi_module

The only entry point into the module DSO is the module structure itself;
use libtool's export-symbols linker trick to hide all the other global
symbols, which otherwise are potentially visible outside the module
itself (SEAL_* etc).

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoRemove all uses of APLOG_NOERRNO
Joe Orton [Sat, 23 May 2015 11:26:36 +0000 (12:26 +0100)]
Remove all uses of APLOG_NOERRNO

This directive is deprecated and has no effect in all httpd 2.x releases.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoFix typo.
Joe Orton [Sat, 23 May 2015 11:24:03 +0000 (12:24 +0100)]
Fix typo.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoDrop OOM handling.
Joe Orton [Sat, 23 May 2015 11:09:06 +0000 (12:09 +0100)]
Drop OOM handling.

In httpd/APR it is best practice to assume that memory allocation always
succeeds, which simplifies module code.

APR internally calls abort() if memory allocation ever actually fails,
so in pratice you cannot trigger these code paths anyway.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoUse the "ssl_is_https" definition from mod_ssl.h.
Joe Orton [Sat, 23 May 2015 11:04:11 +0000 (12:04 +0100)]
Use the "ssl_is_https" definition from mod_ssl.h.

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoAdd GssapiSignalPersistentAuth directive
Isaac Boukris [Sat, 25 Apr 2015 12:36:40 +0000 (15:36 +0300)]
Add GssapiSignalPersistentAuth directive

Controls whether to send the Persistent-Auth header, and sets it only
when necessary/appropriate

Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoExport variable with session expiration time
Simo Sorce [Tue, 5 May 2015 17:36:04 +0000 (13:36 -0400)]
Export variable with session expiration time

Closes #16

4 years agoRevert "Use aes-256-gcm rather than aes-128-cbc"
Simo Sorce [Thu, 23 Apr 2015 18:51:00 +0000 (14:51 -0400)]
Revert "Use aes-256-gcm rather than aes-128-cbc"

This reverts commit e9c92795d87a316ea47f6bf37c9636e86eec57e7.

AESGCM is a neat idea but it is not really appropriate to be used in
mod_auth_gssapi because we cannot gurantee that the nonce will never be
reused. It is not very probable, and it is also not easy to force the
server to generate so many encyrpted sessions to have a good chance of
a collision that I know of, but better to avoid the whole issue, than
risk unforseen cases where it may happen.

4 years agoBump version to 1.2.0 v1.2.0
Simo Sorce [Tue, 21 Apr 2015 15:48:38 +0000 (11:48 -0400)]
Bump version to 1.2.0

4 years agoProperly complete context establishment
Simo Sorce [Sun, 19 Apr 2015 19:59:51 +0000 (15:59 -0400)]
Properly complete context establishment

On success do not forget to send the last negotiate packet (if any)
to the client within the 200 Reply.

Fixes #21

4 years agoAdd support for delegate creds on basic auth
Simo Sorce [Tue, 14 Apr 2015 17:52:05 +0000 (13:52 -0400)]
Add support for delegate creds on basic auth

When doing fallback basic auth, we may also want to honor the
configured directive about storing delegated credentials.
Detect if we are configured to store them and set the appopriate
init_sec_context flag that will cause the accept_sec_context call
to get valid delegated credentials for later storage.

4 years agoBump version to 1.1.1 v1.1.1
Simo Sorce [Thu, 2 Apr 2015 22:00:51 +0000 (18:00 -0400)]
Bump version to 1.1.1

4 years agoHandle authentication on subrequests
Simo Sorce [Mon, 30 Mar 2015 16:48:30 +0000 (12:48 -0400)]
Handle authentication on subrequests

In some cases (like during directory listing) Apache will re-run the
authentication code. Many GSSAPI mechanism have replay detection so
we cannot simply rerun the accept_sec_context phase. Others require
multiple steps. When authntication has already been estalished just
implicitly consider the authentication successfully performed and
copy the user name. Otherwise fail.
If a subrequest hits a location with a different mod_auth_gssapi
configuration warn but do not error off right away.

Fixes #15

4 years agoEscape principal name to remove the path separator
Simo Sorce [Thu, 26 Mar 2015 20:30:56 +0000 (16:30 -0400)]
Escape principal name to remove the path separator

The principla name is used as a file name, any embedded path separators
are going to cause trouble if used in the file name, so we need to escape
them away. Usee ~ as the escape chracter (~~ to escape ~ itself)

Fixes #14

4 years agoBump version to 1.1.0 v1.1.0
Simo Sorce [Thu, 12 Mar 2015 19:49:09 +0000 (15:49 -0400)]
Bump version to 1.1.0

4 years agoUse aes-256-gcm rather than aes-128-cbc
Nathaniel McCallum [Tue, 10 Mar 2015 14:57:23 +0000 (10:57 -0400)]
Use aes-256-gcm rather than aes-128-cbc

Also, remove all the manual HMAC code since it is no longer needed.

The end result should be faster and stronger authenticated encryption.

Closes #12
Reviewed-by: Simo Sorce <simo@redhat.com>
4 years agoDo not free orig_ccache
Simo Sorce [Tue, 10 Mar 2015 21:14:33 +0000 (17:14 -0400)]
Do not free orig_ccache

It realy is const memory referenced internally by MIT's gssapi.
Freeing it will cause a segfault on the next invocation.
This memory is kept in thread local storage and freed by gssapi itself
as needed.

Fixes #11

4 years agoImprove Basic Auth based logins
Simo Sorce [Tue, 10 Mar 2015 16:23:12 +0000 (12:23 -0400)]
Improve Basic Auth based logins

Set a per-thread Credentials Cache Name that will be thrown away once
authentication is done. This handles both an issue with stomping on
ccaches if two authentications happen in concurrent threads, as well
as issues with gss_acquire_cred_with_password() reusing the ccache
without actually performing an AS request.

Fixes #11

4 years agoFix random number generation
Simo Sorce [Tue, 10 Mar 2015 17:32:36 +0000 (13:32 -0400)]
Fix random number generation

Untested code is broken code :(

4 years agoUse apr function for random bytes
Simo Sorce [Tue, 10 Mar 2015 16:15:50 +0000 (12:15 -0400)]
Use apr function for random bytes

The apr function is thread safe while the OpenSSL one depdns on setting
up custom locking, which is hard in a library.

4 years agoDocumentation fixes
Simo Sorce [Mon, 9 Mar 2015 14:46:55 +0000 (10:46 -0400)]
Documentation fixes

Fix GssapiDelegCcacheDir examples and add all the required options to
make GssapiUseS4U2Proxy really work.

Thanks to David Kupka for testing that highlighted these issues.

4 years agoRemove forward basic auth and fix docs
Simo Sorce [Fri, 6 Mar 2015 14:30:51 +0000 (09:30 -0500)]
Remove forward basic auth and fix docs

Fixes #8

4 years agoAdd support for handling Basic Auth
Simo Sorce [Thu, 5 Mar 2015 22:26:45 +0000 (17:26 -0500)]
Add support for handling Basic Auth

Support either passing Basic Auth Through to another module,
or handling it directly through gss_acquire_cred_with_password()

Fixes #8

4 years agoDo not leak acquired_cred
Simo Sorce [Thu, 5 Mar 2015 17:05:45 +0000 (12:05 -0500)]
Do not leak acquired_cred

4 years agoReplace block size constants with actual block size
Nathaniel McCallum [Tue, 3 Feb 2015 14:20:15 +0000 (15:20 +0100)]
Replace block size constants with actual block size

4 years agoBump version to 1.0.4 v1.0.4
Simo Sorce [Sat, 8 Nov 2014 19:20:41 +0000 (14:20 -0500)]
Bump version to 1.0.4

4 years agoFix error message copy&paste error
Simo Sorce [Tue, 21 Oct 2014 17:15:29 +0000 (13:15 -0400)]
Fix error message copy&paste error

4 years agoFix build on some platforms by adding extra flags
Simo Sorce [Tue, 14 Oct 2014 13:17:46 +0000 (09:17 -0400)]
Fix build on some platforms by adding extra flags

For some reason all the necessary CFALGS are not returned by simply
querying the CFLAGS from apxs. We also need to query EXTRA_CPPFLAGS
apparently.

4 years agoProperly initialize logging
Simo Sorce [Mon, 13 Oct 2014 20:46:26 +0000 (16:46 -0400)]
Properly initialize logging

We need to call APLOG_USE_MODULE() so that the module name is reported
properly in log lines, and per module logging level can be set.

Fixes #6

4 years agoAttempt to use sessions only when they are enabled
Simo Sorce [Mon, 13 Oct 2014 20:35:57 +0000 (16:35 -0400)]
Attempt to use sessions only when they are enabled