> For the complete documentation index, see [llms.txt](https://ajuda.rnp.br/cafe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajuda.rnp.br/cafe/sheerid/procedimentos-complementares/configuracao-do-idp-com-google-workspace.md).

# Configuração do IDP com Google Workspace

Essa página tem como objetivo auxiliar na configuração do seu IDP Shibboleth com a configuração de acesso SSO do Google Workspace.

{% hint style="danger" %}
Atenção !

Substituir a variável $DOMAIN presente no roteiro pelo domínio de sua instituição.                      Exemplo: $DOMAIN por "rnp.br"
{% endhint %}

### Guia passo a passo

{% hint style="info" %}
Durante o processo de configuração em seu IDP com Shibboleth iremos editar e escrever em alguns arquivos, são eles:

*relaying-party.xml*

*saml-nameid.xml*

*attribute-resolver.xml*

*metadata-providers.xml*

*attribute-filter.xml*

Todos eles ficam no mesmo diretório */opt/shibboleth-idp/conf*

Sugiro que seja feito um backup desses arquivos antes de edita-los, caso seja necessário basta voltar ao estado anterior deles para normalizar qualquer problema em seu IDP.
{% endhint %}

Seguir os procedimentos abaixo para a configuração da autenticação federada do Google em seu IdP:

### **Alterar o arquivo "relying-party.xml".**&#x20;

**Dentro da tag  \<util:list id="shibboleth.RelyingPartyOverrides">**

`<util:list` `id="shibboleth.RelyingPartyOverrides">`

`...`  &#x20;

`</util:list>`

**Incluir o código abaixo**

```xml
<bean id="Google" parent="RelyingPartyByName" c:relyingPartyIds="google.com">
   <property name="profileConfigurations">
        <list>
           <bean parent="SAML2.SSO" p:encryptAssertions="false" p:encryptNameIDs="false" />
        </list>
   </property>
</bean>
```

### **Alterar o arquivo "saml-nameid.xml".**&#x20;

**Dentro da tag \<util:list id="shibboleth.SAML2NameIDGenerators">**

```xml
<!-- Release to Google an "emailAddress" NameID with the value of Gprincipal -->
<bean parent="shibboleth.SAML2AttributeSourcedGenerator"
      p:format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
      p:attributeSourceIds="#{ {'Gprincipal'} }">
   <property name="activationCondition">
      <bean parent="shibboleth.Conditions.RelyingPartyId" c:candidate="google.com" />
   </property>
</bean>
```

### **Alterar o arquivo "attribute-resolver.xml.**&#x20;

**Dentro da arquivo de configuração /conf/attribute-resolver.xml criar uma nova definição de atributo iniciando com o seguinte parâmetro \<AttributeDefinition> para gerar o atrbituo "Gprincipal"**

```xml
<AttributeDefinition xsi:type="Template" id="Gprincipal">
   <InputDataConnector ref="dcLDAP" attributeNames="mail" />
   <Template>
      <![CDATA[
         ${mail}
      ]]>
   </Template>
</AttributeDefinition>
```

### **Criar o arquivo de propriedade do atributo Gprincipal.**

Dentro do diretório conf/attributes/custom/ criar o arquivo com o seguinte nome "Gprincipal.properties" e inserir o seguinte conteúdo:

```
# Gprincipal

id=Gprincipal
transcoder=SAML2StringTranscoder
displayName.en=Username Google
displayName.it=Username Google
description.en=Username for Google
description.it=Username usato da Google
saml2.name=urn:oid:0.9.2342.19200300.100.1.3
saml1.encodeType=false
```

### **Criar o arquivo de metadata dentro do diretório /metadata.**

Nessa etapa deve-se criar o arquivo de metadado dentro do diretório do Shibboleth. Para isso use um editor de sua preferência para criar o metadado com o segiunte nome:

google-md.xml

Dentro desse arquivo copiar e colar esse conteúdo:

{% hint style="danger" %}
ATENÇÃO! Essa etapa possui uma alteração no conteúdo abaixo, repare que nesse caso há uma variável "$DOMAIN", você deve substituir pelo domínio configurado na sua autenticação SSO do Google.
{% endhint %}

```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!-- entityID = "google.com" -->
<EntityDescriptor entityID="google.com" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
   <SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
      <NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>
      <AssertionConsumerService index="1" Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://www.google.com/a/$DOMAIN/acs" />
   </SPSSODescriptor>
</EntityDescriptor>
```

### **Alterar o arquivo "metadata-providers.xml".**

**Acrescentar dentro do arquivo /conf/metadata-providers.xml o seguinte conteúdo:**

```xml
<MetadataProvider id="Google”  xsi:type="FilesystemMetadataProvider" metadataFile="%{idp.home}/metadata/google-md.xml"/>
```

### **Alterar o arquivo "attribute-filter.xml".**&#x20;

**Dentro da tag \<AttributeFilterPolicyGroup>**

```
<AttributeFilterPolicy id="releaseToGoogle">
  <PolicyRequirementRule xsi:type="OR">
    <Rule xsi:type="Requester" value="google.com/a/$DOMAIN" />
  </PolicyRequirementRule>
  <AttributeRule attributeID="mail">
    <PermitValueRule xsi:type="ANY" />
  </AttributeRule>
</AttributeFilterPolicy>
```

### **Configurar o arquivo attribute-filter.xml para a liberação de atributo ao SP Google.**

**Dentro do arquivo /conf/attribute-filter.xml inserir a seguinte liberação de regra:**

```xml
<!-- G Suite (Google Apps)  -->
<AttributeFilterPolicy id="google.com">
   <PolicyRequirementRule xsi:type="Requester" value="google.com" />
   <AttributeRule attributeID="Gprincipal">
      <PermitValueRule xsi:type="ANY" />
   </AttributeRule>
</AttributeFilterPolicy>
```

**Após terminar a criação e configuração do metadado do google será necessário reiniciar o serviço do shibboleth, para isso faça:**

```
systemctl restart jetty9.service && tail -f /opt/shibboleth-idp/logs/idp-process.log
```

### Agora, precisamos configurar do lado do Portal Admin do Google for Education&#x20;

![](https://3706451151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M94Z581aPIo4Bzo9ImS%2Fuploads%2F94oPyiFOOcIccIX6bjfw%2FAdmin_console_google.png?alt=media\&token=1ae9cdd7-b72b-412e-a487-3dd41c945489)

**Sign-in page URL:**

<https://shibserver.university.edu/idp/profile/SAML2/Redirect/SSO>

**Sign-out page URL:**

<https://shibserver.university.edu/idp/profile/Logout>

E certifique-se de que “**Use a domain specific issuer**” esteja marcado.

Além disso, esse "**Verificiation certificate**" é seu **idp.crt**

É isso. Depois de concluir o procedimento acima, você deverá ter uma instância do Google Apps for Education em funcionamento, autenticando-se em seu servidor Shibboleth.

{% hint style="warning" %}
Lembrando que é necessário que os usuários que irão acessar o google tenham configurado as suas permissões com acesso administrador ao espaço.

* [x] <https://support.google.com/a/answer/9807615?hl=pt-BR&ref_topic=9832445>
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ajuda.rnp.br/cafe/sheerid/procedimentos-complementares/configuracao-do-idp-com-google-workspace.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
