Lo scollegamento può essere avviato dalla tua piattaforma o da Google e la visualizzazione di uno stato di collegamento coerente su entrambe offre la migliore esperienza utente. Il supporto di un endpoint di revoca dei token o della Protezione su più account è facoltativo per il collegamento dell'Account Google.
Gli account possono essere scollegati per uno dei seguenti motivi:
- Richiesta utente da
- un'applicazione Google o le impostazioni dell'Account Google
- La tua piattaforma
- Impossibilità di rinnovare un token di aggiornamento scaduto
- Altri eventi avviati da te o da Google. Ad esempio, la sospensione dell'account da parte dei servizi di rilevamento di abusi e minacce.
L'utente ha richiesto lo scollegamento da Google
Lo scollegamento dell'account avviato tramite l'Account Google o l'app di un utente elimina tutti i token di accesso e aggiornamento emessi in precedenza, rimuove il consenso dell'utente e chiama facoltativamente l'endpoint di revoca dei token se hai scelto di implementarne uno.
L'utente ha richiesto lo scollegamento dalla tua piattaforma
Devi fornire un meccanismo per consentire agli utenti di scollegare, ad esempio un URL al loro account. Se non offri un modo per scollegare gli account, includi un link all'Account Google in modo che gli utenti possano gestire il proprio account collegato.
Puoi scegliere di implementare la condivisione e la collaborazione in caso di rischi e incidenti (RISC) e notificare a Google le modifiche allo stato di collegamento dell'account utente. Ciò consente un'esperienza utente migliorata in cui sia la tua piattaforma sia Google mostrano uno stato di collegamento attuale e coerente senza la necessità di fare affidamento su una richiesta di aggiornamento o token di accesso per aggiornare lo stato del collegamento.
Scadenza del token
Per offrire un'esperienza utente ottimale ed evitare interruzioni del servizio, Google tenta di rinnovare i token di aggiornamento verso la fine del loro ciclo di vita. In alcuni scenari, potrebbe essere necessario il consenso dell'utente per ricollegare gli account quando non è disponibile un token di aggiornamento valido.
La progettazione della piattaforma per supportare più token di accesso e aggiornamento non scaduti può ridurre al minimo le race condition presenti negli scambi client-server tra ambienti in cluster, evitare interruzioni per gli utenti e ridurre al minimo scenari complessi di gestione di tempi e gestione degli errori. Sebbene alla fine coerenti, sia i token precedenti che quelli appena emessi e non scaduti potrebbero essere in uso per un breve periodo di tempo durante lo scambio di rinnovi dei token client-server e prima della sincronizzazione del cluster. Ad esempio, una richiesta di Google al tuo servizio che utilizza il token di accesso precedente non scaduto si verifica subito dopo l'emissione di un nuovo token di accesso, ma prima che la ricezione e la sincronizzazione del cluster avvengano in Google. Sono consigliate misure di sicurezza alternative a Refresh Token Rotation.
Altri eventi
Gli account possono essere scollegati per vari altri motivi, ad esempio inattività, sospensione, comportamento dannoso e così via. In questi scenari, la tua piattaforma e Google possono gestire al meglio gli account utente e ricollegarli notificandosi a vicenda le modifiche allo stato dell'account e del collegamento.
Implementa un endpoint di revoca dei token da chiamare per Google e comunica a Google gli eventi di revoca dei token utilizzando RISC per garantire che la tua piattaforma e Google mantengano uno stato di collegamento dell'account utente coerente.
Endpoint di revoca del token
If you support an OAuth 2.0 token revocation endpoint, your platform can receive notifications from Google. This lets you inform users of link state changes, invalidate a token, and cleanup security credentials and authorization grants.
The request has the following form:
POST /revoke HTTP/1.1 Host: oauth2.example.com Content-Type: application/x-www-form-urlencoded client_id=GOOGLE_CLIENT_ID&client_secret=GOOGLE_CLIENT_SECRET&token=TOKEN&token_type_hint=refresh_token
Your token revocation endpoint must be able to handle the following parameters:
| Revocation endpoint parameters | |
|---|---|
client_id |
A string that identifies the request origin as Google. This string must be registered within your system as Google's unique identifier. |
client_secret |
A secret string that you registered with Google for your service. |
token |
The token to be revoked. |
token_type_hint |
(Optional) The type of token being revoked, either an
access_token or refresh_token. If unspecified,
defaults to access_token. |
Return a response when the token is deleted or invalid. See the following for an example:
HTTP/1.1 200 Success Content-Type: application/json;charset=UTF-8
If the token can't be deleted for any reason, return a 503 response code, as shown in the following example:
HTTP/1.1 503 Service Unavailable Content-Type: application/json;charset=UTF-8 Retry-After: HTTP-date / delay-seconds
Google retries the request later or as requested by Retry-After.
Protezione su più account (RISC)
If you support Cross-Account Protection, your platform can notify Google when access or refresh tokens are revoked. This allows Google to inform users of link state changes, invalidate the token, cleanup security credentials, and authorization grants.
Cross-Account Protection is based on the RISC standard developed at the OpenID Foundation.
A Security Event Token is used to notify Google of token revocation.
When decoded, a token revocation event looks like the following example:
{
"iss":"http://risc.example.com",
"iat":1521068887,
"aud":"google_account_linking",
"jti":"101942095",
"toe": "1508184602",
"events": {
"https://schemas.openid.net/secevent/oauth/event-type/token-revoked":{
"subject_type": "oauth_token",
"token_type": "refresh_token",
"token_identifier_alg": "hash_SHA512_double",
"token": "double SHA-512 hash value of token"
}
}
}
Security Event Tokens that you use to notify Google of token revocation events must conform to the requirements in the following table:
| Token revocation events | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
iss |
Issuer Claim: This is a URL which you host, and it's shared with Google during registration. | ||||||||||
aud |
Audience Claim: This identifies Google as the JWT recipient. It
must be set to google_account_linking. |
||||||||||
jti |
JWT ID Claim: This is a unique ID that you generate for every security event token. | ||||||||||
iat |
Issued At Claim: This is a NumericDate value
that represents the time when this security event token was created. |
||||||||||
toe |
Time of Event Claim: This is an optional
NumericDate value that represents the time at which the
token was revoked. |
||||||||||
exp |
Expiration Time Claim: Do not include this field, as the event resulting in this notification has already taken place. | ||||||||||
events |
|
||||||||||
For more information on field types and formats, see JSON Web Token (JWT).