Nb. d dl Z d dlZd dlmZ d dlmZmZ d dlmZ dZ dZ
d Zd Zd Z
dd
Zd Zd Zd
ZddZ ddZd ZdS ) N)web)AbstractIdentityPolicyAbstractAuthorizationPolicywraps aiohttp_security_identity_policyaiohttp_security_autz_policyc K t |t s
J | |sJ | j t }|d}t j || |j | ||fi | d{V dS )zRemember identity into response.
The action is performed by identity_policy.remember()
Usually the identity is stored in user cookies somehow but may be
pushed into custom header also.
NMSecurity subsystem is not initialized, call aiohttp_security.setup(...) firstreasontext)
isinstancestrconfig_dictgetIDENTITY_KEYr HTTPInternalServerErrorremember)requestresponseidentitykwargsidentity_policyr s f/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/aiohttp_security/api.pyr r s h$$..h..$OO8)--l;;O9
)DAAAA
"/
"7Hh
I
I&
I
IIIIIIIIII c K | j t }|d}t j || | | | d{V dS )z|Forget previously remembered identity.
Usually it clears cookie or server-side storage to forget user
session.
Nr r )r r r r r forget)r r r r s r r r ! sq )--l;;O9
)DAAAA
(
3
3333333333r c K | j t }| j t }||d S | | d {V }|d S | | d {V }|S N)r r r AUTZ_KEYidentifyauthorized_userid)r r autz_policyr user_ids r r# r# 2 s )--l;;O%))(33K+"5t$--g66666666Ht11(;;;;;;;;GNr c ` K t |t t j f s
J | |sJ | j t }| j t }||dS | | d {V }| ||| d {V }|S )NT)
r r enumEnumr r r r! r" permits)r
permissioncontextr r$ r accesss r r) r) > s j3 "233??Z??3:)--l;;O%))(33K+"5t$--g66666666H&&xWEE
E
E
E
E
E
EFMr c K | j t }|dS | | d{V }|dS dS )zkCheck if user is anonymous.
User is considered anonymous if there is not identity
in request.
NTF)r r r r" )r r r s r is_anonymousr. K s^ )--l;;Ot$--g66666666Ht5r c ^ K t | d{V }|t j |S )z>Checker that raises HTTPUnauthorized for anonymous users.
N)r# r HTTPUnauthorized)r userids r check_authorizedr2 Z s@ %W--
-
-
-
-
-
-F
~"$$$Mr c p t fd }t j dt |S )zDecorator that restrict access only for authorized users.
User is considered authorized if authorized_userid
returns some value.
c K | d }t |t j sd}t | t | d {V | i | d {V S Nz\Incorrect decorator usage. Expecting `def handler(request)` or `def handler(self, request)`.)r r BaseRequestRuntimeErrorr2 )argsr r msgfns r wrappedzlogin_required.