All Projects → staugur → flask-apiSign-demo

staugur / flask-apiSign-demo

Licence: MIT license
Api签名验证样例

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to flask-apiSign-demo

cassh
SSH CA administration via CLI and GUI
Stars: ✭ 66 (+135.71%)
Mutual labels:  sign
flutter-openpgp
OpenPGP for flutter made with golang for fast performance with support for android, ios, macos, linux, windows, web and hover
Stars: ✭ 35 (+25%)
Mutual labels:  sign
CalendarView
日历控件
Stars: ✭ 14 (-50%)
Mutual labels:  sign
pyas2-lib
AS2 Library for building and parsing Messages and MDNs
Stars: ✭ 33 (+17.86%)
Mutual labels:  sign
tangem-sdk-ios
The native Swift library for iOS platforms
Stars: ✭ 35 (+25%)
Mutual labels:  sign
reactnative-android-production
Step by step guid for compiling and installing React Native Android app [ bundled release version ] to your test device.
Stars: ✭ 51 (+82.14%)
Mutual labels:  sign
chaoxing
Make Github to help u for signing on Superstar Xuexitong every 5 minutes, base on github actions.
Stars: ✭ 58 (+107.14%)
Mutual labels:  sign
SignTools-CI
Sign iOS apps on demand using CI. Part of: https://github.com/SignTools/SignTools
Stars: ✭ 145 (+417.86%)
Mutual labels:  sign
Taro-sign
Taro 开发的 思政教育签到小程序
Stars: ✭ 27 (-3.57%)
Mutual labels:  sign
ReSign
A burp extender that recalculate signature value automatically after you modified request parameter value.
Stars: ✭ 52 (+85.71%)
Mutual labels:  sign
ethjs-signer
A simple module for signing Ethereum transactions.
Stars: ✭ 27 (-3.57%)
Mutual labels:  sign
customer-ajax-login
Free magento 2 extension for Popup and AJAX based Login and Sign Up | Manish Joy
Stars: ✭ 14 (-50%)
Mutual labels:  sign
sign-in-with-apple
An example for sign-in-with-apple, golang-version.
Stars: ✭ 22 (-21.43%)
Mutual labels:  sign
swarm-cli
Manage your Bee node and interact with the Swarm network via the CLI
Stars: ✭ 36 (+28.57%)
Mutual labels:  sign
SmartTrafficIntersection
Another AI toy project, of a traffic intersection controlled by a Reinforcement Learning AI agent to optimize traffic flow in an intersection of vehicles or pedestrians
Stars: ✭ 30 (+7.14%)
Mutual labels:  sign
JNI RSA Sign
通过JNI实现验证App签名获取公钥
Stars: ✭ 86 (+207.14%)
Mutual labels:  sign
SchoolRegistrationUI-Android
Check out the new style for App Design aims for school or colleges...😉😀😁😎
Stars: ✭ 56 (+100%)
Mutual labels:  sign
crypto
Aplus Framework Crypto Library
Stars: ✭ 20 (-28.57%)
Mutual labels:  sign
react-signature-canvas
A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad
Stars: ✭ 420 (+1400%)
Mutual labels:  sign
ipa re sign
Re_sign an ipa using Apple Enterprise Certificate 使用企业证书 对 ipa 进行重签名.
Stars: ✭ 32 (+14.29%)
Mutual labels:  sign

flask-apiSign-demo

Api签名验证样例

使用

cd server ; pip install -r requirements.txt
python main.py

客户端

Python、Shell

JavaScript(HTML)

签名描述

一、起因

为了实现基本的防抓取机制,对绝大多数采用了 Api 签名验证,在保证签名秘钥不泄露的前提下,具有一定的数据抓取防御能力。

  1. 请求参数是否被篡改;
  2. 请求来源是否合法;
  3. 请求是否具有唯一性。

二、经过

  1. 前提准备

    接口提供方生成用户密钥,包含:

    1.1 accesskey_id, 标识用户

    1.2 accesskey_secret, 用户加密串(严格保管,仅用于加密不参与通信)

  2. 公共参数

    2.1 accesskey_id, 标识用户

    2.2 version, 后端接口版本号

    2.3 timestamp, 10位时间戳(客户端生成时间戳可以适当减几秒)

    2.4 signature, uri请求参数签名(除signature外所有)

    # 另可以定义其他参数,比如signMethod

  3. 签名过程

    3.1.对除签名外的所有请求参数按key做的升序排列。

    例如:有b=2一个私有参数,另加上公共参数后,按key排序后为:accesskey_id、b、timestamp、version

    3.2 把排序后的参数以"参数名=参数值&"的形式连接,末尾再加上"accesskey_secret",得到拼装字符串。

    例如:accesskey_id=test&b=2&timestamp=1511232761&version=v1&accesskey_secret

    3.3 将上一步得到的字符串MD5加密并转化为大写。

    例如:signature=F833B331E572FD9D3D64A8D0737490B0

    3.4 最终请求示例。

    timestamp=1511232761&b=2&version=v1&accesskey_id=test&signature=F833B331E572FD9D3D64A8D0737490B0

  4. 验证请求

    4.1 验证版本(非必要)

    4.2 验证时间戳是否有效(小于等于服务器时间戳且在30s之内请求有效)

    4.3 验证accesskey_id是否有效

    4.4 验证签名

三、返回

  1. 正确返回

    {
        "ping": "pong"
    }
    
  2. 错误返回

    2.1 版本错误

    {
        "msg": "Invalid version",
        "success": false
    }
    

    2.2 时间戳错误

    {
        "msg": "Invalid timestamp",
        "success": false
    }
    

四、参考

  1. API接口签名验证(详细描述主流签名方式)

  2. Api:签名验证机制(提及关于POST签名说明)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].