websauna.system.user.interfaces module¶
Define various interfaces telling how user subsystem objects interact and can be looked up from registry.
-
exception
websauna.system.user.interfaces.
AuthenticationFailure
[source]¶ Bases:
Exception
The user is not allowed to log in.
-
exception
websauna.system.user.interfaces.
CannotResetPasswordException
[source]¶ Bases:
Exception
Password reset is disabled for this user e.g. due to disabled account.
-
interface
websauna.system.user.interfaces.
IActivationModel
[source]¶ Bases:
zope.interface.Interface
Register utility registration which marks active Activation SQLAlchemy model class.
-
interface
websauna.system.user.interfaces.
IAuthomatic
[source]¶ Bases:
zope.interface.Interface
Mark Authomatic instance in the registry.
-
interface
websauna.system.user.interfaces.
ICredentialActivityService
[source]¶ Bases:
zope.interface.Interface
User password and activation related activities.
TODO: Interface not described yet, see
websauna.system.user.credentialactivityservice.DefaultCredentialActivityService
.
-
interface
websauna.system.user.interfaces.
IForgotPasswordForm
[source]¶ Bases:
zope.interface.Interface
Deform form used for Forgot password form.
-
interface
websauna.system.user.interfaces.
IForgotPasswordSchema
[source]¶ Bases:
zope.interface.Interface
Colander schema used for Forgot password form.
-
interface
websauna.system.user.interfaces.
IGroup
[source]¶ Bases:
zope.interface.Interface
User group.
Usually SQLAlchemy model instance of
websauna.system.user.usermixin.GroupMixin
but can be any object.-
name
= <zope.interface.interface.Attribute object at 0x1084fbc50 websauna.system.user.interfaces.IGroup.name>¶ Then name of the group
-
-
interface
websauna.system.user.interfaces.
IGroupModel
[source]¶ Bases:
zope.interface.Interface
Register utility registration which marks active Group SQLAlchemy model class.
-
interface
websauna.system.user.interfaces.
ILoginForm
[source]¶ Bases:
zope.interface.Interface
Deform form used for sign in form.
-
interface
websauna.system.user.interfaces.
ILoginSchema
[source]¶ Bases:
zope.interface.Interface
Colander schema used for sign in form.
-
interface
websauna.system.user.interfaces.
ILoginService
[source]¶ Bases:
zope.interface.Interface
A service that is responsible for handling normal website facing log in actions.
This service is responsible to
Set up logged in session
Do post login actions like redirects
Use
websauna.system.user.utils.get_login_service()
to get access to configured login service.-
authenticate_credentials
(username, login_source, password, location=None)¶ Logs in the user.
This is called after the user credentials have been validated.
Sets the auth cookies and redirects to a post login page, which defaults to a view named ‘index’.
Fills in user last login time and IP data..
- Parameters
request – Current request
user – Default login service is designed to work with UserMixin compatible user classes
location – Override the redirect page. If none use
websauna.login_redirect
. TODO - to be changed.login_source – Application specific string telling where the login come from. E.g. “social_media”, “signup”, “login_form”.
- Raises
AuthenticationFailure – If the password does not match or user is disabled
-
authentication_user
(user, login_source, location=None)¶ Make the current session logged in session for this particular user.
A password check is not performed. However it is checked if user is active and such.
- Parameters
location – Override the redirect page. If none use
websauna.login_redirect
. TODO - to be changed.login_source – Application specific string telling where the login come from. E.g. “social_media”, “signup”, “login_form”.
- Raises
AuthenticationFailure – If the user is disabled
-
logout
(location=None)¶ Log out user from the site.
Terminate session
Show logged out message
Redirect the user to post login page
-
interface
websauna.system.user.interfaces.
IOAuthLoginService
[source]¶ Bases:
zope.interface.Interface
A login service for federated authentication.
See
websauna.system.interfaces.ILoginService
.Use
websauna.system.user.utils.get_oauth_login_service()
to get access to configured login service.-
handle_request
(provider_name)¶ Handle all requests coming to login/facebook, login/twitter etc. endpoints.
Login form does an empty HTTP POST request to initiate OAuth process
Federated authentication service does HTTP GET redirect when they accept OAuth authentication request
-
-
interface
websauna.system.user.interfaces.
IPasswordHasher
[source]¶ Bases:
zope.interface.Interface
A utility for hashing passwords.
Used by
websauna.system.models.usermixin.UserMixin._set_password()
.-
hash_password
(plain_text)¶ Generate a hash presentation for plain text password.
This is to be stored in database.
- Returns
A hasher internal string format. Usually contains number of cycles, hashed password and salt string.
-
verify_password
(hashed_password, plain_text)¶ Verify a password.
Compare if inputed password matches one stored in the dabase.
- Returns
True if the password matches, False otherwise.
-
-
interface
websauna.system.user.interfaces.
IRegisterForm
[source]¶ Bases:
zope.interface.Interface
Deform form used for sign upform.
-
interface
websauna.system.user.interfaces.
IRegisterSchema
[source]¶ Bases:
zope.interface.Interface
Colander schema used for sign upform.
-
interface
websauna.system.user.interfaces.
IRegistrationService
[source]¶ Bases:
zope.interface.Interface
Sign up form service.
TODO: Interface not described yet, see
websauna.system.user.registrationservice.DefaultRegistrationService
.
-
interface
websauna.system.user.interfaces.
IResetPasswordForm
[source]¶ Bases:
zope.interface.Interface
Deform form used for Reset password form.
-
interface
websauna.system.user.interfaces.
IResetPasswordSchema
[source]¶ Bases:
zope.interface.Interface
Colander schema used for Reset password form.
-
interface
websauna.system.user.interfaces.
ISiteCreator
[source]¶ Bases:
zope.interface.Interface
Utility that is responsible to create the initial site.
-
interface
websauna.system.user.interfaces.
ISocialLoginMapper
[source]¶ Bases:
zope.interface.Interface
Named marker interface to look up social login mappers.
Extract social media information from the Authomatic login result in order to associate the user account.
Map incoming social network data to internal data structure.
Sometimes social networks change how the data is presented over API and you might need to do some wiggling to get it a proper shape you wish to have.
The resulting dict must be JSON serializable as it is persisted as is.
- Parameters
user – Authomatic user.
- Returns
Dict representation of the user.
Set the initial data on the user model.
When the user logs in from a social network for the first time (no prior logins with this email before) we fill in blanks in the user model with incoming data.
Default action is not to set any items.
- Parameters
user – User object.
data – Normalized data.
-
interface
websauna.system.user.interfaces.
IUser
[source]¶ Bases:
zope.interface.Interface
User.
Usually SQLAlchemy model instance of
websauna.system.user.usermixin.UserMixin
.Hard requirements for User interface listed here - this is what Websauna default frontend expects from an user instance.
websauna.system.user.interfaces.ILoginService
must know some user implementation details.-
friendly_name
= <zope.interface.interface.Attribute object at 0x1084fbbe0 websauna.system.user.interfaces.IUser.friendly_name>¶ How we present the user’s name to the user itself. Usually. Picks one of 1) full name if set 2) username if set 3) email.
-
-
interface
websauna.system.user.interfaces.
IUserModel
[source]¶ Bases:
zope.interface.Interface
Register utility registration which marks active User SQLAlchemy model class.
-
interface
websauna.system.user.interfaces.
IUserRegistry
[source]¶ Bases:
zope.interface.Interface
Manage creation and querying of users.
Allow abstraction over the user backend - do not assume users are stored in the primary database.
TODO: Interface not described yet, see
websauna.system.user.userregistry.DefaultEmailBasedUserRegistry
.