Skip to main content

dvadmin-ak-sk 插件是dvadmin的一个ak/sk加密调用插件,使用Access Key Id / Secret Access Key加密的方法来验证某个请求的发送者身份。Access Key Id(AK)用于标示用户,Secret Access Key(SK)是用于加密认证字符串来验证认证字符串的密钥,其中SK必须保密。 AK/SK原理使用对称加解密。

Project description

dvadmin_ak_sk

介绍

dvadmin-ak-sk 插件是dvadmin的一个ak/sk加密调用插件,使用Access Key Id / Secret Access Key加密的方法来验证某个请求的发送者身份。Access Key Id(AK)用于标示用户,Secret Access Key(SK)是用于加密认证字符串来验证认证字符串的密钥,其中SK必须保密。 AK/SK原理使用对称加解密。

软件架构

软件架构说明

安装包

使用pip安装软件包:

pip install dvadmin-ak-sk

方式一: 一键导入注册配置

在 application / settings.py 插件配置中下导入默认配置

...
from dvadmin_ak_sk.settings import *

方式二: 手动配置

在INSTALLED_APPS 中注册app(注意先后顺序)

INSTALLED_APPS = [
    ...
    'dvadmin_ak_sk',
]
REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": (
        ...,
        'dvadmin_ak_sk.libs.authentication.AkSkAuthentication'
    )
}

在 application / urls.py 中注册url地址

urlpatterns = [
    ...,
    path(r'api/dvadmin_ak_sk/', include('dvadmin_ak_sk.urls')),
]

使用说明

import json
import os

import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()
from plugins.dvadmin_ak_sk_backend.client import Auth

AccessKey = 't32fSY09Mi0m0jT2G7XtmG7XgcS6QDzq'
AccessSecret = 'tMAiu8r8eJ4lptxviQ8QHsDOAtNvlG6K'

AuthObj = Auth(accessKey=AccessKey, accessSecret=AccessSecret)


def get_url(url):
    method = 'GET'
    body = ""
    queryString = ""
    headers = {"content-type": "application/json"}
    res = AuthObj.request(method=method, url=url, headers=headers, body=body, params=queryString)
    print(res)


def post_url(url):
    method = 'POST'
    body = {"name": '测试03', "unique_key": '1111'}
    queryString = ""
    headers = {"content-type": "application/json"}
    res = AuthObj.request(method=method, url=url, headers=headers, body=json.dumps(body), params=queryString)
    print(res)


if __name__ == '__main__':
    get_url('http://ip:8000/api/dvadmin_ak_sk/key_manage/')
    # post_url('http://ip.com:8000/api/dvadmin_ak_sk/key_manage/')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dvadmin-ak-sk-1.0.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

dvadmin_ak_sk-1.0.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file dvadmin-ak-sk-1.0.0.tar.gz.

File metadata

  • Download URL: dvadmin-ak-sk-1.0.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.4

File hashes

Hashes for dvadmin-ak-sk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7de3431be227c99919ad837746c1affd942c0fda32f951847311eac9cc96b55e
MD5 e85bbce48d71bb45fa832294d6f10e77
BLAKE2b-256 8feff292790d2927557254d0aae59cb4dafd66a7981152827f526617fca6573d

See more details on using hashes here.

File details

Details for the file dvadmin_ak_sk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dvadmin_ak_sk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dc4d675092377bbd3839b1c570789cec371c03db8aba2f46660c3a43f1e6a69
MD5 6a58e5b21bfc92f53e41b1348dbb6379
BLAKE2b-256 e109f75d94bba53d7a64d2d2a637c92ae432047b28ad80a51c838ea917be91e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page