django-nice-auth
A Django library for integrating NICE authentication services. This library provides an interface for generating authentication data, retrieving authentication URLs, and verifying authentication results.
Current version: 0.1.11
Overview
django-niceauth is a Django library that provides an interface for interacting with the NICE authentication API. It supports obtaining tokens, generating encrypted tokens, and creating URLs for NICE authentication services.
Requirements
- Python 3.6+
- Django 3.0+
nice_authlibrary
Installation
-
Install the library:
pip install -U django-nice-auth
-
Add the library to your Django project:
Add
'niceauth'to yourINSTALLED_APPSin the Django settings file.INSTALLED_APPS = [ ..., 'niceauth', ]
-
Set up your environment variables:
Create a
.envfile in the root directory and add the following configurations:NICE_AUTH_BASE_URL=https://svc.niceapi.co.kr:22001 NICE_CLIENT_ID=your_client_id NICE_CLIENT_SECRET=your_client_secret NICE_PRODUCT_ID=your_product_id NICE_RETURN_URL=https://yourdomain.com/verify NICE_AUTHTYPE=M NICE_POPUPYN=N
-
Apply the migrations:
python manage.py migrate
Configuration
Before using the library, you need to set up the necessary configuration values in your .env file as shown above.
Usage
Models
The library includes the following models to store authentication requests and results:
NiceAuthRequest: Stores the request data.NiceAuthResult: Stores the result data.
API Endpoints
The library provides the following API endpoints:
-
Get NICE Authentication Data
-
URL:
/api/niceauth/ -
Method:
GETorPOST -
Response:
{ "request_no": "REQUEST_NO", "enc_data": "ENCRYPTED_DATA", "integrity_value": "INTEGRITY_VALUE", "token_version_id": "TOKEN_VERSION_ID" }
-
-
Get NICE Authentication URL
-
URL:
/api/niceauth/url/ -
Method:
GETorPOST -
Response:
{ "nice_auth_url": "https://nice.checkplus.co.kr/CheckPlusSafeModel/service.cb?m=service&token_version_id=TOKEN_VERSION_ID&enc_data=ENCRYPTED_DATA&integrity_value=INTEGRITY_VALUE" }
-
-
Verify NICE Authentication Result
-
URL:
/api/niceauth/verify/ -
Method:
GETorPOST -
Request Body:
{ "enc_data": "ENCRYPTED_DATA", "token_version_id": "TOKEN_VERSION_ID", "integrity_value": "INTEGRITY_VALUE" }
-
Response:
{ "resultcode": "0000", "requestno": "REQUEST_NO", "sitecode": "SITE_CODE", ... }
-
Example Usage
Initializing the Service
First, you need to initialize the NiceAuthService with the necessary configuration values:
from nice_auth.services import NiceAuthService
service = NiceAuthService(
base_url=settings.NICE_AUTH_BASE_URL,
client_id=settings.NICE_CLIENT_ID,
client_secret=settings.NICE_CLIENT_SECRET,
product_id=settings.NICE_PRODUCT_ID,
return_url=settings.NICE_RETURN_URL,
authtype=settings.NICE_AUTHTYPE,
popupyn=settings.NICE_POPUPYN
)
### Getting NICE Authentication Data
```python
auth_data = service.get_nice_auth()
Getting NICE Authentication URL
nice_url = service.get_nice_auth_url()
Verifying NICE Authentication Result
result_data = service.verify_auth_result(enc_data, key, iv)
Running Tests
To run the tests, use the following command:
python manage.py test
Metadata
Release files for django-nice-auth 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-nice-auth-0.1.11.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_nice_auth-0.1.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.6 kB
Release files / django-nice-auth-0.1.11.tar.gz
| Download URL | django-nice-auth-0.1.11.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56396427c5cb2294f72edc173817c57ba3f878553f0b871b4992be7472a5adf6
|
|
BLAKE2b-256 checksum How to use checksums |
5c8ea7b3642d9dd22eaa1efa75f7ca240e021f932b7f8e242fb6f743ebccfc55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|
Release files / django_nice_auth-0.1.11-py3-none-any.whl
| Download URL | django_nice_auth-0.1.11-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5cea3730ad83473b2e6f2df3537d3fe0b8a0d1a67488434d129da11b59c6819a
|
|
BLAKE2b-256 checksum How to use checksums |
27a666c9ef40bb562f5b6318490c89d274677864921972b830b63c1c24529b24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.18
|