You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-security/docs/Jwt.md

35 lines
638 B

# JWT
## 安装
```shell
go get git.tsl3060.com/openapi/go-security/jwt
```
将包放在你的项目文件夹下,并在 import 中添加以下内容:
```golang
import jwt "git.tsl3060.com/openapi/go-security/jwt"
```
## 基本使用
### 获取服务器公钥
访问[https://opendev.tsl3060.com/certs/publickey](https://opendev.tsl3060.com/certs/publickey)以获取服务器公钥
### 配置并使用示例
```golang
// 设置公钥
service, err := jwt.NewTokenService("public key")
if err != nil {
return
}
// 校验解析token
token, err := service.VerifyToken("token")
if err != nil {
return
}
fmt.Println(token)
```