| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/openid/server/__pycache__/ |
Upload File : |
�
QT�^I � �f � d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlm Z ddl
mZ ddlm
Z
dd lmZmZ dd
lmZmZmZ ddlmZmZmZmZmZmZ ddlmZ ej e� � Z d
Z!dZ"dZ#ddgZ$dZ%dZ&dZ'dZ( G d� de)� � Z* G d� de*� � Z+ G d� de)� � Z, G d� de)� � Z- G d� de-� � Z. G d� de*� � Z/ G d � d!e*� � Z0 G d"� d#e)� � Z1 G d$� d%e)� � Z2 G d&� d'e)� � Z3 G d(� d)e)� � Z4 G d*� d+e4� � Z5 G d,� d-e)� � Z6 G d.� d/e)� � Z7 G d0� d1e8� � Z9 G d2� d3e8� � Z: G d4� d5e8� � Z; G d6� d7e8� � Z< G d8� d9e<� � Z= G d:� d;e9� � Z> G d<� d=e9� � Z? G d>� d?e9� � Z@dS )@a� OpenID server protocol and logic.
Overview
========
An OpenID server must perform three tasks:
1. Examine the incoming request to determine its nature and validity.
2. Make a decision about how to respond to this request.
3. Format the response according to the protocol.
The first and last of these tasks may performed by
the L{decodeRequest<Server.decodeRequest>} and
L{encodeResponse<Server.encodeResponse>} methods of the
L{Server} object. Who gets to do the intermediate task -- deciding
how to respond to the request -- will depend on what type of request it
is.
If it's a request to authenticate a user (a X{C{checkid_setup}} or
X{C{checkid_immediate}} request), you need to decide if you will assert
that this user may claim the identity in question. Exactly how you do
that is a matter of application policy, but it generally involves making
sure the user has an account with your system and is logged in, checking
to see if that identity is hers to claim, and verifying with the user that
she does consent to releasing that information to the party making the
request.
Examine the properties of the L{CheckIDRequest} object, optionally
check L{CheckIDRequest.returnToVerified}, and and when you've come
to a decision, form a response by calling L{CheckIDRequest.answer}.
Other types of requests relate to establishing associations between client
and server and verifying the authenticity of previous communications.
L{Server} contains all the logic and data necessary to respond to
such requests; just pass the request to L{Server.handleRequest}.
OpenID Extensions
=================
Do you want to provide other information for your users
in addition to authentication? Version 2.0 of the OpenID
protocol allows consumers to add extensions to their requests.
For example, with sites using the U{Simple Registration
Extension<http://openid.net/specs/openid-simple-registration-extension-1_0.html>},
a user can agree to have their nickname and e-mail address sent to a
site when they sign up.
Since extensions do not change the way OpenID authentication works,
code to handle extension requests may be completely separate from the
L{OpenIDRequest} class here. But you'll likely want data sent back by
your extension to be signed. L{OpenIDResponse} provides methods with
which you can add data to it which can be signed with the other data in
the OpenID signature.
For example::
# when request is a checkid_* request
response = request.answer(True)
# this will a signed 'openid.sreg.timezone' parameter to the response
# as well as a namespace declaration for the openid.sreg namespace
response.fields.setArg('http://openid.net/sreg/1.0', 'timezone', 'America/Los_Angeles')
There are helper modules for a number of extensions, including
L{Attribute Exchange<openid.extensions.ax>},
L{PAPE<openid.extensions.pape>}, and
L{Simple Registration<openid.extensions.sreg>} in the L{openid.extensions}
package.
Stores
======
The OpenID server needs to maintain state between requests in order
to function. Its mechanism for doing this is called a store. The
store interface is defined in C{L{openid.store.interface.OpenIDStore}}.
Additionally, several concrete store implementations are provided, so that
most sites won't need to implement a custom store. For a store backed
by flat files on disk, see C{L{openid.store.filestore.FileOpenIDStore}}.
For stores based on MySQL or SQLite, see the C{L{openid.store.sqlstore}}
module.
Upgrading
=========
From 1.0 to 1.1
---------------
The keys by which a server looks up associations in its store have changed
in version 1.2 of this library. If your store has entries created from
version 1.0 code, you should empty it.
From 1.1 to 2.0
---------------
One of the additions to the OpenID protocol was a specified nonce
format for one-way nonces. As a result, the nonce table in the store
has changed. You'll need to run contrib/upgrade-store-1.1-to-2.0 to
upgrade your store, or you'll encounter errors about the wrong number
of columns in the oid_nonces table.
If you've written your own custom store or code that interacts
directly with it, you'll need to review the change notes in
L{openid.store.interface}.
@group Requests: OpenIDRequest, AssociateRequest, CheckIDRequest,
CheckAuthRequest
@group Responses: OpenIDResponse
@group HTTP Codes: HTTP_OK, HTTP_REDIRECT, HTTP_ERROR
@group Response Encodings: ENCODE_KVFORM, ENCODE_HTML_FORM, ENCODE_URL
� N)�deepcopy)� cryptutil)�oidutil)�kvform)�
DiffieHellman)�mkNonce)� TrustRoot�verifyReturnTo)�Association�default_negotiator�
getSecretSize)�Message�InvalidOpenIDNamespace� OPENID_NS�
OPENID2_NS�IDENTIFIER_SELECT�OPENID1_URL_LIMIT)�urinorm�� i. i� �
checkid_setup�checkid_immediate)zURL/redirect)z HTML formc � � e Zd ZdZdZdS )�
OpenIDRequestzxI represent an incoming OpenID request.
@cvar mode: the C{X{openid.mode}} of this request.
@type mode: str
N)�__name__�
__module__�__qualname__�__doc__�mode� � �6/usr/lib/python3/dist-packages/openid/server/server.pyr r � s � � � � � �� �
�D�D�Dr r c �L � e Zd ZdZdZg d�Zd d�Zeefd�� � Z d� Z
d� ZdS )
�CheckAuthRequestan A request to verify the validity of a previous response.
@cvar mode: "X{C{check_authentication}}"
@type mode: str
@ivar assoc_handle: The X{association handle} the response was signed with.
@type assoc_handle: str
@ivar signed: The message with the signature which wants checking.
@type signed: L{Message}
@ivar invalidate_handle: An X{association handle} the client is asking
about the validity of. Optional, may be C{None}.
@type invalidate_handle: str
@see: U{OpenID Specs, Mode: check_authentication
<http://openid.net/specs.bml#mode-check_authentication>}
�check_authentication)�identity� return_to�response_nonceNc �H � || _ || _ || _ t | _ dS )a Construct me.
These parameters are assigned directly as class attributes, see
my L{class documentation<CheckAuthRequest>} for their descriptions.
@type assoc_handle: str
@type signed: L{Message}
@type invalidate_handle: str
N)�assoc_handle�signed�invalidate_handler � namespace)�selfr) r* r+ s r! �__init__zCheckAuthRequest.__init__� s&