login.md 2.0 KB

用户登录

请求路径

http://cloud-gateway:9999/auth/oauth/token

修改hosts cloud-gateway 指向 服务器ip或请求地址直接用服务器ip

header要求

    VERSION
    Content-Type: application/x-www-form-urlencoded
    Authorization: Basic d2ViOndlYg==

参数

参数 类型 是否必填 释义
grant_type string 登录方式

formdata

| 参数 | 类型 | 是否必填 | 释义 | |:---------|------- :|:----: |-----| | username | string | 是 | 账号 | | password | string | 是 | 密码 |

参数加密方式

Authorization: Basic xxxxxx

xxxxxx 为加密数据,平台会对每种客户端都分配一个密钥。
在没有登录之前,使用密钥进行加密,并替换xxxxxx部分;
在登录之后xxxxxx替换为登录接口返回的token,
Authorization: token_type token
---------------------------------------------
加密方式: 暂时使用直接加密后的参数 

Authorization: Basic d2ViOndlYg==

password

对password进行AES对称加密,采用CFB模式
ex:
        AES aes = new AES(Mode.CFB, Padding.NoPadding,
                new SecretKeySpec("sdjurli%*iw18s^1".getBytes(StandardCharsets.UTF_8), "AES"),
                new IvParameterSpec("sdjurli%*iw18s^1".getBytes(StandardCharsets.UTF_8)));
        System.out.println(aes.encryptBase64("test123".getBytes(StandardCharsets.UTF_8)));
        
        输出结果是 2iIrtaZRSw==
        
        'sdjurli%*iw18s^1'是密钥,对test123进行加密

request example

method: POST 
uri:http://cloud-gateway:9999/auth/oauth/token?grant_type=password

Content-Type: application/x-www-form-urlencoded
Authorization: Basic d2ViOndlYg==

username=admin&password=2iIrtaZRSw==

img.png

web参考

http://192.168.31.78:8080/  
账号:admin   密码:test123
swagger文档地址  http://cloud-gateway:9999/swagger-ui/index.html