
在手搓个人网站,现在考虑鉴权的问题
场景需求是:
大大们是怎么做的?有什么思路?
1 7gugu 2023 年 1 月 29 日 直接用 wordpress 一步到位 |
2 gra 2023 年 1 月 29 日 做个登录呗,最次一个字段,没注册,简单登录验证最方便 |
3 opengps 2023 年 1 月 29 日 我就是自己用了一个特别的路径,自己知道,然后再所有添加修改的地方,增加一个密码框就行了 |
4 boks 2023 年 1 月 29 日 ?p=xxxxxx |
6 loading 2023 年 1 月 29 日 建议 localhost |
7 Kinnice 2023 年 1 月 29 日 不要在线的后台了,只搭建个本地的后台编辑器,每次本机编辑好,生成静态文件,同步到服务器 |
8 cvooc 2023 年 1 月 29 日 ```php <?php $auth = array('密码 1','密码 2'); if (empty($_COOKIE["token"])||!in_array($_COOKIE["token"],$auth)) { // 校验失败,不显示后续内容 $loginhtml = <<<EOT <html> <head> <meta charset="utf-8"> <title>验证失败</title> </head> <body> <h1>认证已过期,请输入密码</h1> <input type="tel" id="mobile" description="输入你的密码即可" /> <button type="button" Onclick="save()">提交</button> </body> <script type="text/Javascript"> function save() { var mobile = document.getElementById('mobile').value; var exp = new Date(); exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000); document.cookie = "token=" + mobile + ";expires=" + exp.toGMTString(); location.reload(); } </script> </html> EOT; echo $loginhtml;exit(); } else { // 记录密码访问记录 $log_file = './log/log_'.date('Ymd',time()).'.log'; $cOntent= date('Y-m-d H:i:s',time()).' '.$_COOKIE["token"]."\r\n"; file_put_contents($log_file,$content, FILE_APPEND); } ``` // 后面业务内容随便整 |
9 shalingye 2023 年 1 月 29 日 via Android 同意楼上,我就是 hugo+vscode+syncthing |
10 cvooc 2023 年 1 月 29 日 ```php <?php $auth = array('密码 1','密码 2'); if (empty($_COOKIE["token"])||!in_array($_COOKIE["token"],$auth)) { // 校验失败,不显示后续内容 $loginhtml = <<<EOT <html> <head> <meta charset="utf-8"> <title>验证失败</title> </head> <body> <h1>认证已过期,请输入密码</h1> <input type="tel" id="mobile" description="输入你的密码即可" /> <button type="button" Onclick="save()">提交</button> </body> <script type="text/Javascript"> function save() { var mobile = document.getElementById('mobile').value; var exp = new Date(); exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000); document.cookie = "token=" + mobile + ";expires=" + exp.toGMTString(); location.reload(); } </script> </html> EOT; echo $loginhtml;exit(); } else { // 记录密码访问记录 $log_file = './log/log_'.date('Ymd',time()).'.log'; $cOntent= date('Y-m-d H:i:s',time()).' '.$_COOKIE["token"]."\r\n"; file_put_contents($log_file,$content, FILE_APPEND); } ``` // 后面业务内容随便整 |
11 cvooc 2023 年 1 月 29 日 之前给文档站加临时权限搞的, 基本思路就上面这样,简单粗暴, 说白了就是前端存个明文 cookie |
12 Herry001 2023 年 1 月 29 日 照着 Wordpress 的逻辑抄呗…… 手搓 OAuth 接第三方登录可比写一个账号系统麻烦多了(你甚至可以把账号和密码写死在代码里 |
13 HugoChao 2023 年 1 月 29 日 这个可以参考日网揭示板的设计,你弄个可编辑功能给所有人,然后编辑需要密码就可以了 |
14 QUC062IzY3M1Y6dg 2023 年 1 月 29 日 @shalingye 巧了,我也是这个方案,一模一样 |
15 blackboom 2023 年 1 月 29 日 via iPhone |
16 hsfzxjy 2023 年 1 月 29 日 via Android 我的博客静态挂在 github pages 上,其中一部分是公开的,一部分要密码才能查看 我的做法:魔改了 hexo 的渲染器,在渲染私有文章时做一次对称加密,加密过的内容隐藏写入页面,并在页面上放个密码框。要读文章就输入正确的密码解密。整个过程不需要服务器参与 |
17 celestylr 2023 年 1 月 29 日 静态 Blog 就没有这个烦恼 Private Repo + Github Action 远程服务器推送 |
18 potatowish 2023 年 1 月 29 日 via iPhone 配合 Google Authenticator 做动态密码登录认证 |
19 blackboom 2023 年 1 月 29 日 @potatowish 这个想法不错 |
20 hsuyeung 2023 年 1 月 29 日 #7 的方案感觉可以。我自己的还是做了一个简单的登录功能,没有注册,可以生成帐号。 |
21 dzdh 2023 年 1 月 29 日 客户端证书 |
22 lookStupiToForce 2023 年 1 月 29 日 一路看下来你们是真的闲,自己的博客自己登后台就行了还要鉴权 而且稍微有个差池被人 oday 了 /爆破了哭都没地儿哭 |
23 kirito41dd 2023 年 1 月 29 日 我真不是打广告,用 hugo 整个静态网站吧,放博客也比较省心 https://www.kirito.info/blog-with-gitpage-and-ci/ |
24 JustSong 2023 年 1 月 29 日 via Android 启动时接受一个命令行参数或者从环境变量中读取一个 token ,用这个 token 来做鉴权,我的微博客之前就是这样干的,https://github.com/songquanpeng/microblog |
25 sprite82 2023 年 1 月 30 日 > 后台编辑等需要鉴权的场景 这个场景直接内网访问不就好了,这就不需要鉴权了 |