---
- name: Install cas client lib
get_url:
url: "{{ item.url }}"
checksum: sha1:{{ item.sha1 }}
dest: /opt/zimbra/jetty/common/lib/
loop: "{{ zcs_cas_libs }}"
tags: zcs
- name: Get or generate a pre authentication key
shell: |
KEY=$(/opt/zimbra/bin/zmprov getDomain {{ item }} zimbrapreauthkey | perl -ne '/^(?:zimbraP|p)reAuthKey: (.*)/ && print $1')
[ -z $KEY ] && KEY=$(/opt/zimbra/bin/zmprov generateDomainPreAuthKey {{ item }} | perl -ne '/^(?:zimbraP|p)reAuthKey: (.*)/ && print $1')
echo $KEY
become_user: zimbra
register: zcs_preauthkeys
changed_when: False
loop: "{{ zcs_domains.keys() | list }}"
tags: zcs
- name: Install preauth pages
template: src=cas_preauth.jsp.j2 dest=/opt/zimbra/jetty/webapps/zimbra/public/preauth_{{ item.item }}.jsp owner=zimbra group=zimbra
loop: "{{ zcs_preauthkeys.results }}"
notify: restart zimbra
tags: zcs
- name: Install admin preauth pages
template: src=cas_preauth_admin.jsp.j2 dest=/opt/zimbra/jetty/webapps/zimbraAdmin/public/preauth_{{ item.item }}.jsp owner=zimbra group=zimbra
loop: "{{ zcs_preauthkeys.results }}"
notify: restart zimbra
tags: zcs
- name: Configure CAS filters
blockinfile:
path: /opt/zimbra/jetty/etc/zimbra.web.xml.in
block: |2
{% for domain in zcs_domains.keys() | list %}
{% if zcs_domains[domain].cas is defined and zcs_domains[domain].cas.enabled is defined and zcs_domains[domain].cas.enabled %}
CasSingleSignOutFilter{{ domain }}
org.jasig.cas.client.session.SingleSignOutFilter
casServerUrlPrefix
{{ zcs_domains[domain].cas.server_url }}
CasSingleSignOutFilter{{ domain }}
/*
org.jasig.cas.client.session.SingleSignOutHttpSessionListener
CasAuthenticationFilter{{ domain }}
org.jasig.cas.client.authentication.AuthenticationFilter
casServerLoginUrl
{{ zcs_domains[domain].cas.server_url }}/login
serverName
{{ zcs_domains[domain].public_url }}
CasAuthenticationFilter{{ domain }}
/public/preauth_{{ domain }}.jsp
CasValidationFilter{{ domain }}
org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter
casServerUrlPrefix
{{ zcs_domains[domain].cas.server_url }}
serverName
{{ zcs_domains[domain].public_url }}
redirectAfterValidation
true
CasValidationFilter{{ domain }}
/*
{% else %}
{% endif %}
{% endfor %}
CasHttpServletRequestWrapperFilter
org.jasig.cas.client.util.HttpServletRequestWrapperFilter
CasHttpServletRequestWrapperFilter
/public/*
COOKIE
marker: ''
insertafter: ''
validate: xmllint %s
notify: restart zimbra
tags: zcs
- name: Configure CAS admin filters
blockinfile:
path: /opt/zimbra/jetty/etc/zimbraAdmin.web.xml.in
block: |2
{% for domain in zcs_domains.keys() | list %}
{% if zcs_domains[domain].cas is defined and zcs_domains[domain].cas.enabled is defined and zcs_domains[domain].cas.enabled %}
CasSingleSignOutFilter{{ domain }}
org.jasig.cas.client.session.SingleSignOutFilter
casServerUrlPrefix
{{ zcs_domains[domain].cas.server_url }}
CasSingleSignOutFilter{{ domain }}
/*
org.jasig.cas.client.session.SingleSignOutHttpSessionListener
CasAuthenticationFilter{{ domain }}
org.jasig.cas.client.authentication.AuthenticationFilter
casServerLoginUrl
{{ zcs_domains[domain].cas.server_url }}/login
serverName
{{ zcs_domains[domain].admin_url }}
CasAuthenticationFilter{{ domain }}
/public/preauth_{{ domain }}.jsp
CasValidationFilter{{ domain }}
org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter
casServerUrlPrefix
{{ zcs_domains[domain].cas.server_url }}
serverName
{{ zcs_domains[domain].admin_url }}
redirectAfterValidation
true
CasValidationFilter{{ domain }}
/*
{% else %}
{% endif %}
{% endfor %}
CasHttpServletRequestWrapperFilter
org.jasig.cas.client.util.HttpServletRequestWrapperFilter
CasHttpServletRequestWrapperFilter
/public/*
COOKIE
marker: ''
insertafter: ''
validate: xmllint %s
notify: restart zimbra
tags: zcs
- name: Configure login and logout URL
shell: |
/opt/zimbra/bin/zmprov modifyDomain {{ item }} zimbraWebClientLoginURL "{{ zcs_domains[item].public_url | regex_replace('/$','') }}/public/preauth_{{ item }}.jsp"
/opt/zimbra/bin/zmprov modifyDomain {{ item }} zimbraAdminConsoleLoginURL "{{ zcs_domains[item].admin_url | regex_replace('/$','') }}/zimbraAdmin/public/preauth_{{ item }}.jsp"
/opt/zimbra/bin/zmprov modifyDomain {{ item }} zimbraWebClientLogoutURL "{{ zcs_domains[item].cas.server_url | regex_replace('/$','') }}/logout"
/opt/zimbra/bin/zmprov modifyDomain {{ item }} zimbraAdminConsoleLogoutURL "{{ zcs_domains[item].cas.server_url | regex_replace('/$','') }}/logout"
become_user: zimbra
loop: "{{ zcs_domains.keys() | list }}"
when:
- zcs_domains[item].cas is defined
- zcs_domains[item].cas.enabled is defined
- zcs_domains[item].cas.enabled == True
changed_when: False
tags: zcs