Middleware to intercept JWT auth token and more utils functions
Project description
JSM User JWT Service
Middleware to intercept JWT auth token and more utils functions
Install
pip install jsm-user-services
Add jsm_user_services
to your INSTALLED_APPS
:
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"jsm_user_services",
"app_test",
]
Add the Middleware:
MIDDLEWARE = [
...
"jsm_user_services.middleware.JsmJwtService",
]
# Dev url
USER_API_HOST="http://a430a8ff19f7411e9879d0ad999a381f-5028c72b56d78b59.elb.us-east-1.amazonaws.com/api/v1"
Use
from jsm_user_services.services.user import current_jwt_token
from jsm_user_services.services.user import get_jsm_token
from jsm_user_services.services.user import get_jsm_user_data_from_jwt
from jsm_user_services.services.user import get_ltm_token
from jsm_user_services.services.user import get_user_email_from_jwt
from jsm_user_services.services.user import get_user_id_from_jwt
from jsm_user_services.services.user import get_user_data_from_server
from jsm_user_services.services.user import get_user_data_from_cpf
from jsm_user_services.services.user import get_cpf_from_jwt
current_jwt_token()
"""
Response example:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTY1ODc4MjI4LCJqdGkiOiJiZDFmMzBiMGEzMTc0MmRmYjk3MTBiMzEzMTY0M2E2ZiIsInl1bnRpYW5kdSI6IjhyR0NjVHZGTE9VemR2LWRhTFk4SzdHZTF2MmVyQS01TWJOVkZ4TFBwTUNDTmRwTjQ2bDlJMHZFNG9aTmNNanRfZTh5SWJkTlczN0tKRUhWdzM3dmJjOEdLZmlfd0ZmZDJTRDlIYUJuNk80SVVabWVNUjlROVRqVTd0WFI1WDZPeFoyRDRiNXNHSWlKWGQwcGtPcXptOFpFSUl2Y2xtLUNuMjVJMklKNGJ2M2RaeTVtQUhqUnhaTmNMM2RyX1NkX1FGTFpVMWthNmtfQ0FFTkZxOE9CR1RoelNlRmtxeDFfTFBDLXE1dUVC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ugQwiLxp6e4Ew"
"""
get_ltm_token()
"""
Response example:
"b51yreTQ3_4l2Z7zGsEb7UCosv-xulOtzkfflxsxTwrbOYva7loVGhxHmD6Qv5P0x5enm3LuykiAOGvf9fjDkr7qUETk5_OPONonkw1roSwHBpCCjS_IiGWdk2t2mpR4o-SFKMPfKyATzQQkBi886wMJ5g8Sg7GJNaQBHimbHDoWsvSF4zZhMin3IkD-3aVruS3IpBM6-72f4mabCB2kbtRQfTfjU5BvMYYKQzEp79_AWHbUm34gpgh5OJEt9VynHVb0Wzj-_M5sNl8uzEEQ0kixlWyueha2e5gZPHPA2TiSb0dt4WdBUqSL9BPXpsCB9TBtyRkU6JeH-DXo05Px02joOUh_MrjqhbXxYtJXWTkX4E6krHI1kS2r75DFU3dUTfQtELrvn1lQxpNCG_FAX0gB5B_XMWiX2Pn6hWE-QO9uglJgnkllxwhBBiwC1K57ony1tgpZLPY7kapAQveGmJAgWAkFXKtR2s4DK9Bkz_Xz-dUdZRONlBIH6yP4QotiE58QT0DFEluRMXhQX6huPSKuVnyaGLRrbFxdocUPuVgLTigg4rk9zgXX-GmOdHD5sxvC-cd8OWep0r7Pn5URwIdkWFjY_vly8dQDb3Cx2TXx2lXQeXBlj4XwQNlrAJTBGdmnL-Nu6Sk3oyh1_r-u53JyaF4frbt8Q6ZZsNAeZtRNLvM3l1JJ591XpApteouRRFakC6Iu8ED3IRmuzYvCgajDIDede7vtpsBvEp4yxl0"
"""
get_jsm_user_data_from_jwt()
"""
Response example:
{
"email": "64722338612@loyaltyJSM.com",
"unique_name": "Test User",
"website": "ClientApplication",
"uid": "8735bf8d-5479-4448-83cf-89997d7df608",
"sellers": "1e3b831f-95d0-41a7-b3e1-1fe03fae2046",
"role": "Customer",
"cnpjs": "68.597.280/0001-09",
"nbf": 1561558635,
"exp": 1562163435,
"iat": 1561558635,
"iss": "tfp://identity.jsm/authority",
"aud": "bc051de3-aeaa-4ac9-8fbf-05a86e083fcf"
}
"""
get_user_email_from_jwt()
"""
Response example:
"64722338612@loyaltyJSM.com"
"""
get_user_id_from_jwt()
"""
Response example:
"85071dde-b568-41af-a579-3f42c1df0998"
"""
get_user_data_from_server()
"""
Response example:
{
"id": "85071dde-b568-41af-a579-3f42c1df0998",
"username": "44444444444",
"cpf": "44444444444",
"occupation": "owner",
"name": "ca1bd09f-b109-435f-b6d5-206d28a3e5e2",
"birthday": "1990-06-15",
"phones": [{"number": "5511111111111", "type": "MOBILE"}],
"emails": [{"email": "fernando@gmail.com", "type": "PERSONAL"}],
"roles": ["Proprietário"],
"gender": "male",
"allow_contact": True,
"mediums": ["SMS", "Push"],
"rules_agreement": True,
"addresses": [
{
"postal_code": "06763180",
"street": "Rua Adolfino Arruda Castanho",
"number": "200",
"complement": "Ap 133",
"district": "Jardim Bom Tempo",
"city": "Taboao da Serra",
"state": "SP",
"country": "Brazil",
"type": "HOME",
}
]
}
"""
get_user_data_from_cpf(cpf)
"""
Response example:
{
"pageIndex": 1,
"pageSize": 20,
"items": [
"id": "85071dde-b568-41af-a579-3f42c1df0998",
"username": "44444444444",
"cpf": "44444444444",
"occupation": "owner",
"name": "ca1bd09f-b109-435f-b6d5-206d28a3e5e2",
"birthday": "1990-06-15",
"phones": [{"number": "5511111111111", "type": "MOBILE"}],
"emails": [{"email": "fernando@gmail.com", "type": "PERSONAL"}],
"roles": ["Proprietário"],
"gender": "male",
"allow_contact": True,
"mediums": ["SMS", "Push"],
"rules_agreement": True,
"addresses": [
{
"postal_code": "06763180",
"street": "Rua Adolfino Arruda Castanho",
"number": "200",
"complement": "Ap 133",
"district": "Jardim Bom Tempo",
"city": "Taboao da Serra",
"state": "SP",
"country": "Brazil",
"type": "HOME",
}
]
],
"totalItems": 0,
"totalPages": 1
}
"""
get_cpf_from_jwt()
"""
Response example:
"09345699823"
"""
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
jsm_user_services-0.2.0.tar.gz
(16.9 kB
view hashes)
Built Distribution
Close
Hashes for jsm_user_services-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08a9a56c1e1ee106c44d7e99e2051a773c044e4cbaa1678ab7daac3c61b8fea9 |
|
MD5 | 45a7afd0c67be460193019d0b9a0ca95 |
|
BLAKE2b-256 | f474ce8d7fc1951133498cc3d36f19607fbeb1a52d539fc8d9110837ae884f34 |