o
    Df                     @   sT   d dl Z d dlmZmZmZmZ d dlmZmZ G dd deZ	G dd deZ
dS )    N)ColumnStringTextInteger)
TokenMixinAuthorizationCodeMixinc                   @   s   e Zd ZeeddddZeedZeeddZeeddZ	eeddZ
eeZeeddd	 d
ZeeZeedZdd Zdd Zdd Zdd Zdd ZdS )OAuth2AuthorizationCodeMixinx   TFuniquenullable0    defaultc                   C      t t S Ninttime r   r   g/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/integrations/sqla_oauth2/tokens_mixins.py<lambda>       z%OAuth2AuthorizationCodeMixin.<lambda>r   r   c                 C   s   | j d t k S )Ni,  )	auth_timer   selfr   r   r   
is_expired   s   z'OAuth2AuthorizationCodeMixin.is_expiredc                 C      | j S r   )redirect_urir   r   r   r   get_redirect_uri      z-OAuth2AuthorizationCodeMixin.get_redirect_uric                 C   r   r   scoper   r   r   r   	get_scope   r"   z&OAuth2AuthorizationCodeMixin.get_scopec                 C   r   r   )r   r   r   r   r   get_auth_time!   r"   z*OAuth2AuthorizationCodeMixin.get_auth_timec                 C   r   r   )noncer   r   r   r   	get_nonce$   r"   z&OAuth2AuthorizationCodeMixin.get_nonceN)__name__
__module____qualname__r   r   code	client_idr   r    response_typer$   r'   r   r   code_challengecode_challenge_methodr   r!   r%   r&   r(   r   r   r   r   r   	   s$    r   c                   @   s   e Zd ZeedZeedZeeddddZeedddZee	dd	Z
eedd
d dZeedddZeedddZeedddZdd Zdd Zdd Zdd Zdd ZdS )OAuth2TokenMixinr   (      TFr
   )indexr   r   c                   C   r   r   r   r   r   r   r   r   /   r   zOAuth2TokenMixin.<lambda>r   r   c                 C   s   | j | kS r   )r-   get_client_id)r   clientr   r   r   check_client5   s   zOAuth2TokenMixin.check_clientc                 C   r   r   r#   r   r   r   r   r%   8   r"   zOAuth2TokenMixin.get_scopec                 C   r   r   )
expires_inr   r   r   r   get_expires_in;   r"   zOAuth2TokenMixin.get_expires_inc                 C   s   | j p| jS r   )access_token_revoked_atrefresh_token_revoked_atr   r   r   r   
is_revoked>   s   zOAuth2TokenMixin.is_revokedc                 C   s"   | j sdS | j| j  }|t k S )NF)r8   	issued_atr   )r   
expires_atr   r   r   r   A   s   zOAuth2TokenMixin.is_expiredN)r)   r*   r+   r   r   r-   
token_typeaccess_tokenrefresh_tokenr   r$   r   r=   r:   r;   r8   r7   r%   r9   r<   r   r   r   r   r   r1   (   s"    
r1   )r   
sqlalchemyr   r   r   r   authlib.oauth2.rfc6749r   r   r   r1   r   r   r   r   <module>   s
    