当前位置:网站首页>Laravel Swagger添加访问密码
Laravel Swagger添加访问密码
2022-07-29 05:19:00 【廖圣平】
接口文档暴露给外部是非常致命的,所以适当的把接口保护起来是必要的
在我使用 darkaonline/l5-swagger 包的时候没有查到比较明确接口文档保护措施,下面提供相对于暴露接口文档的方案。
方案一:
路由保护的方法,在 config/l5-swagger.php

修改这个路由路径,比如:
方案二:
在访问中添加token的参数
修改文件:resources\views\vendor\l5-swagger\index.blade.php
添加:
<?php
if (empty(request()->get('token')) || request()->get('token') != '112233') {
echo <<<HTML <div style="width: 100%;height: 100%;display: flex; align-items: center;justify-content: center"> <div > <div> <h1 style="color: #6ed162">接口文档</h1> </div> <div> <form style="height: 100px" action="" method="get"> <input name="token"> <button>验证</button> </form> </div> </div> </div> HTML;
exit;
}
?>

上面的112233 就是访问的token 可修改成自己的
边栏推荐
- Clickhouse learning (V) cluster operation
- Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration
- TXT 纯文本操作
- Clickhouse learning (IV) SQL operation
- Selection options of uniapp components (such as package selection)
- Hcia-r & s self use notes (27) comprehensive experiment
- ClickHouse学习(二)ClickHouse单机安装
- HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置
- [typescript] type reduction (including type protection) and type predicate in typescript
- Day14: upload labs customs clearance tutorial
猜你喜欢

ClickHouse学习(六)语法优化
![[typescript] learn typescript object types in depth](/img/87/a9fd2f177331863e06fcf14559eeed.png)
[typescript] learn typescript object types in depth
![[C language series] - string + partial escape character explanation + annotation tips](/img/75/698ba0672af9d6118ee7e2fdf6daae.png)
[C language series] - string + partial escape character explanation + annotation tips

Clickhouse learning (IV) SQL operation

DAY15(DAY16拓展):文件包含漏洞

·Let's introduce ourselves to the way of programming·

Clickhouse learning (VIII) materialized view

table中同一列中合并相同项

Clickhouse learning (VI) grammar optimization

AR虚拟增强与现实
随机推荐
Fvuln automated web vulnerability detection tool
ClickHouse学习(十一)clickhouseAPI操作
OpenAtom OpenHarmony分论坛圆满举办,生态与产业发展迈向新征程
QPalette学习笔记
Wechat applet - component parameter transmission, state management
重绘与回流的关系
table中同一列中合并相同项
link与@import的关系
ClickHouse学习(九)clickhouse整合mysql
Common characteristic engineering operations
Relative positioning and absolute positioning
uniapp之常用提示弹框
How does the MD editor of CSDN input superscripts and subscripts? The input method of formula and non formula is different
JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
[typescript] in depth study of typescript functions
[C language series] - detailed explanation of file operation (Part 1)
shell基本操作(上)
使用Qss设置窗体样式
[typescript] learn typescript object types in depth
href与src的区别