Lo scollegamento può essere avviato dalla tua piattaforma o da Google e la visualizzazione di un stato del collegamento coerente su entrambe le piattaforme offre la migliore esperienza utente. Il supporto di un endpoint di revoca del 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 dell'utente da
- un'applicazione Google o le impostazioni di un Account Google
- La tua piattaforma
- Mancata riattivazione di un token di aggiornamento scaduto
- Altri eventi avviati da te o da Google. Ad esempio, la sospensione dell'account da parte di servizi di rilevamento di abusi e minacce.
L'utente ha richiesto lo scollegamento da Google
Lo scollegamento dell'account avviato tramite l'app o l'Account Google di un utente elimina tutti i token di accesso e aggiornamento emessi in precedenza, rimuove il consenso dell'utente e, facoltativamente, chiama l'endpoint di revoca del 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 l'account, ad esempio un URL al loro account. Se non offri un modo per scollegare gli utenti, includi un link all'Account Google in modo che possano gestire il proprio account collegato.
Puoi scegliere di implementare la funzionalità di condivisione e collaborazione per rischi e incidenti (RISC) e di notificare a Google le modifiche allo stato di collegamento degli account utente. In questo modo, si ottiene un'esperienza utente migliorata in cui sia la tua piattaforma sia Google mostrano uno stato di collegamento aggiornato e coerente senza dover fare affidamento su un aggiornamento o una richiesta di token di accesso per aggiornare lo stato del collegamento.
Scadenza del token
Per offrire un'esperienza utente senza problemi ed evitare interruzioni del servizio, Google tenta di rinnovare i token di aggiornamento verso la fine della loro durata. In alcuni scenari, potrebbe essere necessario il consenso dell'utente per ricollegare gli account quando non è disponibile un token di aggiornamento valido.
Progettare la piattaforma in modo da supportare più token di accesso e aggiornamento non scaduti può ridurre al minimo le condizioni di gara presenti negli scambi client-server tra ambienti clusterizzati, evitare interruzioni per gli utenti e ridurre al minimo scenari complessi di temporizzazione e gestione degli errori. Sebbene siano eventualmente 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 rinnovo 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 della ricezione e della sincronizzazione del cluster da parte di Google. Sono consigliate misure di sicurezza alternative alla rotazione dei token di aggiornamento.
Altri eventi
Gli account possono essere scollegati per vari altri motivi, come inattività, sospensione, comportamento dannoso e così via. In questi scenari, la tua piattaforma e Google possono gestire al meglio gli account utente e ricollegarsi tramite notifica reciproche delle modifiche agli stati dell'account e del collegamento.
Implementa un endpoint di revoca del token che Google possa chiamare e informare Google dei tuoi eventi di revoca del token utilizzando RISC per garantire che la tua piattaforma e Google mantengano uno stato del 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).