Welcome to Pacifica Authentication’s documentation!¶
The Pacifica Authentication library provides Pacifica Core services a consistent authentication configuration and APIs.
Installation¶
The Pacifica software is available through PyPi so creating a virtual environment to install is what is shown below. Please keep in mind compatibility with the Pacifica Core services.
Installation in Virtual Environment¶
These installation instructions are intended to work on both Windows, Linux, and Mac platforms. Please keep that in mind when following the instructions.
Please install the appropriate tested version of Python for maximum chance of success.
Linux and Mac Installation¶
mkdir ~/.virtualenvs
python -m virtualenv ~/.virtualenvs/pacifica
. ~/.virtualenvs/pacifica/bin/activate
pip install pacifica-auth
Windows Installation¶
This is done using PowerShell. Please do not use Batch Command.
mkdir "$Env:LOCALAPPDATA\virtualenvs"
python.exe -m virtualenv "$Env:LOCALAPPDATA\virtualenvs\pacifica"
& "$Env:LOCALAPPDATA\virtualenvs\pacifica\Scripts\activate.ps1"
pip install pacifica-auth
Configuration¶
The configuration of Pacifica Authentication is done on the command line using arguments passed to services that incorporate the library.
Authentication Options¶
These are common command line switches when Pacifica services include the authentication library.
Session Directory --session-dir
¶
Default is sessions
and contains the user sessions managed by the
core service.
Database URL --db-url
¶
Default is sqlite:///database.sqlite3
and is the SQLAlchemy engine
connection url
Social Auth Class --social-class
¶
Python Social Auth class name from the module in the --social-module
name.
Social Auth Settings --social-setting
¶
Python Social Auth settings are passed as to CherryPy configrations. Examples are the following:
pacifica-service \
--social-setting=github_key=<GitHub OAuth Key> \
--social-setting=github_secret=<GitHub OAuth Secret>
Application Directory --app-dir
¶
This is optional as some Pacifica services don’t serve applications to users. This can serve both ReactJS or Swagger-UI as example applications.
Example Usage¶
Need to have good example application.
Authentication Python Module¶
Application Python Module¶
Base application module.
-
pacifica.auth.application.
check_sa_module_class
(sa_path, sa_module, sa_class)[source]¶ Check the combination of module and class.
-
pacifica.auth.application.
command_setup
(argv, description, user_class, user_import_path, config_callback=None, parser_callback=None)[source]¶ Common setup for commands to execute.
-
pacifica.auth.application.
create_argparser
(description, parser_callback=None)[source]¶ Create the argparser and return it.
-
pacifica.auth.application.
create_configparser
(args: argparse.Namespace, config_callback=None)[source]¶ Create the config parser and return it calling callback if given.
-
pacifica.auth.application.
error_page_default
(**kwargs)[source]¶ Error page when something goes wrong.
-
pacifica.auth.application.
pacifica_auth_arguments
(parser)[source]¶ Add Pacifica authentication command line arguments.
-
pacifica.auth.application.
quickstart
(argv, description, user_class, user_import_path, swagger_path, config_callback=None, parser_callback=None)[source]¶ Simple wrapper around cherrypy quickstart.
Setup the social settings for pacifica auth.
Root CherryPy Python Module¶
Root class to handle social auth.
SAPlugin Python Module¶
CherryPy plugin to manage SQLAlchemy session connection.
SATool Python Module¶
CherryPy Social Auth Tools to setup database connections.
SQLAlchemy User Model Python Module¶
Example user model for consumers to use.
-
class
pacifica.auth.user_model.
Base
(**kwargs)¶ The most base type
-
__init__
(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
metadata
= MetaData()¶
-
registry
= <sqlalchemy.orm.decl_api.registry object>¶
-
-
class
pacifica.auth.user_model.
User
(**kwargs)[source]¶ Example SQLAlchemy User Model.
-
__init__
(**kwargs)¶ A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_sa_class_manager
= {'active': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'email': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'password': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'username': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'uuid': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}¶
-
active
¶
-
email
¶
-
id
¶
-
name
¶
-
password
¶
-
username
¶
-
uuid
¶
-
Pacifica Authentication Module.
-
pacifica.auth.
quickstart
(argv, description, user_class, user_import_path, swagger_path, config_callback=None, parser_callback=None)[source]¶ Simple wrapper around cherrypy quickstart.
-
pacifica.auth.
command_setup
(argv, description, user_class, user_import_path, config_callback=None, parser_callback=None)[source]¶ Common setup for commands to execute.
Social Auth Module
--social-module
¶Python Social Auth backends Python module name. The module name is relative to
social_core.backends
.