HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/eks/__pycache__/get_token.cpython-310.pyc
o

.&�a��@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�sts�GetCallerIdentityz
2011-06-15�v4�<�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)�name�	help_text�requiredzrole-arnz8Assume this role for credentials when signing the token.FcCst��ttd�}|�d�S)N)�minutesz%Y-%m-%dT%H:%M:%SZ)r�utcnowr�TOKEN_EXPIRATION_MINS�strftime)�self�token_expiration�r�E/usr/lib/python3/dist-packages/awscli/customizations/eks/get_token.py�get_expiration_time;s
z#GetTokenCommand.get_expiration_timecCsbt|j�}|j|j|jd�}t|��|j�}|��}ddi||d�d�}t	t
�|��t	d�dS)N)�region_name�role_arn�ExecCredentialz%client.authentication.k8s.io/v1alpha1)�expirationTimestamp�token)�kind�
apiVersion�spec�status�
r)�STSClientFactory�_session�get_sts_client�regionr�TokenGenerator�	get_token�cluster_namerr�json�dumps)r�parsed_args�parsed_globals�client_factory�
sts_clientrr�full_objectrrr�	_run_main?s"
���
zGetTokenCommand._run_mainN)�__name__�
__module__�__qualname__�NAME�DESCRIPTION�	ARG_TABLErr2rrrrr
's���
r
c@s$eZdZdd�Zdd�Zdd�ZdS)r(cC�
||_dS�N)�_sts_client�rr0rrr�__init__[�
zTokenGenerator.__init__cCs.|�|�}tt�|�d���d��d�}|S)z4 Generate a presigned url token to pass to kubectl. zutf-8�=)�_get_presigned_url�TOKEN_PREFIX�base64�urlsafe_b64encode�encode�decode�rstrip)rr*�urlrrrrr)^s
��zTokenGenerator.get_tokencCs|jjdd|itdd�S)N�get_caller_identity�ClusterName�GET)�Params�	ExpiresIn�
HttpMethod)r;�generate_presigned_url�URL_TIMEOUT)rr*rrrr@es�z!TokenGenerator._get_presigned_urlN)r3r4r5r=r)r@rrrrr(Zsr(c@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)r$cCr9r:)r%)r�sessionrrrr=or>zSTSClientFactory.__init__NcCs`d|i}|dur |�||�}|d|d<|d|d<|d|d<|jjd	i|��}|�|�|S)
Nr�AccessKeyId�aws_access_key_id�SecretAccessKey�aws_secret_access_key�SessionToken�aws_session_tokenr)r)�_get_role_credentialsr%�
create_client�_register_cluster_name_handlers)rrr�
client_kwargs�credsrrrrr&rs�
zSTSClientFactory.get_sts_clientcCs |j�d|�}|j|dd�dS)Nr�EKSGetTokenAuth)�RoleArn�RoleSessionName�Credentials)r%rX�assume_role)rrrrrrrrWs��z&STSClientFactory._get_role_credentialscCs(|jj�d|j�|jj�d|j�dS)Nz+provide-client-params.sts.GetCallerIdentityz!before-sign.sts.GetCallerIdentity)�meta�events�register�_retrieve_cluster_name�_inject_cluster_name_headerr<rrrrY�s��z0STSClientFactory._register_cluster_name_handlerscKsd|vr
|�d�|d<dSdS)NrI�eks_cluster)�pop)r�params�context�kwargsrrrrd�s�z'STSClientFactory._retrieve_cluster_namecKs"d|jvr|jd|jt<dSdS)Nrf)ri�headers�CLUSTER_NAME_HEADER)r�requestrjrrrre�s
���z,STSClientFactory._inject_cluster_name_header)NN)	r3r4r5r=r&rWrYrdrerrrrr$ns


r$)rB�botocorer+rr�botocore.signersr�botocore.modelr�awscli.customizations.commandsr�awscli.customizations.utilsr�AUTH_SERVICE�AUTH_COMMAND�AUTH_API_VERSION�AUTH_SIGNING_VERSIONrOrrArlr
�objectr(r$rrrr�<module>s&3