Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Dev

Client authorization against LDAP using client certificates

 

 

Apache dev RSS feed   Index | Next | Previous | View Threaded


Johannes.Mueller at eon-is

Jul 3, 2008, 11:21 PM

Post #1 of 12 (463 views)
Permalink
Client authorization against LDAP using client certificates

Hello,

we want to use client authorization against LDAP using client certificates on Apache webserver 2.2.
Unfortunately this is not possible with Apache webserver at the current state of development.
There have been third party modules (ModXAuthLDAP, mod_authz_ldap) in the past which did this task quite well.
But they haven’t been updated for years and therefore do not work with httpd newer than 2.0.
Therefore my company has put some effort in developing a reasonable solution for its needs.

Firstly let me describe why it is not possible for us to do this form of authorization with a default httpd.

The client connects using SSL and a client certificate. Mod_ssl receives the request and checks the validity of the certificate using CRLs. After that it sets the user field in the Apache request object to the cn of the certificate (SSLUserName SSL_CLIENT_S_DN_CN). Afterwards mod_auth_basic tries to authenticate the user against its configured provider, wich is LDAP in our case. This fails, because there is no password coming from the certificate, which is quite obvious.

As you can see the missing password in the authentication phase is our main problem.
We tried to use SSLOptions +FakeBasicAuth, but then we would have to set “password” as password for all users in our directory. This is definitely no solution.

Another solution we thought of was to just set the require directives, but the hook seems to never get called, because of the missing AuthType directive.

We have developed the following possible solutions, which involve changes to the apache source code.
I’d be interested in comments and my company would appreciate it, if a solution could be included in apache. I could also provide a patch.

Solution 1
Description
* Add a boolean directive AuthBasicUserFromCert to mod_auth_basic
* This should tell mod_auth_basic not to run the configured authentication provider if a remote user is set by mod_ssl
* If no user is set (client does not provide certificate), basic authentication is done
Implementation
* Register directive in mod_auth_basic.c
* Add branch in authentication function to return AUTH_GRANTED if directive and user is set
* Remove call to ap_note_auth_basic_failure() in mod_authnz_ldap.c to avoid password dialog although we have a certificate if authorization fails
Pros and cons
+ Fallback to basic authentication done easy
+ Does not conflict with AAA-model
+ No duplicate code as we don't have to duplicate basic auth functionality (compare solution 3)
- mod_authnz_ldap has to be modified, too. Maybe this is not needed in Apache 2.3/2.4, because the call has been removed.


Solution 2
Description
* Create new module mod_auth_cert which has to be hooked previous to mod_auth_basic
* This new module runs if AuthType is set to „Cert“ checks for the remote user to be set
* In case the user is set by mod_ssl, return OK
* Else fall back to basic authentication by calling mod_auth_basic somehow
* This can possibly be achieved by rewriting AuthType on the fly
Implementation
* Copy mod_auth_basic.c
* Rename to mod_auth_cert
* Remove needless code
* Register in hook previous to mod_auth_basic.c
* In case the user is set by mod_ssl, return OK
* Else change r→auth_type to „Basic“ ?? Did not work in tests!
Pros and cons
+ Very clean concerning the AAA-model, because mod_auth_basic has nothing to do with certificates in principle
+ No duplicate code as we don't have to duplicate basic auth functionality (compare solution 3)
- Dirty solution concerning rewriting the AuthType directive on the fly
- More difficult to implement
- Maybe impossible


Solution 3
Description
* Duplicate mod_auth_basic
* Call it mod_auth_cert
* Add new directives AuthType „Cert“ and AuthCertProvider
* If remote user is set by mod_ssl do not run authentication provider and return OK
* Else du basic authentication using the provider
Implementation
* Copy mod_auth_basic.c
* Rename to mod_auth_cert.c
* Rename directives
* Add branch in authentication function to return AUTH_GRANTED if directive and user is set
* Remove call to ap_note_auth_basic_failure() in mod_authnz_ldap.c to avoid password dialog although we have a certificate if authorization fails
Pros and cons
+ Fallback to basic authentication done easy
+ Very clean concerning the AAA-model, because mod_auth_basic has nothing to do with certificates in principle
- Otherwise dirty, because mod_auth_cert should have nothing to do with basic authentication, either
- mod_authnz_ldap has to be modified, too. Maybe this is not needed in Apache 2.3/2.4, because the call has been removed.
- Duplicate code


Freundliche Grüße/Kind regards
Johannes Müller

I/TS1A-G - Web Infrastructure
T +49 8 9-12 54 57 92
johannes.mueller[at]eon-is.com

E.ON IS GmbH
Blutenburgstraße 18
80636 München
www.eon-is.com

Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board:
Dr. Marcus Schenck Geschäftsführung/Managing Directors:
Werner Hecker (Vorsitzender/Chairman) Jörg Becker Damian
Bunyan Dr. Kai Pfitzner Dr. Jörg Zunft E.ON IS GmbH
Sitz/Registered Office Hannover Amtsgericht/District Court
Hannover HRB 57814


minfrin at sharp

Jul 4, 2008, 2:13 AM

Post #2 of 12 (447 views)
Permalink
Re: Client authorization against LDAP using client certificates [In reply to]

Müller Johannes wrote:

> we want to use client authorization against LDAP using client certificates on Apache webserver 2.2.
> Unfortunately this is not possible with Apache webserver at the current state of development.
> There have been third party modules (ModXAuthLDAP, mod_authz_ldap) in the past which did this task quite well.
> But they haven’t been updated for years and therefore do not work with httpd newer than 2.0.
> Therefore my company has put some effort in developing a reasonable solution for its needs.

I think the thing that is missing is that the FakeBasicAuth option
within mod_ssl should flag the request to say that a password isn't
necessary.

mod_authnz_ldap (and others) should then be taught to recognise this
flag within the request, and not test the password if this is the case.

Regards,
Graham
--
Attachments: smime.p7s (3.21 KB)


Johannes.Mueller at eon-is

Jul 4, 2008, 2:43 AM

Post #3 of 12 (445 views)
Permalink
Re: Client authorization against LDAP using client certificates [In reply to]

Well, this would require quite big changes to all authentication modules, i guess.
I think, the better way would be to skip authentication completely in mod_auth_basic in case the user is set in the request object, because the user is already authenticated somehow through mod_ssl.


-----Ursprngliche Nachricht-----
Von: Graham Leggett [mailto:minfrin[at]sharp.fm]
Gesendet: Freitag, 4. Juli 2008 11:14
An: dev[at]httpd.apache.org
Betreff: Re: Client authorization against LDAP using client certificates

Mller Johannes wrote:

> we want to use client authorization against LDAP using client certificates on Apache webserver 2.2.
> Unfortunately this is not possible with Apache webserver at the current state of development.
> There have been third party modules (ModXAuthLDAP, mod_authz_ldap) in the past which did this task quite well.
> But they haven't been updated for years and therefore do not work with httpd newer than 2.0.
> Therefore my company has put some effort in developing a reasonable solution for its needs.

I think the thing that is missing is that the FakeBasicAuth option
within mod_ssl should flag the request to say that a password isn't
necessary.

mod_authnz_ldap (and others) should then be taught to recognise this
flag within the request, and not test the password if this is the case.

Regards,
Graham
--


covener at gmail

Jul 4, 2008, 5:28 AM

Post #4 of 12 (440 views)
Permalink
Re: Client authorization against LDAP using client certificates [In reply to]

On Fri, Jul 4, 2008 at 5:43 AM, Mller Johannes
<Johannes.Mueller[at]eon-is.com> wrote:
> Well, this would require quite big changes to all authentication modules, i guess.
> I think, the better way would be to skip authentication completely in mod_auth_basic in case the user is set in the request object, because the user is already authenticated somehow through mod_ssl.

Your solution 2 is not difficult at all, and you don't even really
need to use a new AuthType. Simply returning OK or DECLINED from your
new modules early ap_hook_check_user_id, and letting authz run as
normal, is sufficient for cert-based auth.

--
Eric Covener
covener[at]gmail.com


Johannes.Mueller at eon-is

Jul 4, 2008, 6:08 AM

Post #5 of 12 (440 views)
Permalink
AW: Client authorization against LDAP using client certificates [In reply to]

So far so good, but how to handle fallback to basic authentication if the client has no certificate (SSLVerifyClient optional)?
If we created a new module mod_auth_cert and there is no username from mod_ssl we would like to call mod_auth_basic.
If i understood you right, i would hook mod_auth_cert before mod_auth_basic and let it react on AuthType Basic.
If mod_auth_cert then returns DECLINED, mod_auth_basic runs and does basic authentication.

That would work, but i personally don't like it.
If i configure "AuthType Basic" i want to do basic auth, not cert auth.
If i created a new module i would prefer configuring "AuthType Cert" and doing something like "AuthCertFallback On"

Greetings


-----Ursprngliche Nachricht-----
Von: Eric Covener [mailto:covener[at]gmail.com]
Gesendet: Freitag, 4. Juli 2008 14:28
An: dev[at]httpd.apache.org
Betreff: Re: Client authorization against LDAP using client certificates

On Fri, Jul 4, 2008 at 5:43 AM, Mller Johannes
<Johannes.Mueller[at]eon-is.com> wrote:
> Well, this would require quite big changes to all authentication modules, i guess.
> I think, the better way would be to skip authentication completely in mod_auth_basic in case the user is set in the request object, because the user is already authenticated somehow through mod_ssl.

Your solution 2 is not difficult at all, and you don't even really
need to use a new AuthType. Simply returning OK or DECLINED from your
new modules early ap_hook_check_user_id, and letting authz run as
normal, is sufficient for cert-based auth.

--
Eric Covener
covener[at]gmail.com


ruediger.pluem at vodafone

Jul 4, 2008, 6:18 AM

Post #6 of 12 (434 views)
Permalink
Re: Client authorization against LDAP using client certificates [In reply to]

> -----Ursprngliche Nachricht-----
> Von: Mller Johannes
> Gesendet: Freitag, 4. Juli 2008 15:09
> An: dev[at]httpd.apache.org
> Betreff: AW: Client authorization against LDAP using client
> certificates
>
> So far so good, but how to handle fallback to basic
> authentication if the client has no certificate
> (SSLVerifyClient optional)?
> If we created a new module mod_auth_cert and there is no
> username from mod_ssl we would like to call mod_auth_basic.
> If i understood you right, i would hook mod_auth_cert before
> mod_auth_basic and let it react on AuthType Basic.
> If mod_auth_cert then returns DECLINED, mod_auth_basic runs
> and does basic authentication.
>
> That would work, but i personally don't like it.
> If i configure "AuthType Basic" i want to do basic auth, not
> cert auth.
> If i created a new module i would prefer configuring
> "AuthType Cert" and doing something like "AuthCertFallback On"

You can do it this way and make your module non authoritative by
returning DECLINED.
See

http://httpd.apache.org/docs/2.2/en/mod/mod_auth_basic.html#authbasicauthoritative
http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html#authzldapauthoritative

You can make this configurable by creating something like a
AuthCertAuthoritative directive in you module. And based on its value you return
either DECLINED or DONE.

Regards

Rdiger


minfrin at sharp

Jul 4, 2008, 6:20 AM

Post #7 of 12 (434 views)
Permalink
Re: AW: Client authorization against LDAP using client certificates [In reply to]

Mller Johannes wrote:

> So far so good, but how to handle fallback to basic authentication if the client has no certificate (SSLVerifyClient optional)?
> If we created a new module mod_auth_cert and there is no username from mod_ssl we would like to call mod_auth_basic.
> If i understood you right, i would hook mod_auth_cert before mod_auth_basic and let it react on AuthType Basic.
> If mod_auth_cert then returns DECLINED, mod_auth_basic runs and does basic authentication.
>
> That would work, but i personally don't like it.
> If i configure "AuthType Basic" i want to do basic auth, not cert auth.
> If i created a new module i would prefer configuring "AuthType Cert" and doing something like "AuthCertFallback On"

Hmmm... this looks a little bit too cert specific.

Tt would be cool if we could support auth fallback in an arbitrary
fashion. For example, if a user has a cert, use that as their identity,
otherwise use their session identity from mod_auth_form, or failing that
use basic authentication.

If all of them fail, then pick one of them to handle the "access denied"
part (for example request a basic authentication username and password,
or let mod_auth_form display a login form, whatever).

You might do something like this:

AuthType certificate, form, basic

Regards,
Graham
--
Attachments: smime.p7s (3.21 KB)


Johannes.Mueller at eon-is

Jul 4, 2008, 6:43 AM

Post #8 of 12 (434 views)
Permalink
AW: AW: Client authorization against LDAP using client certificates [In reply to]

Maybe let's concentrate on non-third-party modules.
Basically there is mod_auth_basic and mod_auth_digest on the top level followed by their providers on the second level.
In my opinion mod_auth_cert is another possibilty to authenticate users on the same level as basic and digest, because it has nothing to do with basic and digest authentication in principle.
Therefore i would prefer a third AuthType named Cert or something to keep httpd's authentication model clean.

To support more than one authentication method at a time we would have to do fallback like "AuthType Cert, Basic".
I really share this opinion.

And finally, to use the same provider independent of the configured AuthType, we would have to rename the AuthBasicProvider and AuthDigestProvider directives.
In the end it would look like this:

AuthType Cert, Basic
AuthProvider ldap
AuthLDAP...


-----Ursprngliche Nachricht-----
Von: Graham Leggett [mailto:minfrin[at]sharp.fm]
Gesendet: Freitag, 4. Juli 2008 15:20
An: dev[at]httpd.apache.org
Betreff: Re: AW: Client authorization against LDAP using client certificates

Mller Johannes wrote:

> So far so good, but how to handle fallback to basic authentication if the client has no certificate (SSLVerifyClient optional)?
> If we created a new module mod_auth_cert and there is no username from mod_ssl we would like to call mod_auth_basic.
> If i understood you right, i would hook mod_auth_cert before mod_auth_basic and let it react on AuthType Basic.
> If mod_auth_cert then returns DECLINED, mod_auth_basic runs and does basic authentication.
>
> That would work, but i personally don't like it.
> If i configure "AuthType Basic" i want to do basic auth, not cert auth.
> If i created a new module i would prefer configuring "AuthType Cert" and doing something like "AuthCertFallback On"

Hmmm... this looks a little bit too cert specific.

Tt would be cool if we could support auth fallback in an arbitrary
fashion. For example, if a user has a cert, use that as their identity,
otherwise use their session identity from mod_auth_form, or failing that
use basic authentication.

If all of them fail, then pick one of them to handle the "access denied"
part (for example request a basic authentication username and password,
or let mod_auth_form display a login form, whatever).

You might do something like this:

AuthType certificate, form, basic

Regards,
Graham
--


Johannes.Mueller at eon-is

Jul 4, 2008, 6:48 AM

Post #9 of 12 (434 views)
Permalink
AW: Client authorization against LDAP using client certificates [In reply to]

Yeah, we thought about this one too, but we tend to get this functionality into the apache source linked directly to the AAA model.

Greetings


-----Ursprngliche Nachricht-----
Von: "Plm, Rdiger, VF-Group" [mailto:ruediger.pluem[at]vodafone.com]
Gesendet: Freitag, 4. Juli 2008 15:19
An: dev[at]httpd.apache.org
Betreff: Re: Client authorization against LDAP using client certificates

You can do it this way and make your module non authoritative by
returning DECLINED.
See

http://httpd.apache.org/docs/2.2/en/mod/mod_auth_basic.html#authbasicauthoritative
http://httpd.apache.org/docs/2.2/en/mod/mod_authnz_ldap.html#authzldapauthoritative

You can make this configurable by creating something like a
AuthCertAuthoritative directive in you module. And based on its value you return
either DECLINED or DONE.

Regards

Rdiger


henrik at henriknordstrom

Jul 4, 2008, 7:41 AM

Post #10 of 12 (434 views)
Permalink
Re: AW: AW: Client authorization against LDAP using client certificates [In reply to]

On fre, 2008-07-04 at 15:43 +0200, Müller Johannes wrote:

> To support more than one authentication method at a time we would have to do fallback like "AuthType Cert, Basic".

Or for that matter "AuthType Digest, Basic".

Regards
Henrik
Attachments: signature.asc (0.30 KB)


minfrin at sharp

Jul 4, 2008, 10:33 AM

Post #11 of 12 (416 views)
Permalink
Re: AW: AW: Client authorization against LDAP using client certificates [In reply to]

Mller Johannes wrote:

> Maybe let's concentrate on non-third-party modules.
> Basically there is mod_auth_basic and mod_auth_digest on the top level followed by their providers on the second level.

mod_auth_form is part of httpd trunk, and is not a third party module.

Regards,
Graham
--
Attachments: smime.p7s (3.21 KB)


Johannes.Mueller at eon-is

Jul 5, 2008, 3:03 AM

Post #12 of 12 (394 views)
Permalink
AW: AW: AW: Client authorization against LDAP using client certificates [In reply to]

Sorry, you are right!
Well then it's the fourth module in the collection.

-----Ursprngliche Nachricht-----
Von: Graham Leggett [mailto:minfrin[at]sharp.fm]
Gesendet: Freitag, 4. Juli 2008 19:33
An: dev[at]httpd.apache.org
Betreff: Re: AW: AW: Client authorization against LDAP using client certificates

Mller Johannes wrote:

> Maybe let's concentrate on non-third-party modules.
> Basically there is mod_auth_basic and mod_auth_digest on the top level followed by their providers on the second level.

mod_auth_form is part of httpd trunk, and is not a third party module.

Regards,
Graham
--

Apache dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.