3 ,['0@sdZddlmZmZddlmZmZmZmZm Z m Z m Z m Z ddl mZddlmZddlmZdd lmZdd lmZGd d d eeeeZGd ddeeeeZGdddeeeZGdddeeeZGdddeeeZdS)z oauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. )absolute_importunicode_literals)AuthCodeGrantDispatcherAuthorizationCodeGrantClientCredentialsGrant ImplicitGrantOpenIDConnectAuthCodeOpenIDConnectImplicitRefreshTokenGrant%ResourceOwnerPasswordCredentialsGrant) BearerToken)AuthorizationEndpoint)ResourceEndpoint)RevocationEndpoint) TokenEndpointc@seZdZdZdddZdS)Serverz  zServer.__init__)NNN)__name__ __module__ __qualname____doc__r"r0r0r0r1rsrc@seZdZdZdddZdS)WebApplicationServerzLAn all-in-one endpoint featuring Authorization code grant and Bearer tokens.Nc Kspt|}t|}t||||}tj|dd|i|dtj|d||d|dtj|dd|idtj||dS) aConstruct a new web application server. :param request_validator: An implementation of oauthlib.oauth2.RequestValidator. :param token_expires_in: An int or a function to generate a token expiration offset (in seconds) given a oauthlib.common.Request object. :param token_generator: A function to generate a token from a request. :param refresh_token_generator: A function to generate a token from a request for the refresh token. :param kwargs: Extra parameters to pass to authorization-, token-, resource-, and revocation-endpoint constructors. r)rrrr)rr)rrrr)r r!N)rr r rr"rrr) r#r$r&r%r'r)r*r.r/r0r0r1r"[s zWebApplicationServer.__init__)NNN)r2r3r4r5r"r0r0r0r1r6Vsr6c@seZdZdZdddZdS)MobileApplicationServerzGAn all-in-one endpoint featuring Implicit code grant and Bearer tokens.NcKsVt|}t||||}tj|dd|i|dtj|dd|idtj||dgddS)aConstruct a new implicit grant server. :param request_validator: An implementation of oauthlib.oauth2.RequestValidator. :param token_expires_in: An int or a function to generate a token expiration offset (in seconds) given a oauthlib.common.Request object. :param token_generator: A function to generate a token from a request. :param refresh_token_generator: A function to generate a token from a request for the refresh token. :param kwargs: Extra parameters to pass to authorization-, token-, resource-, and revocation-endpoint constructors. r)rrrr)r r! access_token)supported_token_typesN)rr rr"rr)r#r$r&r%r'r)r+r/r0r0r1r"s z MobileApplicationServer.__init__)NNN)r2r3r4r5r"r0r0r0r1r7|sr7c@seZdZdZdddZdS)LegacyApplicationServerz]An all-in-one endpoint featuring Resource Owner Password Credentials grant and Bearer tokens.Nc KsZt|}t|}t||||}tj|d||d|dtj|dd|idtj||dS)a Construct a resource owner password credentials grant server. :param request_validator: An implementation of oauthlib.oauth2.RequestValidator. :param token_expires_in: An int or a function to generate a token expiration offset (in seconds) given a oauthlib.common.Request object. :param token_generator: A function to generate a token from a request. :param refresh_token_generator: A function to generate a token from a request for the refresh token. :param kwargs: Extra parameters to pass to authorization-, token-, resource-, and revocation-endpoint constructors. r)rr)rrrr)r r!N)r r r rr"rr) r#r$r&r%r'r)r,r.r/r0r0r1r"s z LegacyApplicationServer.__init__)NNN)r2r3r4r5r"r0r0r0r1r:sr:c@seZdZdZdddZdS)BackendApplicationServerzLAn all-in-one endpoint featuring Client Credentials grant and Bearer tokens.NcKsVt|}t||||}tj|dd|i|dtj|dd|idtj||dgddS)aConstruct a client credentials grant server. :param request_validator: An implementation of oauthlib.oauth2.RequestValidator. :param token_expires_in: An int or a function to generate a token expiration offset (in seconds) given a oauthlib.common.Request object. :param token_generator: A function to generate a token from a request. :param refresh_token_generator: A function to generate a token from a request for the refresh token. :param kwargs: Extra parameters to pass to authorization-, token-, resource-, and revocation-endpoint constructors. r)rrrr)r r!r8)r9N)rr rr"rr)r#r$r&r%r'r)r-r/r0r0r1r"s z!BackendApplicationServer.__init__)NNN)r2r3r4r5r"r0r0r0r1r;sr;N)r5Z __future__rrrrrrrr r r r tokensr Z authorizationrZresourcerZ revocationrrrrr6r7r:r;r0r0r0r1s"(     >% #