summaryrefslogtreecommitdiffstats
path: root/src/mod_auth_gssapi.c
Commit message (Collapse)AuthorAgeFilesLines
* Add cleanup function for mag_conn->name_attributesHEADmasterAlejandro Perez2017-02-131-2/+0
| | | | | Reviewed-by: Simo Sorce <simo@redhat.com> Closes #127
* Add option to set alternative ccname env varFraser Tweedale2017-02-081-0/+4
| | | | | | | | | | | | | In some cases (e.g. if you want to convey the ccname over AJP) the request environment variable name "KRB5CCNAME" is not appropriate. Add the GssapiDelegCcacheEnvVar option that allows the env var name to be changed. Fixes: https://github.com/modauthgssapi/mod_auth_gssapi/issues/123 Reviewed-by: Simo Sorce <simo@redhat.com> Closes #124 Closes #123
* rewrite: implicitly handle internal redirectsIsaac Boukris2017-01-111-5/+34
| | | | | | | | | | | | | | Internal redirects are a special case of subrequest - they have no req->main but req->prev instead, so we should check for that too in case the request is not initial. Also, make sure to export MAG environment variables to subrequests and internal redirects. Signed-off-by: Isaac Boukris <iboukris@gmail.com> Reviewed-by: Simo Sorce <simo@redhat.com> Reported-by: scopev24 Closes #119
* Add option to store the session encryption key.Simo Sorce2017-01-031-14/+85
| | | | | | | | | | With the new 'file:' sytnax a session key can be automatically generated the first time mod_auth_gssapi runs and stored on the filesystem. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com> Closes #117
* Fix memory pool used to hold ccache nameMarcel Ritter2016-12-191-1/+1
| | | | | | | | | broken ccache name when "GssapiDelegCcacheUnique Off" (default) Signed-off-by: Marcel Ritter <ritter.marcel@googlemail.com> Reviewed-by: Simo Sorce <simo@redhat.com> Closes #116 Fixes #115
* Add option to set custom permissions on ccacheSimo Sorce2016-11-301-0/+83
| | | | | | | | | This allows apache to set permission so that another user in the default group can access the ccache. Useful when apache passes the request to a process running under a different user or group id number. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com>
* Write 'Persistent-Auth' header to err_headers_outMichael Osipov2016-10-111-1/+1
| | | | | | | | | | | | | | In some cases, like internal redirects, authentication is completed but our 'Persistent-Auth' header is dropped by the server because headers_out is ignored with errors (4xx, 5xx) and internal redirects. See: https://ci.apache.org/projects/httpd/trunk/doxygen/structrequest__rec.html#a9f49c2d5680987c0c28466ea37d41a62 This fixes #110 Reviewed-by: Simo Sorce <simo@redhat.com> Reviewed-by: Isaac Boukris <iboukris@gmail.com> Closes #111
* Declare mag_complete outside the ifdef blockSimo Sorce2016-10-111-4/+4
| | | | | | | | Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Isaac Boukris <iboukris@gmail.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com> Fixes #106 Closes #107
* Move context loops to a helper functionSimo Sorce2016-06-151-110/+72
| | | | | | | | This work simplifies the calling code and reduces duplication. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Reviewed-by: Isaac Boukris <iboukris@gmail.com> Close #94
* Postpone adding spnego mech to mech listSimo Sorce2016-06-091-23/+65
| | | | | | | | | | | Add the SPNEGO mech oid only if we are performing negotiate auth. This cacthes earlier, with a hard failure, the case where a mechanism defined on the command line is not available, by checking if there are any desired mechs. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Isaac Boukris <iboukris@gmail.com> Close #93
* Add support for GssapiImpersonate.Jan Pazdziora2016-06-091-1/+156
| | | | | | | | | | | | | | | | This is can be enabled on locations that are authenticated by another module to obtain a ticket for the user, so that the application gets access to krb5 credentials and all named attributes for the client. The service needs to be authorized by the KDC if there is the need to use credentials for further ticket acquisition by setting the ok_to_auth_as_delegate flag on the service principal. This will provide a forwardable ticket that can be used to obtain additional tickets via consrained delegation (also subkect to KDC access control). Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com> Signed-off-by: Simo Sorce <simo@redhat.com> Close #92
* Split the book keeping operations into a functionSimo Sorce2016-06-091-48/+66
| | | | | | | | | This will be used in a following patch that perform gssapi operations using a different path but need to perform the same bookj keeping as the main auth path. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Jan Pazdziora <jpazdziora@redhat.com>
* Do not use ap_hook_check_user_id on Apache 2.4Jan Pazdziora2016-06-021-0/+5
| | | | | | | | On Apache 2.4 this method is deprecated, use the recommended hook. Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com> Close #84
* Implement unique ccache namesRobbie Harwood2016-05-181-11/+54
| | | | | | | | | | | Unique ccache names may be requested using the GssapiDelegCcacheUnique configuration option. This option is off by default. If both unique ccache names and session use are enabled, then a mechanism for removing old ccaches must be supplied. Signed-off-by: Robbie Harwood <rharwood@redhat.com> Also-authored-by: Petr Vobornik <pvoborni@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Unify copyright conventionRobbie Harwood2016-05-181-23/+1
| | | | | Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
* Cleanup s4u2proxy in mag_auth_basicIsaac Boukris2016-02-171-18/+4
| | | | | | | | | | | | | | 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
* Add option to not send a Negotiate headersJames Groffen2016-02-171-5/+22
| | | | | | | | | | | | | | | | 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
* Fix build when cred store is not available.Simo Sorce2016-01-131-0/+2
| | | | | | Older distributions have versions of Kerberos that miss this feature. Signed-off-by: Simo Sorce <simo@redhat.com>
* Add code to set attribute names in the environmentname_attrsSimo Sorce2015-12-031-2/+68
| | | | | | | | | | | | 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
* Move setting request data to a separate fileSimo Sorce2015-12-021-88/+35
| | | | | | In preparation for the next commit. Signed-off-by: Simo Sorce <simo@redhat.com>
* Fix bug in handling Session KeysSimo Sorce2015-09-031-1/+1
| | | | | | | | 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>
* Allow building without NTLMSSP supportSimo Sorce2015-09-031-9/+20
| | | | | | | | | | | | | 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
* Do not use /tmp as default for s4u2proxySimo Sorce2015-08-311-4/+14
| | | | | | | | | | 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>
* Allocate new keys at server startup.Simo Sorce2015-08-301-8/+24
| | | | | | | | 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>
* Support forward proxy authenticationIsaac Boukris2015-08-061-20/+44
| | | | | | | | Proxy auth headers are a little different. Sessions cannot be used as we cannot set a cookie. Reviewed-by: Simo Sorce <simo@redhat.com>
* Avoid advertising NTLM if it isn't technically supportedIsaac Boukris2015-08-061-3/+9
| | | | | | | | | | 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>
* Fix checks on allowed mechsSimo Sorce2015-07-071-6/+6
| | | | | | | | | | | | | | 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>
* Retrieve default mechs at server initIsaac Boukris2015-06-251-34/+39
| | | | | | | | | | 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>
* Properly check return error when filtering mechsSimo Sorce2015-06-241-1/+4
| | | | | | | 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>
* Fail server startup on bad mechanismsIsaac Boukris2015-06-241-6/+10
| | | | | | | This helps to detect mis-configurations early. Configuration errors are considered fatal in apache anyway. Reviewed-by: Simo Sorce <simo@redhat.com>
* Skip spnego filtering since we already filter itIsaac Boukris2015-06-231-6/+0
| | | | Reviewed-by: Simo Sorce <simo@redhat.com>
* Acquire server creds with given cred_usage rather than bothIsaac Boukris2015-06-231-1/+1
| | | | Reviewed-by: Simo Sorce <simo@redhat.com>
* Support allowing arbitrary mechanismsSimo Sorce2015-06-221-21/+50
| | | | | | | | | 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>
* Acquire creds only once for basic_authSimo Sorce2015-06-221-25/+26
| | | | | | | | | | 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>
* Set krb5 ccache only if krb5 is usedSimo Sorce2015-06-211-19/+37
| | | | | | | 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>
* Add GssapiBasicAuthMech optionSimo Sorce2015-06-201-22/+142
| | | | | | | | | 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>
* Fix Basic Auth with non-krb5 mechanismsSimo Sorce2015-06-191-55/+85
| | | | | | | | | | | 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>
* Better handling of desired_mechsSimo Sorce2015-06-191-7/+12
| | | | | | | | | | | | | | | 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>
* Enforce GssapiAllowedMech over raw gssapi mechsIsaac Boukris2015-06-191-0/+9
| | | | | | 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).
* Always require authentication with basic authSimo Sorce2015-06-161-1/+3
| | | | | | | | | | | | 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>
* Move most of basic_auth handling to a functionSimo Sorce2015-06-161-126/+160
| | | | | | | | | | | 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>
* Separate basic auth loop from the main accept.Simo Sorce2015-06-161-37/+27
| | | | | | | | | 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>
* Move the initial part of basic auth processingSimo Sorce2015-06-161-49/+47
| | | | | | | | | 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>
* Improve mag_conn memory handlingSimo Sorce2015-06-161-13/+30
| | | | | | | | | | | | 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>
* Fix re-authentication when connection bound is onSimo Sorce2015-06-141-8/+18
| | | | | | | | | | | | | | | | 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>
* Fix connection/session bound authIsaac Boukris2015-06-141-0/+2
| | | | | | | | | 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>
* Use apr_pool_cleanup_register() to cleanup mcIsaac Boukris2015-06-141-2/+2
| | | | | | 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>
* Make sure to release the ctx when no 'mc' availableIsaac Boukris2015-06-131-2/+3
| | | | And some other cleanup adjusments.
* When an authorization haeder is sent, recheck authSimo Sorce2015-06-131-25/+32
| | | | | | | | | | | | | 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>
* Store data in session as the last thingSimo Sorce2015-06-131-3/+3
| | | | | | mag_attempt_session() was being called too early. Signed-off-by: Simo Sorce <simo@redhat.com>