HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/eks/__pycache__/get_token.cpython-36.opt-1.pyc
3

�T_��@s�ddlZddlZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZdZ
dZd	Zd
ZdZdZd
ZdZGdd�de
�ZGdd�de�ZGdd�de�ZdS)�N)�datetime�	timedelta)�
RequestSigner)�	ServiceId)�BasicCommand)�	uni_print�stsZGetCallerIdentityz
2011-06-15Zv4�<�zk8s-aws-v1.zx-k8s-aws-idc@s<eZdZdZdZdddd�ddd	d�gZd
d�Zdd
�ZdS)�GetTokenCommandz	get-tokenz{Get a token for authentication with an Amazon EKS cluster. This can be used as an alternative to the aws-iam-authenticator.zcluster-namezASpecify the name of the Amazon EKS cluster to create a token for.T)�nameZ	help_textZrequiredzrole-arnz8Assume this role for credentials when signing the token.FcCstj�ttd�}|jd�S)N)Zminutesz%Y-%m-%dT%H:%M:%SZ)rZutcnowr�TOKEN_EXPIRATION_MINSZstrftime)�self�token_expiration�r�/usr/lib/python3.6/get_token.py�get_expiration_time;sz#GetTokenCommand.get_expiration_timecCsbt|j�}|j|j|jd�}t|�j|j�}|j�}ddi||d�d�}t	t
j|��t	d�dS)N)�region_name�role_arnZExecCredentialz%client.authentication.k8s.io/v1alpha1)ZexpirationTimestamp�token)ZkindZ
apiVersion�specZstatus�
r)�STSClientFactory�_session�get_sts_clientZregionr�TokenGenerator�	get_token�cluster_namerr�json�dumps)rZparsed_argsZparsed_globalsZclient_factory�
sts_clientrrZfull_objectrrr�	_run_main?s

zGetTokenCommand._run_mainN)�__name__�
__module__�__qualname__�NAMEZDESCRIPTIONZ	ARG_TABLErr!rrrrr's
rc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs
||_dS)N)�_sts_client)rr rrr�__init__[szTokenGenerator.__init__cCs.|j|�}ttj|jd��jd�jd�}|S)z4 Generate a presigned url token to pass to kubectl. zutf-8�=)�_get_presigned_url�TOKEN_PREFIX�base64Zurlsafe_b64encode�encode�decode�rstrip)rrZurlrrrrr^s
zTokenGenerator.get_tokencCs|jjdd|itdd�S)NZget_caller_identity�ClusterNameZGET)ZParamsZ	ExpiresInZ
HttpMethod)r&Zgenerate_presigned_url�URL_TIMEOUT)rrrrrr)es
z!TokenGenerator._get_presigned_urlN)r"r#r$r'rr)rrrrrZsrc@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs
||_dS)N)r)rZsessionrrrr'oszSTSClientFactory.__init__NcCs\d|i}|dk	r@|j||�}|d|d<|d|d<|d|d<|jjd	|�}|j|�|S)
NrZAccessKeyIdZaws_access_key_idZSecretAccessKeyZaws_secret_access_keyZSessionTokenZaws_session_tokenr)r)�_get_role_credentialsr�
create_client�_register_cluster_name_handlers)rrrZ
client_kwargsZcredsrrrrrrs
zSTSClientFactory.get_sts_clientcCs |jjd|�}|j|dd�dS)NrZEKSGetTokenAuth)ZRoleArnZRoleSessionNameZCredentials)rr2Zassume_role)rrrrrrrr1s
z&STSClientFactory._get_role_credentialscCs(|jjjd|j�|jjjd|j�dS)Nz+provide-client-params.sts.GetCallerIdentityz!before-sign.sts.GetCallerIdentity)�metaZevents�register�_retrieve_cluster_name�_inject_cluster_name_header)rr rrrr3�sz0STSClientFactory._register_cluster_name_handlerscKsd|kr|jd�|d<dS)Nr/�eks_cluster)�pop)rZparams�context�kwargsrrrr6�sz'STSClientFactory._retrieve_cluster_namecKsd|jkr|jd|jt<dS)Nr8)r:Zheaders�CLUSTER_NAME_HEADER)rZrequestr;rrrr7�s
z,STSClientFactory._inject_cluster_name_header)NN)	r"r#r$r'rr1r3r6r7rrrrrns


r)r+ZbotocorerrrZbotocore.signersrZbotocore.modelrZawscli.customizations.commandsrZawscli.customizations.utilsrZAUTH_SERVICEZAUTH_COMMANDZAUTH_API_VERSIONZAUTH_SIGNING_VERSIONr0r
r*r<r�objectrrrrrr�<module>
s$3