当前位置:网站首页>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 可修改成自己的
边栏推荐
- 基础爬虫实战案例之获取游戏商品数据
- Merge the same items in the same column in table
- HCIA-R&S自用笔记(26)PPP
- Do students in the science class really understand the future career planning?
- Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)
- sql-server 数据表的简单操作
- Realize simple database query (incomplete)
- The function of using wechat applet to scan code to log in to the PC web of the system
- Clickhouse learning (VII) table query optimization
- Common characteristic engineering operations
猜你喜欢

Day14: upload labs customs clearance tutorial

微信小程序-屏幕高度

Hcia-r & s self use notes (27) comprehensive experiment

DAY4:SQL Sever 简单使用

Li Kou 994: rotten orange (BFS)
![[C language series] - string + partial escape character explanation + annotation tips](/img/75/698ba0672af9d6118ee7e2fdf6daae.png)
[C language series] - string + partial escape character explanation + annotation tips

【TypeScript】深入学习TypeScript函数

DAY13:文件上传漏洞

Set the background color of a cell in the table

解决表单校验提示信息不消失问题以及赋值不生效问题
随机推荐
Basic use of redis
ClickHouse学习(二)ClickHouse单机安装
ClickHouse学习(十一)clickhouseAPI操作
使用Qss设置窗体样式
Detailed explanation of typical application code of C language array - master enters by mistake (step-by-step code explanation)
[typescript] type reduction (including type protection) and type predicate in typescript
公众号不支持markdown格式文件编写怎么办?
Qt设置背景图片方法
uniapp之常用提示弹框
Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
What is sqlmap and how to use it
Selenium实战案例之爬取js加密数据
微信小程序-组件传参,状态管理
The function of using wechat applet to scan code to log in to the PC web of the system
Longest string without duplicate characters
Detailed installation and use tutorial of MySQL (nanny installation with pictures and texts)
[JS question solution] questions 1-10 in JS of niuke.com
OpenAtom OpenHarmony分论坛圆满举办,生态与产业发展迈向新征程
Use QSS to style the form
Introduction to C language array to proficiency (array elaboration)