
    +                         d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ dZdZe	j*                   G d de	j,                               Zy)zCommand to create a login configuration file used to enable browser based sign-in using third-party user identities via gcloud auth login.
    )absolute_import)division)unicode_literalsN)base)cred_config)log)
properties)universe_descriptor)fileszlogin configuration filezcloud.googlec                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)CreateLoginConfiga?  Create a login configuration file to enable sign-in via a web-based authorization flow using Workforce Identity Federation.

  This command creates a configuration file to enable browser based
  third-party sign in with Workforce Identity Federation through
  `gcloud auth login --login-config=/path/to/config.json`.
  EXAMPLESz          To create a login configuration for your project, run:

            $ {command} locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID --output-file=login-config.json
          c                     |j                  dd       |j                  ddd       |j                  dd	d
d       |j                  ddd	d       |j                  ddd       |j                  ddd       y )Naudiencez&Workforce pool provider resource name.)helpz--output-filez9Location to store the generated login configuration file.T)r   requiredz
--activate
store_trueFzSets the property `auth/login_config_file` to the created login configuration file. Calling `gcloud auth login` will automatically use this login configuration unless it is explicitly unset.)actiondefaultr   z--enable-mtlszUse mTLS for STS endpoints.)r   r   hiddenz--universe-domainzThe universe domain.)r   r   z--universe-cloud-web-domainzThe universe cloud web domain.)add_argument)clsparsers     6lib/surface/iam/workforce_pools/create_login_config.pyArgszCreateLoginConfig.Args8   s     A   H   !  
 *	   #  
 %-      c                    t         j                  j                  j                  }|j	                         }t        |dd       r|j                  }||j                  k(  rt        }nGt        |dd       r|j                  }n-t        j                         j	                  |      j                  }t        |dd      }t        j                  ||      }||dd|j                  z   dj                  |	      |j                   |j"                  d
}t%        j&                  |j(                  t+        j,                  |d             t/        j0                  |j(                  t2               |j4                  r`t        j6                  t         j                  j8                  j:                  t<        j>                  jA                  |j(                               y y )Nuniverse_domainuniverse_cloud_web_domainenable_mtlsF)r    r   -external_account_authorized_user_login_configz//iam.googleapis.com/z)https://auth.{cloud_web_domain}/authorize)cloud_web_domain)r   r   typer   auth_url	token_urltoken_info_url   )indent)!r	   VALUEScorer   Getgetattrr   GOOGLE_DEFAULT_CLOUD_WEB_DOMAINr   r
   UniverseDescriptorr"   r   StsEndpointsr   formatoauth_token_urlr&   r   WriteFileContentsoutput_filejsondumpsr   CreatedResourceRESOURCE_TYPEactivatePersistPropertyauthlogin_config_fileospathabspath)selfargsuniverse_domain_propertyr   r   r    token_endpoint_builderoutputs           r   RunzCreateLoginConfig.Run`   s   )0055EE.224Ot&-,,o
 2:::"A	2D	9"&"@"@ 
0
0
23   $u5K(55 +%>?+dmm;?FF6 G 
 ,;;0??
F 
D,,djj.JK((-8}}  



 
 
2
2
''//$**
+ r   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpclassmethodr   rD    r   r   r   r   &   s@     
(//  - % %N/r   r   )rH   
__future__r   r   r   r4   r<   rI   googlecloudsdk.callioper   .googlecloudsdk.command_lib.iam.byoid_utilitiesr   googlecloudsdk.corer   r	   'googlecloudsdk.core.universe_descriptorr
   googlecloudsdk.core.utilr   r7   r-   UniverseCompatibleCreateCommandr   rM   r   r   <module>rV      sg    '  '  	  ( F # * G * +"0  h** h hr   