pdc authentication manager
Project description
PDC AUTH
PDC Authentication Manager
Installation
Installation: To install from PyPI use:
$ python -m pip install pdc-auth
After installation, import with something like:
import pdc_auth as pdca
Configure Endpoint
Before using authenticator configure the endpoint first. Enpoint by default has url "http://localhost:4000" and path "/v2/login". If method get_host()
called will return "http://localhost:4000/v2/login". Configure to get a custom host.
from pdc_auth.endpoint import EndpointConfig, configure_endpoint
url = "www.myendpoint.com"
path = "/v1/auth"
configure_endpoint(url, path)
endpoint = EndpointConfig()
endpoint.get_host() # www.myendpoint.com/v1/auth
Create Config File
By default the configuration file path is "data/config.json". Path can be customized as desired by adding parameters to the authenticator later. However the configuration file must be json
and include fields like below.
{
"lisensi": {
"email": "myemail@custom.com",
"pwd": "secret"
}
}
Authenticator
Authenticator is used to check the login to the endpoint according to the previous configuration. With the appropriate email and password listed in the configuration. When the login()
function is called checking for an error in the login returns an error. If the login is successful it will return the value True
.
from pdc_auth.authenticator import Authenticator
from pdc_auth.exceptions.login_provider_exc import LoginProviderFailedException
config_fname="config/lisensi.json"
authenticator = Authenticator(config_fname=config_fname) # config_fname by default is: "data/config.json"
try:
authenticator.login()
except LoginProviderFailedException as e:
pass
Custom Login Provider
Customizing the provider on the login authenticator.
from pdc_auth.authenticator import Authenticator
from pdc_auth.exceptions.login_provider_exc import LoginProviderFailedException
from pdc_auth.login_provider import LoginProvider
provider = LoginProvider()
authenticator = Authenticator(provider=provider)
try:
authenticator.login()
except LoginProviderFailedException as e:
pass
Some of the data that can be customized on the provider are as follows:
- Custom Bot
from pdc_auth.login_provider import LoginProvider
bot_id = 10
version = '3.0.0'
provider = LoginProvider(bot_id=bot_id, version=version)
or
from pdc_auth.login_provider import LoginProvider
bot_id = 10
version = '3.0.0'
latest_version = '3.0.18'
provider = LoginProvider()
provider.update_bot(bot_id=bot_id, version=version, latest_version=latest_version)
- Custom Headers
from pdc_auth.login_provider import LoginProvider
custom_headers = { "X-Secret-Key": "secret" }
provider = LoginProvider()
provider.update_headers(custom_headers)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pdc-auth-0.2.1.tar.gz
.
File metadata
- Download URL: pdc-auth-0.2.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95baff02a5522d2638b122b6cdbdd50f39b5d7a81d6a8c34d85c3a0417d2e929 |
|
MD5 | 6bce96c6c513b021a091e9ec81dad1ac |
|
BLAKE2b-256 | 10c040115f7bade6122015edeb3aa4db8d1466a50d2b7cc31600309f11f75046 |
File details
Details for the file pdc_auth-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: pdc_auth-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7f444dd680f1776a5d7c378bc33b6b466adb2a12d4f0a8f573d36bc0cca6be |
|
MD5 | d5f11eb286f65162de0f7c2cde1ebe1f |
|
BLAKE2b-256 | 4d4b64a08e1b14ebbd52fb35943a4559094bdcb31c1d017154d43c2f68b48c54 |