لغو پیوند حساب ها، لغو پیوند حساب ها

لغو پیوند می‌تواند از پلتفرم شما یا گوگل آغاز شود و نمایش وضعیت پیوند ثابت در هر دو، بهترین تجربه کاربری را فراهم می‌کند. پشتیبانی از نقطه پایانی ابطال توکن یا محافظت متقابل حساب برای پیوند حساب گوگل اختیاری است.

حساب‌ها می‌توانند به دلایل زیر از هم جدا شوند:

  • درخواست کاربر از
    • یک برنامه گوگل یا تنظیمات حساب گوگل
    • پلتفرم شما
  • عدم تمدید توکن به‌روزرسانی منقضی‌شده
  • سایر رویدادهایی که توسط شما یا گوگل آغاز شده‌اند. به عنوان مثال، تعلیق حساب توسط سرویس‌های تشخیص سوءاستفاده و تهدید.

کاربر درخواست لغو لینک از گوگل را داد

لغو اتصال حساب که از طریق حساب گوگل یا برنامه کاربر آغاز می‌شود، هرگونه توکن دسترسی و به‌روزرسانی که قبلاً صادر شده است را حذف می‌کند، رضایت کاربر را حذف می‌کند و در صورت تمایل، در صورت تمایل، نقطه پایانی لغو توکن شما را فراخوانی می‌کند.

کاربر درخواست لغو لینک از پلتفرم شما را داده است

شما باید مکانیزمی برای لغو پیوند کاربران فراهم کنید، مانند یک URL به حساب کاربری‌شان. اگر راهی برای لغو پیوند کاربران ارائه نمی‌دهید، پیوندی به حساب گوگل قرار دهید تا کاربران بتوانند حساب پیوند شده خود را مدیریت کنند.

شما می‌توانید از قابلیت به اشتراک‌گذاری و همکاری در برابر ریسک و حادثه (RISC) استفاده کنید و گوگل را از تغییرات وضعیت لینک حساب کاربری مطلع کنید. این کار باعث بهبود تجربه کاربری می‌شود، به طوری که هم پلتفرم شما و هم گوگل، وضعیت لینک فعلی و ثابتی را بدون نیاز به تکیه بر به‌روزرسانی یا درخواست توکن دسترسی برای به‌روزرسانی وضعیت لینک، نشان می‌دهند.

انقضای توکن

برای ارائه یک تجربه کاربری روان و جلوگیری از اختلال در سرویس، گوگل تلاش می‌کند تا توکن‌های به‌روزرسانی را در نزدیکی پایان عمرشان تمدید کند. در برخی موارد، ممکن است رضایت کاربر برای اتصال مجدد حساب‌ها در صورت عدم دسترسی به توکن به‌روزرسانی معتبر، لازم باشد.

طراحی پلتفرم شما برای پشتیبانی از چندین توکن دسترسی و به‌روزرسانی منقضی نشده می‌تواند شرایط رقابتی موجود در تبادلات کلاینت-سرور بین محیط‌های خوشه‌ای را به حداقل برساند، از اختلال کاربر جلوگیری کند و سناریوهای پیچیده زمان‌بندی و مدیریت خطا را به حداقل برساند. در حالی که در نهایت سازگار هستند، توکن‌های منقضی نشده قبلی و جدید صادر شده ممکن است برای مدت کوتاهی در طول تبادل تمدید توکن کلاینت-سرور و قبل از همگام‌سازی خوشه‌ای مورد استفاده قرار گیرند. به عنوان مثال، یک درخواست گوگل به سرویس شما که از توکن دسترسی منقضی نشده قبلی استفاده می‌کند، درست پس از صدور یک توکن دسترسی جدید توسط شما، اما قبل از دریافت و همگام‌سازی خوشه‌ای در گوگل، رخ می‌دهد. اقدامات امنیتی جایگزین برای چرخش توکن به‌روزرسانی توصیه می‌شود.

رویدادهای دیگر

حساب‌ها می‌توانند به دلایل مختلف دیگری مانند عدم فعالیت، تعلیق، رفتار مخرب و غیره از هم جدا شوند. در چنین سناریوهایی، پلتفرم شما و گوگل می‌توانند با اطلاع‌رسانی به یکدیگر در مورد تغییرات در حساب و وضعیت پیوند، به بهترین شکل حساب‌های کاربری را مدیریت کرده و دوباره به هم متصل شوند.

یک نقطه پایانی ابطال توکن برای فراخوانی توسط گوگل پیاده‌سازی کنید و با استفاده از RISC، رویدادهای ابطال توکن خود را به گوگل اطلاع دهید تا از حفظ وضعیت پیوند حساب کاربری سازگار بین پلتفرم و گوگل اطمینان حاصل شود.

نقطه پایانی ابطال توکن

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.

محافظت از حساب‌های کاربری متقابل (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).