| 1 |
EXTRACTING LOGIN FROM CERTIFICATE HOWTO |
| 2 |
--------------------------------------- |
| 3 |
|
| 4 |
Starting at pam_pkcs11-0.4.2 a new feature is provided: pam-pkcs11 can |
| 5 |
deduce user name from certificate, without login prompt. |
| 6 |
|
| 7 |
This is done when pam_get_user() call returns null or empty string. |
| 8 |
In this case, pam-pcks11 use the module mapper "find" feature instead |
| 9 |
of normal "match". |
| 10 |
|
| 11 |
If the finder list returns ok, evaluated user is set to pam via |
| 12 |
pam_set_item(PAM_USER) call, and PAM_AUTH_OK is returned. |
| 13 |
|
| 14 |
So there are no longer need to enter user name if a certificate is |
| 15 |
provided and can be mapped to an user. |
| 16 |
|
| 17 |
|
| 18 |
There are to ways to use this feature: |
| 19 |
|
| 20 |
a) Patch "gdm" and "login" programs to detect card presence and return |
| 21 |
null as user name, without prompt for an user login. |
| 22 |
This is a work to be done :-( |
| 23 |
|
| 24 |
b) Use unpatched versions, and do the following procedures: |
| 25 |
|
| 26 |
b.1) When login from console, just enter " " (space) + Enter. |
| 27 |
|
| 28 |
b.2) When login from gdm, just key Enter at login prompt. |
| 29 |
|
| 30 |
In both cases the procedure continues as: |
| 31 |
- If a card is not present, login will ask for password, and gdm will |
| 32 |
prompt again for user login |
| 33 |
|
| 34 |
- If a card is present, pam-pkcs11 will ask for the PIN, and then invoke |
| 35 |
finder in module mapper list. When a user is found, this user becomes |
| 36 |
the logged user |
| 37 |
|
| 38 |
This feature can be used with pam-mkhomedir.so PAM Session module. |
| 39 |
In this case, you can create on-the-fly accounts. This scenario is |
| 40 |
ideal for centralized auth services (Winbind, ldap, kerberos, RDBMS auth...) |
| 41 |
|
| 42 |
As example, here comes my tested /etc/pam.d/gdm file: |
| 43 |
#%PAM-1.0 |
| 44 |
auth sufficient pam_pkcs11.so debug config_file=/etc/pam_pkcs11/pam_pkcs11.conf |
| 45 |
auth required pam_env.so |
| 46 |
auth required pam_stack.so service=system-auth |
| 47 |
auth required pam_nologin.so |
| 48 |
account required pam_stack.so service=system-auth |
| 49 |
password required pam_stack.so service=system-auth |
| 50 |
session required pam_stack.so service=system-auth |
| 51 |
session optional pam_mkhomedir.so skel=/etc/skel umask=0022 |
| 52 |
session optional pam_console.so |
| 53 |
|
| 54 |
IMPORTANT NOTES: |
| 55 |
|
| 56 |
For pam_set_item(PAM_USER) success, application using pam must have |
| 57 |
enough permissions. If this condition is not met, setting user process |
| 58 |
will fail and proper log message registered. So this feature is mainly |
| 59 |
provided for logging processes running as root. |
| 60 |
|
| 61 |
Improper mapper chain configurations with unauthorized certificates can |
| 62 |
lead in the creation of fake accounts in the system if pam_mkhomedir.so |
| 63 |
module is used. So be really careful when authenticating users directly |
| 64 |
from certificates. |
| 65 |
|
| 66 |
Enjoy! |