-
Notifications
You must be signed in to change notification settings - Fork 21
Kerberos-based authentication #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
73c02d2
c3eae31
0ebcb23
81c85ff
0332563
c8f68e2
2c204d2
9ed48d9
4912a18
126629b
19b310a
735a3ce
4979f6c
9b015c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| - name: Remove external authentication configuration | ||
| ansible.builtin.file: | ||
| path: "/etc/httpd/conf.d/05-{{ item }}.d/external_auth.conf" | ||
| state: absent | ||
| notify: | ||
| - Restart httpd | ||
| loop: | ||
| - foreman | ||
| - foreman-ssl | ||
|
|
||
| - name: Remove Apache module configuration files for IPA authentication | ||
| ansible.builtin.file: | ||
| path: /etc/httpd/conf.modules.d/55-{{ item }}.conf | ||
| state: absent | ||
| loop: | ||
| - authnz_pam | ||
| - intercept_form_submit | ||
| - lookup_identity | ||
| - auth_gssapi | ||
| notify: | ||
| - Restart httpd |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| - name: Install Apache modules for IPA authentication | ||
| ansible.builtin.package: | ||
| name: | ||
| - mod_authnz_pam | ||
| - mod_intercept_form_submit | ||
| - mod_lookup_identity | ||
| - mod_auth_gssapi | ||
| state: present | ||
|
|
||
| - name: Create directory for Apache module configuration | ||
| ansible.builtin.file: | ||
| path: /etc/httpd/conf.modules.d | ||
| state: directory | ||
| mode: "0755" | ||
|
|
||
| - name: Load Apache modules for IPA authentication | ||
| ansible.builtin.copy: | ||
| dest: /etc/httpd/conf.modules.d/55-{{ item }}.conf | ||
| content: | | ||
| LoadModule {{ item }}_module modules/mod_{{ item }}.so | ||
| mode: "0644" | ||
| loop: | ||
| - authnz_pam | ||
| - intercept_form_submit | ||
| - lookup_identity | ||
| - auth_gssapi | ||
| notify: | ||
| - Restart httpd | ||
|
|
||
| - name: Set SELinux booleans for IPA authentication | ||
| ansible.posix.seboolean: | ||
| name: "{{ item }}" | ||
| state: true | ||
| persistent: true | ||
| loop: | ||
| - allow_httpd_mod_auth_pam | ||
| - httpd_dbus_sssd | ||
| when: ansible_facts['selinux']['status'] == "enabled" | ||
|
|
||
| - name: Configure SSSD for IPA authentication | ||
| ansible.builtin.import_tasks: ../sssd.yml | ||
| when: httpd_ipa_manage_sssd | bool | ||
|
|
||
| - name: Create PAM service file for IPA authentication | ||
| ansible.builtin.template: | ||
| src: pam_service.j2 | ||
| dest: "/etc/pam.d/{{ httpd_ipa_pam_service }}" | ||
| mode: "0644" | ||
|
|
||
|
Comment on lines
+45
to
+50
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory this is not needed if
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But when is it not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then the service either needs to be defined manually by the user as a yet another pam service or it has to be the name of a user-created HBAC service in ipa Edit: in either case, deploying our custom service config shouldn't be needed, but also doesn't really hurt anything |
||
| - name: Ensure keytab directory exists | ||
| ansible.builtin.file: | ||
| path: "{{ httpd_ipa_keytab | dirname }}" | ||
| state: directory | ||
| mode: "0755" | ||
|
|
||
| - name: Get keytab for HTTP service | ||
| ansible.builtin.shell: | ||
| cmd: | | ||
| KRB5CCNAME=KEYRING:session:get-http-service-keytab kinit -k || true | ||
| KRB5CCNAME=KEYRING:session:get-http-service-keytab /usr/sbin/ipa-getkeytab -k {{ httpd_ipa_keytab }} -p HTTP/{{ ansible_facts['fqdn'] }} | ||
| kdestroy -c KEYRING:session:get-http-service-keytab || true | ||
| creates: "{{ httpd_ipa_keytab }}" | ||
| changed_when: false | ||
|
|
||
| - name: Set keytab file permissions | ||
| ansible.builtin.file: | ||
| path: "{{ httpd_ipa_keytab }}" | ||
| owner: apache | ||
| group: apache | ||
| mode: "0600" | ||
|
|
||
| - name: Create directory for Apache configuration fragments | ||
| ansible.builtin.file: | ||
| path: /etc/httpd/conf.d/05-{{ item }}.d | ||
| state: directory | ||
| mode: "0755" | ||
| loop: | ||
| - foreman | ||
| - foreman-ssl | ||
|
|
||
| - name: Deploy external authentication configuration | ||
| ansible.builtin.template: | ||
| src: external_auth.conf.j2 | ||
| dest: /etc/httpd/conf.d/05-{{ item }}.d/external_auth.conf | ||
| mode: "0644" | ||
| notify: | ||
| - Restart httpd | ||
| loop: | ||
| - foreman | ||
| - foreman-ssl | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| - name: Configure IPA authentication with API support | ||
| ansible.builtin.import_tasks: ipa.yml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| - name: Install sssd-dbus package | ||
| ansible.builtin.package: | ||
| name: sssd-dbus | ||
| state: present | ||
|
|
||
| - name: Ensure SSSD service is running and enabled | ||
| ansible.builtin.systemd: | ||
| name: sssd | ||
| state: started | ||
| enabled: true | ||
|
|
||
| - name: Read existing SSSD configuration | ||
| ansible.builtin.slurp: | ||
| src: /etc/sssd/sssd.conf | ||
| register: httpd_sssd_config | ||
| ignore_errors: true | ||
|
|
||
| - name: Parse SSSD services configuration | ||
| ansible.builtin.set_fact: | ||
| httpd_sssd_existing_services: "{{ (httpd_sssd_config.content | default('') | b64decode | | ||
| regex_search('\\[sssd\\][\\s\\S]*?services\\s*=\\s*([^\\n]+)', '\\1', multiline=True) | | ||
| default(['']) | first) | trim }}" | ||
| when: httpd_sssd_config.content is defined | ||
|
|
||
| - name: Configure SSSD services to include ifp | ||
| community.general.ini_file: | ||
| path: /etc/sssd/sssd.conf | ||
| section: sssd | ||
| option: services | ||
| value: "{{ httpd_sssd_existing_services }}{% if httpd_sssd_existing_services != '' %}, {% endif %}ifp" | ||
| mode: "0600" | ||
| when: httpd_sssd_existing_services | regex_search('\\bifp\\b') != 'ifp' | ||
| notify: | ||
| - Restart sssd | ||
|
|
||
| - name: Configure SSSD IFP allowed_uids | ||
| community.general.ini_file: | ||
| path: /etc/sssd/sssd.conf | ||
| section: ifp | ||
| option: allowed_uids | ||
| value: "root, apache" | ||
| mode: "0600" | ||
| notify: | ||
| - Restart sssd | ||
|
|
||
| - name: Configure SSSD IFP user_attributes | ||
| community.general.ini_file: | ||
| path: /etc/sssd/sssd.conf | ||
| section: ifp | ||
| option: user_attributes | ||
| value: "+email, +firstname, +lastname" | ||
| mode: "0600" | ||
| notify: | ||
| - Restart sssd |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| {% if httpd_external_authentication in ['ipa', 'ipa_with_api'] %} | ||
| # Intercept form submissions for PAM authentication | ||
| <Location /users/login> | ||
| InterceptFormPAMService {{ httpd_ipa_pam_service }} | ||
| InterceptFormLogin login[login] | ||
| InterceptFormPassword login[password] | ||
| </Location> | ||
|
|
||
| # Lookup user attributes from SSSD | ||
| <LocationMatch ^(/api(/v2)?)?/users/(ext)?login/?$> | ||
| LookupUserAttr email REMOTE_USER_EMAIL | ||
| LookupUserAttr firstname REMOTE_USER_FIRSTNAME | ||
| LookupUserAttr lastname REMOTE_USER_LASTNAME | ||
| LookupUserGroups REMOTE_USER_GROUPS : | ||
| LookupUserGroupsIter REMOTE_USER_GROUP | ||
|
|
||
| # Set headers for proxy requests | ||
| RequestHeader set REMOTE_USER %{REMOTE_USER}e | ||
| RequestHeader set REMOTE_USER_EMAIL %{REMOTE_USER_EMAIL}e | ||
| RequestHeader set REMOTE_USER_FIRSTNAME %{REMOTE_USER_FIRSTNAME}e | ||
| RequestHeader set REMOTE_USER_LASTNAME %{REMOTE_USER_LASTNAME}e | ||
| RequestHeader set REMOTE_USER_GROUPS %{REMOTE_USER_GROUPS}e | ||
| </LocationMatch> | ||
|
|
||
| # GSSAPI/Kerberos authentication for web UI | ||
| <LocationMatch ^/users/extlogin/?$> | ||
| SSLRequireSSL | ||
| AuthType GSSAPI | ||
| AuthName "GSSAPI Single Sign On Login" | ||
| GssapiCredStore keytab:{{ httpd_ipa_keytab }} | ||
| GssapiSSLonly On | ||
| GssapiLocalName {{ httpd_ipa_gssapi_local_name | ternary('On', 'Off') }} | ||
| # require valid-user | ||
| require pam-account {{ httpd_ipa_pam_service }} | ||
| ErrorDocument 401 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>' | ||
| # The following is needed as a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1020087 | ||
| ErrorDocument 500 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>' | ||
| </LocationMatch> | ||
|
|
||
| # External authentication for API endpoints | ||
| <LocationMatch ^/api(/v2)?/users/extlogin/?$> | ||
| SSLRequireSSL | ||
| {% if httpd_external_authentication == 'ipa_with_api' %} | ||
| <If "%{HTTP:Authorization} =~ /^Basic/"> | ||
| AuthType Basic | ||
| AuthName "PAM Authentication" | ||
| AuthBasicProvider PAM | ||
| AuthPAMService {{ httpd_ipa_pam_service }} | ||
| </If> | ||
| <Else> | ||
| AuthType GSSAPI | ||
| AuthName "GSSAPI Single Sign On Login" | ||
| GssapiCredStore keytab:{{ httpd_ipa_keytab }} | ||
| GssapiSSLonly On | ||
| GssapiLocalName {{ httpd_ipa_gssapi_local_name | ternary('On', 'Off') }} | ||
| </Else> | ||
| {% else %} | ||
| AuthType Basic | ||
| AuthName "PAM Authentication" | ||
| AuthBasicProvider PAM | ||
| AuthPAMService {{ httpd_ipa_pam_service }} | ||
| {% endif %} | ||
| require pam-account {{ httpd_ipa_pam_service }} | ||
| ErrorDocument 401 '{ "error": "External authentication did not pass." }' | ||
| # The following is needed as a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1020087 | ||
| ErrorDocument 500 '{ "error": "External authentication did not pass." }' | ||
| </LocationMatch> | ||
| {% endif %} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between the two?
ipais UI only, whileipa_with_apidoes UI and API?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to extend that, later we can add other methods here, like oidc etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly
Yes, that was the intent here
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and those are mutually exclusive, right? as in, there can be only one external auth?
(LDAP probably always works, but that's not terminated on the httpd level)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I wanted to avoid the situation we had in the old installer where all the methods could be enabled individually, but some conflicted with others.