Rozłączanie kont

Rozłączenie może zostać zainicjowane na Twojej platformie lub w Google, a wyświetlanie spójnego stanu połączenia na obu platformach zapewnia użytkownikom największą wygodę. Obsługa punktu końcowego unieważniania tokena lub Ochrony wszystkich kont jest opcjonalna w przypadku połączenia konta Google.

Konta mogą zostać odłączone z jednego z tych powodów:

  • Prośba użytkownika z domeny
    • aplikacji Google lub ustawień konta Google.
    • Twoja platforma
  • Nie udało się odnowić wygasłego tokena odświeżania
  • inne wydarzenia zainicjowane przez Ciebie lub Google. Na przykład zawieszenie konta przez usługi wykrywające nadużycia i zagrożenia.

Użytkownik poprosił o odłączenie od Google

Odłączenie konta zainicjowane przez użytkownika na jego koncie Google lub w aplikacji powoduje usunięcie wszystkich wcześniej wydanych tokenów dostępu i odświeżania, cofnięcie zgody użytkownika i opcjonalne wywołanie punktu końcowego unieważniania tokena (jeśli został on zaimplementowany).

Użytkownik poprosił o odłączenie od Twojej platformy

Udostępnij użytkownikom mechanizm rozłączania kont, np. adres URL do ich konta. Jeśli nie oferujesz użytkownikom możliwości odłączenia konta, umieść link do konta Google, aby mogli zarządzać połączonym kontem.

Możesz wdrożyć funkcję udostępniania informacji o ryzyku i incydentach oraz współpracy (RISC) i powiadamiać Google o zmianach stanu powiązania konta użytkownika. Pozwala to zapewnić lepsze wrażenia użytkownika, ponieważ zarówno Twoja platforma, jak i Google wyświetlają aktualny i spójny stan połączenia bez konieczności odświeżania ani wysyłania prośby o token dostępu w celu zaktualizowania stanu połączenia.

Wygaśnięcie tokena

Aby zapewnić użytkownikom wygodę i uniknąć przerw w działaniu usługi, Google próbuje odnowić tokeny odświeżania pod koniec ich okresu ważności. W niektórych przypadkach może być wymagana zgoda użytkownika na ponowne połączenie kont, gdy nie jest dostępny ważny token odświeżania.

Zaprojektowanie platformy tak, aby obsługiwała wiele niewygasłych tokenów dostępu i tokenów odświeżania, może zminimalizować sytuacje wyścigu występujące w wymianie danych między klientem a serwerem w środowiskach klastrowych, uniknąć zakłóceń w działaniu użytkownika oraz zminimalizować złożone scenariusze związane z czasem i obsługą błędów. Chociaż ostatecznie są one spójne, zarówno poprzednie, jak i nowo wydane niewygasłe tokeny mogą być używane przez krótki czas podczas wymiany tokenów między klientem a serwerem i przed synchronizacją klastra. Na przykład żądanie Google do Twojej usługi, które korzysta z poprzedniego niewygasłego tokena dostępu, następuje tuż po wydaniu przez Ciebie nowego tokena dostępu, ale przed otrzymaniem i synchronizacją klastra w Google. Zalecane są alternatywne zabezpieczenia, takie jak rotacja tokena odświeżania.

Inne zdarzenia

Konta mogą zostać odłączone z różnych powodów, np. z powodu braku aktywności, zawieszenia, szkodliwego zachowania itp. W takich przypadkach Twoja platforma i Google mogą najlepiej zarządzać kontami użytkowników i ponownie je łączyć, informując się nawzajem o zmianach stanu konta i połączenia.

Wdróż punkt końcowy unieważniania tokena, do którego Google może wysyłać wywołania, i powiadamiaj Google o zdarzeniach unieważniania tokena za pomocą RISC, aby zapewnić spójność stanu połączenia konta użytkownika na Twojej platformie i w Google.

Punkt końcowy cofnięcia tokena

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.

Ochrona wszystkich kont (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
Security Events Claim: This is a JSON object, and must include only a single token revocation event.
subject_type This must be set to oauth_token.
token_type This is the type of token being revoked, either access_token or refresh_token.
token_identifier_alg This is the algorithm used to encode the token, and it must be hash_SHA512_double.
token This is the ID of the revoked token.

For more information on field types and formats, see JSON Web Token (JWT).