Current Dir: /snap/core22/2437/usr/lib/python3/dist-packages/oauthlib/openid/connect/core/endpoints/__pycache__/
[FILE] pre_configured.cpython-310.pyc [ edit | delete | rename ]
[FILE] userinfo.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]
Viewing: /snap/core22/2437/usr/lib/python3/dist-packages/oauthlib/openid/connect/core/endpoints/__pycache__/userinfo.cpython-310.pyc
o
���a � @ sf d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ e�e
�ZG dd� de�ZdS ) z�
oauthlib.openid.connect.core.endpoints.userinfo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module is an implementation of userinfo endpoint.
� N)�Request)�errors)�BaseEndpoint�catch_errors_and_unavailability)�BearerTokenc @ s. e Zd ZdZdd� Zed
dd��Zdd � ZdS )�UserInfoEndpointz,Authorizes access to userinfo resource.
c C s$ t |d d d �| _|| _t�| � d S )N)r �bearer�request_validatorr �__init__)�selfr � r �Q/usr/lib/python3/dist-packages/oauthlib/openid/connect/core/endpoints/userinfo.pyr
s zUserInfoEndpoint.__init__�GETNc C s� t ||||�}dg|_| �|� | j�|�}|du r&t�d|� tjdd��t |t
�rEddi}d|vr?t�d |� tjdd��t�|�}nt |t
�rQdd
i}|}nt�d|� tjdd��t�d|� ||d
fS )ap Validate BearerToken and return userinfo from RequestValidator
The UserInfo Endpoint MUST return a
content-type header to indicate which format is being returned. The
content-type of the HTTP response MUST be application/json if the
response body is a text JSON object; the response body SHOULD be encoded
using UTF-8.
�openidNz!Userinfo MUST have claims for %r.i� )�status_codezContent-Typezapplication/json�subz Userinfo MUST have "sub" for %r.zapplication/jwtz(Userinfo return unknown response for %r.zUserinfo access valid for %r.�� )r �scopes�validate_userinfo_requestr �get_userinfo_claims�log�errorr �ServerError�
isinstance�dict�json�dumps�str�debug)r �uri�http_method�body�headers�request�claims�resp_headersr r r
�create_userinfo_response s,
�
�
z)UserInfoEndpoint.create_userinfo_responsec C s* | j �|�s
t�� �d|jvrt�� �dS )a� Ensure the request is valid.
5.3.1. UserInfo Request
The Client sends the UserInfo Request using either HTTP GET or HTTP
POST. The Access Token obtained from an OpenID Connect Authentication
Request MUST be sent as a Bearer Token, per Section 2 of OAuth 2.0
Bearer Token Usage [RFC6750].
It is RECOMMENDED that the request use the HTTP GET method and the
Access Token be sent using the Authorization header field.
The following is a non-normative example of a UserInfo Request:
GET /userinfo HTTP/1.1
Host: server.example.com
Authorization: Bearer SlAV32hkKG
5.3.3. UserInfo Error Response
When an error condition occurs, the UserInfo Endpoint returns an Error
Response as defined in Section 3 of OAuth 2.0 Bearer Token Usage
[RFC6750]. (HTTP errors unrelated to RFC 6750 are returned to the User
Agent using the appropriate HTTP status code.)
The following is a non-normative example of a UserInfo Error Response:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token",
error_description="The Access Token expired"
r N)r �validate_requestr �InvalidTokenErrorr �InsufficientScopeError)r r# r r r
r B s
�z*UserInfoEndpoint.validate_userinfo_request)r NN)�__name__�
__module__�__qualname__�__doc__r
r r&