Skip to content

Commit

Permalink
jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyunpeng committed Feb 26, 2024
1 parent cc4b53f commit 21ce5bc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions _posts/2024-02-23-jwt插件使用.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ tags: [lua]
---

# 1. 你要有一台服务器并安装openrest

​ 这里以centos7为例子

```bash
这里以centos7为例子

# add the yum repo:
wget https://openresty.org/package/centos/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/openresty.repo

# update the yum index:
sudo yum check-update

然后就可以像下面这样安装软件包,比如 openresty:
sudo yum install -y openresty
```
​ 然后就可以像下面这样安装软件包

```bash
sudo yum install -y openresty
```


# 2. 安装jwt插件

```bash
Expand All @@ -27,7 +34,7 @@ https://github.com/cdbattags/lua-resty-jwt

下载后将“lib/resty“目录内的文件放到"openresty"默认的目录中“lualib/resty”

# 3. 配置“openresty”规则
# 3. 配置“openresty”规则

```bash
server {
Expand Down Expand Up @@ -158,3 +165,8 @@ curl -s https://xxxx.xx/sign
curl 'https://xxxx.xx/anything/1get?1=a&2=s' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJpc3MiOiJ5ZCIsImlhdCI6MTcwODY4Mzk2MCwibmJmIjoxNzA4NjgzOTkwLCJleHAiOjE3MDg2ODc1NjB9.un7HYSTX7eYpY5puop8-Q_aU69KzSMcdp_Q25xlMivg'
```
## 3. 验证"token"
```
curl -s https://xxxx.xx/verify?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJpc3MiOiJ5ZCIsImlhdCI6MTcwODY4Mzk2MCwibmJmIjoxNzA4NjgzOTkwLCJleHAiOjE3MDg2ODc1NjB9.un7HYSTX7eYpY5puop8-Q_aU69KzSMcdp_Q25xlMivg
```

0 comments on commit 21ce5bc

Please sign in to comment.