
    f                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr	  SSK
Jr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\R0                  5      rS rg)z.Revoke credentials being used by the CloudSDK.    )absolute_import)division)unicode_literalsN)base)
exceptions)	auth_util)config)log)
properties)creds)store)resource_printerc                   4    \ rS rSrSr\S 5       rS rS rSr	g)Revoke$   a  Revoke access credentials for an account.

Revokes credentials for the specified user accounts, service accounts or
external accounts (workload identity pools).

When given a user account, this command revokes the user account token on the
server. If the revocation is successful, or if the token has already been
revoked, this command removes the credential from the local machine.

When given a service account, this command does not revoke the service account
token on the server because service account tokens are not revocable. Instead,
it will print a warning and remove the credential from the local machine. When
used with a service account, this command has only a local effect and the key
associated with the service account is not deleted. This can be done by
executing `gcloud iam service-accounts keys delete` after `revoke`.

When given an external account (workload identity pool), whether impersonated
or not, the command does not revoke the corresponding token on the server
because these tokens are not revocable. The underlying external credentials
(OIDC, AWS, etc.) used to generate these access tokens have to be revoked too,
but gcloud has no control over that. Instead, it will print a warning and
remove the credential from the local machine.

If no account is specified, this command revokes credentials for the currently
active account, effectively logging out of that account. If --all is given,
the behaviors described above apply individually to each account in the list.

You can revoke credentials when you want to prevent gcloud and other Google
Cloud CLI tools from using the specified account. You do not need to revoke
credentials to switch between accounts.
c                 ~    U R                  SSSS9  U R                  SSSS9  U R                  R                  S	5        g )
Naccounts*z-Accounts whose credentials are to be revoked.)nargshelpz--all
store_truez$Revoke credentials for all accounts.)actionr   z"list[title="Revoked credentials:"])add_argumentdisplay_info	AddFormat)parsers    lib/surface/auth/revoke.pyArgsRevoke.ArgsE   sM    

#L  N
C  E
!!"FG    c                 T   UR                   =(       d    / n[        U[        5      (       a  U/n[        R                  " 5       n[        U5      [        U5      -
  nU(       a&  [        R                  " SSR                  U5      5      eUR                  (       a  Un[        R                  R                  R                  R                  5       nU(       d
  U(       a  U/nU(       d  [        R                  " SS5      eSnU GH|  nXW:X  a9  [        R                   " [        R                  R                  R                  S5         [        R"                  " USSS9n[        R(                  " U5      (       Gd  UR+                  S5      (       a'  [,        R.                  " S	R1                  U5      5        M  [2        R4                  " U5      (       a'  [,        R.                  " S
R1                  U5      5        M  [2        R6                  " U5      (       d  [2        R8                  " U5      (       a(  [,        R.                  " SR1                  U5      5        GMR  [,        R.                  " SR1                  U5      5        GMz  SnGM     [;        U5        U$ ! [$        R&                   a    Sn GNNf = f)z-Revoke credentials and update active account.r    z#No credentials available to revoke.FNT)prevent_refreshuse_google_authz.gserviceaccount.comac  [{}] appears to be a service account. Service account tokens cannot be revoked, but they will expire automatically. To prevent use of the service account token earlier than the expiration, delete or disable the parent service account. To explicitly delete the key associated with the service account use `gcloud iam service-accounts keys delete` instead`.zv[{}] appears to be an external account. External account tokens cannot be revoked, but they will expire automatically.z[{}] appears to be an external account user. External account user tokens cannot be revoked, but they will expire automatically.z+[{}] already inactive (previously revoked?))r   
isinstancestrc_storeAvailableAccountssetc_excUnknownArgumentExceptionjoinallr   VALUEScoreaccountGetInvalidArgumentExceptionPersistPropertyLoadcreds_exceptionsErrorr   endswithr
   warningformatc_credsIsExternalAccountCredentials IsExternalAccountUserCredentials*IsExternalAccountAuthorizedUserCredentials_WarnIfRevokeAndADCExists)	selfargsr   available_accountsunknown_accountsactive_accountcreds_revokedr0   r   s	            r   Run
Revoke.RunM   s"   }}"H(C  h 2248}s+='>>**
chh/02 2xx#h&&++33779N !h**
;= = M		""":#4#4#9#9#A#A4HT4A ^^G$$233
++H
 IOI 11%88
++Nvg  55 HHOO
++%vg0
 ++;BB7KM U X m,OC ##  s   JJ'&J'c                     [         R                  " 5       n[        R                  " [         R                  [
        R                  S9nUR                  U5        g )N)out)r'   AllAccountsr   PrinterACCOUNT_TABLE_FORMATr
   statusPrint)r?   unused_results_were_displayedr   printers       r   EpilogRevoke.Epilog   s=    ""$H&&$$#**G MM(r     N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   rE   rP   __static_attributes__rR   r    r   r   r   $   s*    @ H HFPr    r   c                     U (       aj  [         R                  R                  [        R                  " 5       5      (       a2  [
        R                  " 5       (       a  [        R                  " S5        g g g g )NaH  You also have Application Default Credentials (ADC) set up. If you want to revoke your Application Default Credentials as well, use the `gcloud auth application-default revoke` command.

For information about ADC credentials and gcloud CLI credentials, see https://cloud.google.com/docs/authentication/external/credential-types
)	ospathisfiler	   ADCFilePathr   ADCIsUserAccountr
   r8   )rD   s    r   r>   r>      sL    v'9'9';<<  ""KK	 # =mr    )rW   
__future__r   r   r   r[   googlecloudsdk.callioper   r   r*   googlecloudsdk.command_lib.authr   googlecloudsdk.corer	   r
   r   googlecloudsdk.core.credentialsr   r:   r5   r   r'   googlecloudsdk.core.resourcer   Commandr   r>   rR   r    r   <module>rg      sL     5 &  ' 	 ( 7 5 & # * < J < 9vT\\ vr	r    