Critérios de consulta ao OpenLDAP para Shibboleth
Esse roteiro visa ajudar na configuração do seu IdP para que os acessos federados sejam realizados com mais um critério a ser atendido no momento do login. As configurações serão realizadas no arquivo ldap.properties, esse arquivo contêm toda a informação de conexão do seu IdP com sua base de diretório OpenLDAP.
Importante !
Antes de começar é recomendado que seja feito o backup do arquivo "ldap.properties" em seu IdP. O arquivo fica no caminho: /opt/shibboleth-idp/conf
Considerar em todo texto abaixo que, OpenLDAP é a referência usada para identificar a base de diretório usada para a consulta do Shibboleth em seu IdP. Toda essa configuração foi homologada em um ambiente com os seguintes requisitos: Idp → Ubuntu 20.04, Shibboleth 4.2.1, Apache2 e Jetty9
Esse procedimento tem como requisito a criação do grupo, que deseja usar, no seu LDAP. Antes de começar crie seu grupo em sua base OpenLDAP.
Esse roteiro não irá esclarecer a forma como deve ser feita a criação de grupos em seu OpenLDAP ou AD.
Guia passo a passo
Faremos abaixo as etapas de configuração do arquivo "ldap.properties" para que as contas em seu OpenLDAP atendam um critério maior na consulta pelo Shibboleth em seu IdP:
Vamos abrir o arquivo "ldap.properties" dos seu IdP, use um editor de sua preferência, é recomendado o uso do VI ou VIM. O caminho é /opt/shibboleth-idp/conf :
# LDAP authentication configuration, see authn/ldap-authn-config.xml
## Authenticator strategy, either anonSearchAuthenticator, bindSearchAuthenticator, directAuthenticator, adAuthenticator
#idp.authn.LDAP.authenticator = anonSearchAuthenticator
idp.authn.LDAP.authenticator = bindSearchAuthenticator
## Connection properties ##
idp.authn.LDAP.ldapURL = ldaps://Openldap.homolog.rnp:636
idp.authn.LDAP.useStartTLS = false
idp.authn.LDAP.useSSL = false
idp.authn.LDAP.connectTimeout = 3000
## SSL configuration, either jvmTrust, certificateTrust, or keyStoreTrust
idp.authn.LDAP.sslConfig = certificateTrust
## If using certificateTrust above, set to the trusted certificate's path
idp.authn.LDAP.trustCertificates = %{idp.home}/credentials/ldap-server.crt
## If using keyStoreTrust above, set to the truststore path
idp.authn.LDAP.trustStore = %{idp.home}/credentials/ldap-server.truststore
## Return attributes during authentication
## NOTE: this is not used during attribute resolution; configure that directly in the
## attribute-resolver.xml configuration via a DataConnector's <dc:ReturnAttributes> element
idp.authn.LDAP.returnAttributes = uid
## DN resolution properties ##
# Search DN resolution, used by anonSearchAuthenticator, bindSearchAuthenticator
# for AD: CN=Users,DC=example,DC=org
idp.authn.LDAP.baseDN = ou=RNP,dc=homolog,dc=rnp
idp.authn.LDAP.subtreeSearch = true
idp.authn.LDAP.userFilter = (uid={user})
# bind search configuration
# for AD: [email protected]
idp.authn.LDAP.bindDN = uid=leitor-shib,ou=Admins,dc=homolog,dc=rnp
idp.authn.LDAP.bindDNCredential = XXXXXXXX
# Format DN resolution, used by directAuthenticator, adAuthenticator
# for AD use idp.authn.LDAP.dnFormat=%[email protected]
idp.authn.LDAP.dnFormat = uid=%s,ou=RNP,dc=homolog,dc=rnp
# LDAP attribute configuration, see attribute-resolver.xml
idp.attribute.resolver.LDAP.ldapURL = %{idp.authn.LDAP.ldapURL}
idp.attribute.resolver.LDAP.baseDN = %{idp.authn.LDAP.baseDN}
idp.attribute.resolver.LDAP.bindDN = %{idp.authn.LDAP.bindDN}
idp.attribute.resolver.LDAP.bindDNCredential = %{idp.authn.LDAP.bindDNCredential}
idp.attribute.resolver.LDAP.useStartTLS = %{idp.authn.LDAP.useStartTLS:true}
idp.attribute.resolver.LDAP.trustCertificates = %{idp.authn.LDAP.trustCertificates}
idp.attribute.resolver.LDAP.searchFilter = (uid=$requestContext.principalName)
# LDAP pool configuration, used for both authn and DN resolution
#idp.pool.LDAP.minSize = 3
#idp.pool.LDAP.maxSize = 10
#idp.pool.LDAP.validateOnCheckout = false
#idp.pool.LDAP.validatePeriodically = true
#idp.pool.LDAP.validatePeriod = 300
#idp.pool.LDAP.prunePeriod = 300
#idp.pool.LDAP.idleTime = 600
#idp.pool.LDAP.blockWaitTime = 3000
#idp.pool.LDAP.failFastInitialize = false
Agora iremos alterar o valor da variável usada pelo shibboleth (idp.authn.LDAP.userFilter), para executar o critério de consulta no OpenLDAP. Linha 25 do bloco de código abaixo
# LDAP authentication configuration, see authn/ldap-authn-config.xml
## Authenticator strategy, either anonSearchAuthenticator, bindSearchAuthenticator, directAuthenticator, adAuthenticator
#idp.authn.LDAP.authenticator = anonSearchAuthenticator
idp.authn.LDAP.authenticator = bindSearchAuthenticator
## Connection properties ##
idp.authn.LDAP.ldapURL = ldaps://Openldap.homolog.rnp:636
idp.authn.LDAP.useStartTLS = false
idp.authn.LDAP.useSSL = false
idp.authn.LDAP.connectTimeout = 3000
## SSL configuration, either jvmTrust, certificateTrust, or keyStoreTrust
idp.authn.LDAP.sslConfig = certificateTrust
## If using certificateTrust above, set to the trusted certificate's path
idp.authn.LDAP.trustCertificates = %{idp.home}/credentials/ldap-server.crt
## If using keyStoreTrust above, set to the truststore path
idp.authn.LDAP.trustStore = %{idp.home}/credentials/ldap-server.truststore
## Return attributes during authentication
## NOTE: this is not used during attribute resolution; configure that directly in the
## attribute-resolver.xml configuration via a DataConnector's <dc:ReturnAttributes> element
idp.authn.LDAP.returnAttributes = uid
## DN resolution properties ##
# Search DN resolution, used by anonSearchAuthenticator, bindSearchAuthenticator
# for AD: CN=Users,DC=example,DC=org
idp.authn.LDAP.baseDN = ou=RNP,dc=homolog,dc=rnp
idp.authn.LDAP.subtreeSearch = true
idp.authn.LDAP.userFilter = (&(uid={user})(memberof=cn=GRP_SRV_CAFE,ou=GRUPOS,dc=homolog,dc=rnp))
# bind search configuration
# for AD: [email protected]
idp.authn.LDAP.bindDN = uid=leitor-shib,ou=Admins,dc=homolog,dc=rnp
idp.authn.LDAP.bindDNCredential = XXXXXXXX
# Format DN resolution, used by directAuthenticator, adAuthenticator
# for AD use idp.authn.LDAP.dnFormat=%[email protected]
idp.authn.LDAP.dnFormat = uid=%s,ou=RNP,dc=homolog,dc=rnp
# LDAP attribute configuration, see attribute-resolver.xml
idp.attribute.resolver.LDAP.ldapURL = %{idp.authn.LDAP.ldapURL}
idp.attribute.resolver.LDAP.baseDN = %{idp.authn.LDAP.baseDN}
idp.attribute.resolver.LDAP.bindDN = %{idp.authn.LDAP.bindDN}
idp.attribute.resolver.LDAP.bindDNCredential = %{idp.authn.LDAP.bindDNCredential}
idp.attribute.resolver.LDAP.useStartTLS = %{idp.authn.LDAP.useStartTLS:true}
idp.attribute.resolver.LDAP.trustCertificates = %{idp.authn.LDAP.trustCertificates}
idp.attribute.resolver.LDAP.searchFilter = (uid=$requestContext.principalName)
# LDAP pool configuration, used for both authn and DN resolution
#idp.pool.LDAP.minSize = 3
#idp.pool.LDAP.maxSize = 10
#idp.pool.LDAP.validateOnCheckout = false
#idp.pool.LDAP.validatePeriodically = true
#idp.pool.LDAP.validatePeriod = 300
#idp.pool.LDAP.prunePeriod = 300
#idp.pool.LDAP.idleTime = 600
#idp.pool.LDAP.blockWaitTime = 3000
#idp.pool.LDAP.failFastInitialize = false
idp.authn.LDAP.userFilter = (&(uid={user})(mail=*@domínio))
idp.authn.LDAP.userFilter = (|(uid={user})(mail={user}))
Ao final da configuração, você deve salvar as alterações no arquivo e então reiniciar o serviço do tomcat utilizando o seguinte comando:
systemctl restart jetty9.service
Você pode usar o SP da RNP → https://sp.rnp.br/ escolher a opção CAFe e validar a sua configuração tentando um acesso pelo seu IdP.
Last updated
Was this helpful?