Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬可不可以加一个后台管理界面 #23

Open
8ty opened this issue Dec 4, 2021 · 28 comments
Open

大佬可不可以加一个后台管理界面 #23

8ty opened this issue Dec 4, 2021 · 28 comments

Comments

@8ty
Copy link

8ty commented Dec 4, 2021

这样子就不用在上cfkv里,就可以自定义和删除了
另,可不可以在两个地方加个可选的密码一个是跳转,另外一个是主界面,因为害怕被不法分子拿来利用

@8ty
Copy link
Author

8ty commented Dec 4, 2021

已star

@xyTom
Copy link
Owner

xyTom commented Dec 11, 2021

最近一段时间比较忙,需求有点多等过段时间有空了,再逐步更新,也欢迎其他大佬可以参与贡献代码

@chiyi4488
Copy link

@8ty

可不可以在两个地方加个可选的密码一个是跳转

可以用 Cloudflare Access 功能達到驗證登入。

@Anpiluo
Copy link

Anpiluo commented Jun 3, 2022

我试过了,但是好像没办法设密码,而且没办法只给主界面加登录验证,如果给主界面加上,那所有短链接就都有了

@chiyi4488
Copy link

@Anpiluo

if(!path){

改這行,改成像是 if(path == "/manage") 之類的,然後把 Cloudflare Access 驗證路徑,設定在 /manage

@chiyi4488
Copy link

@Anpiluo 其實我有嘗試做一個後台管理介面,現在的狀況就是「能用,但是程式碼寫得很亂」(我是弱雞)。你不介意的話,我可以給你用用看。

https://fordemo.short-link.cotpear.workers.dev/manage

@crazypeace
Copy link

crazypeace commented Jul 24, 2022

@Anpiluo

if(!path){

改這行,改成像是 if(path == "/manage") 之類的,然後把 Cloudflare Access 驗證路徑,設定在 /manage

我的思路是在 kv 里写一个秘密路径,key为"password",value为秘密路径。
#38

@Anpiluo
Copy link

Anpiluo commented Aug 4, 2022

@Anpiluo

if(!path){

改這行,改成像是if(path == "/manage")之類的,然後把 Cloudflare Access 驗證路徑,設定在 /manage

很抱歉这么晚才回复

我在看到了你的回复后,进行了尝试,但我发现如果引号中的路径如果写为 /manager 就会报404,应写为 manage 之类,不应携带斜线

btw:if(path == "/manage") 后面应该再加一个 { ,我一开始直接替换了,部署不成功,在网上查了半天资料🤣

@chiyi4488
Copy link

key为"password",value为秘密路径。
@crazypeace JS有可能被外部讀取嗎?🤔

@chiyi4488
Copy link

不应携带斜线

我的做法是 if(path =="/manage" || path =="/manage/" {

@chiyi4488
Copy link

@Anpiluo 其實我有嘗試做一個後台管理介面,現在的狀況就是「能用,但是程式碼寫得很亂」(我是弱雞)。你不介意的話,我可以給你用用看。

如有需要,請email我。

@crazypeace
Copy link

crazypeace commented Aug 4, 2022

key为"password",value为秘密路径。
@crazypeace JS有可能被外部讀取嗎?🤔

此JS非彼JS。
写了逻辑的JS运行在worker上,如果cloudflare的服务没有漏洞,这个JS不会被攻击者拿到运行过程。而这个JS的源码是可以让攻击者知道的,写明了要读取KV中的password。而如果攻击者没有cloudflare账户权限是读不到KV的数据内容的,也就是说不知道KV中key为passowrd的entry的value是多少。

还有个main.js是由index.html调用的。里面是一些业务逻辑。
你可以看一下 https://github.com/crazypeace/Url-Shorten-Worker
解释:https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide.html
https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html
https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html

@crazypeace
Copy link

示例:
https://1ladder.eu.org/tiananmen

@chiyi4488
Copy link

key为"password",value为秘密路径。
@crazypeace JS有可能被外部讀取嗎?🤔

此JS非彼JS。 写了逻辑的JS运行在workder上,如果cloudflare的服务没有漏洞,这个JS不会被攻击者拿到运行过程。而这个JS的源码是可以让攻击者知道的,写明了要读取KV中的password。而如果攻击者没有cloudflare账户权限是读不到KV的数据内容的,也就是说不知道KV中key为passowrd的entry的value是多少。

还有个main.js是由index.html调用的。里面是一些业务逻辑。 你可以看一下 https://github.com/crazypeace/Url-Shorten-Worker 解释:https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide.html https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html

@crazypeace 哇!我沒想到有這樣子的風險!我自己的做法是不設password(純 if(path =="/manage" || path =="/manage/" {),但用 Cloudflare Zero Trust 來擋(如路徑為 /manage/*則需經過),不知道這樣做您怎麼看?其安全性、風險如何呢?

@crazypeace
Copy link

key为"password",value为秘密路径。
@crazypeace JS有可能被外部讀取嗎?🤔

此JS非彼JS。 写了逻辑的JS运行在workder上,如果cloudflare的服务没有漏洞,这个JS不会被攻击者拿到运行过程。而这个JS的源码是可以让攻击者知道的,写明了要读取KV中的password。而如果攻击者没有cloudflare账户权限是读不到KV的数据内容的,也就是说不知道KV中key为passowrd的entry的value是多少。
还有个main.js是由index.html调用的。里面是一些业务逻辑。 你可以看一下 https://github.com/crazypeace/Url-Shorten-Worker 解释:https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide.html https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html

@crazypeace 哇!我沒想到有這樣子的風險!我自己的做法是不設password(純 if(path =="/manage" || path =="/manage/" {),但用 Cloudflare Zero Trust 來擋(如路徑為 /manage/*則需經過),不知道這樣做您怎麼看?其安全性、風險如何呢?

我个人认为风险不是很大,不过你的worker的JS源码如果公开在互联网上(比如GitHub),原则上攻击者是有可能获得的。因为你的作法相当于在workder的JS里面写死一个密钥(manage),如果访问者提供了此密钥,则向访问者提供服务。

@crazypeace
Copy link

而我的作法是,worker的JS源码表明要在cloudflare的KV库里读取指定key的value作为密钥。
这样攻击者即使知道我的源码,因为密钥被cloudflare的账户权限保护而无法获得我的密钥。

@crazypeace
Copy link

Cloudflare Zero Trust 我没有研究过。

@Anpiluo
Copy link

Anpiluo commented Aug 4, 2022

根据我对Cloudflare Zero Trust的使用经历,@chiyi4488 和我的想法差不多,给界面加路径的目的是为了套cf Access的时候不会把短链接也套上,这种做法基本不依赖“路径”(或者说“密钥”)的隐蔽性(不可知性),我个人认为即使在网络上公开链接也无所谓(除非他能淦破cf(笑))。


诸位可以一试

@crazypeace
Copy link

crazypeace commented Aug 7, 2022

如果简单应用,分享给几个朋友使用。
我加上了删除短链的按钮。
源码:https://github.com/crazypeace/Url-Shorten-Worker
示例:https://1ladder.eu.org/tiananmen

@chiyi4488
Copy link

chiyi4488 commented Aug 7, 2022

@crazypeace @Anpiluo 或許咱可以來整合各自寫的短連結code 😁

感覺不錯

我的範例:https://fordemo.short-link.cotpear.workers.dev/manage

(不過我改動的有點多,我以JSON格式儲存短連結資料)

@crazypeace
Copy link

你的功能比较强大。
我就是一个简单的应用,分享给自己几个朋友使用。加了个密钥,服务不公开,仅此而已。所以管理功能比较弱。

@xenstar
Copy link

xenstar commented Nov 2, 2022

在我们启动URL缩短器之前,必须至少有一次认证。否则,该服务可能被垃圾邮件发送者滥用,这将损害域名的声誉。

例如,"admin "和 "password",然后可以访问URL缩短器页面。不需要很多复杂的功能或多个用户。只有这样,至少可以保护域名。

There must be at least one authentication before we start the URL shortener. Otherwise, the service can be abused by spammers, which will harm the domain's reputation.

e.g., "admin" and "password" can access the URL shortener page. No need for many complicated functions or multiple users. Only this will at least protect the domain.

Edit: Just notice someone already added this feature - https://github.com/51sec/Url-Shorten-By-CF-Worker

Edit 2: Deployed this fork, in the main url, if someone can see the source code or cltr + u, then the password to access the site is visible. Not a viable solution either. Requesting @xyTom to do something regarding basic security.

@crazypeace
Copy link

crazypeace commented Nov 2, 2022

在我们启动URL缩短器之前,必须至少有一次认证。否则,该服务可能被垃圾邮件发送者滥用,这将损害域名的声誉。

例如,"admin "和 "password",然后可以访问URL缩短器页面。不需要很多复杂的功能或多个用户。只有这样,至少可以保护域名。

There must be at least one authentication before we start the URL shortener. Otherwise, the service can be abused by spammers, which will harm the domain's reputation.

e.g., "admin" and "password" can access the URL shortener page. No need for many complicated functions or multiple users. Only this will at least protect the domain.

Edit: Just notice someone already added this feature - https://github.com/51sec/Url-Shorten-By-CF-Worker :D

This is my solution: https://github.com/crazypeace/Url-Shorten-Worker

Demo: https://1ladder.eu.org/6H4wjH

If you don't know the path, just access https://1ladder.eu.org/ , you can not use the service.

You can set a "password" in your KV, it can only be read by cloudflare worker script. So unauthorized user can't know it.

@xenstar
Copy link

xenstar commented Nov 2, 2022

在我们启动URL缩短器之前,必须至少有一次认证。否则,该服务可能被垃圾邮件发送者滥用,这将损害域名的声誉。
例如,"admin "和 "password",然后可以访问URL缩短器页面。不需要很多复杂的功能或多个用户。只有这样,至少可以保护域名。
There must be at least one authentication before we start the URL shortener. Otherwise, the service can be abused by spammers, which will harm the domain's reputation.
e.g., "admin" and "password" can access the URL shortener page. No need for many complicated functions or multiple users. Only this will at least protect the domain.
Edit: Just notice someone already added this feature - https://github.com/51sec/Url-Shorten-By-CF-Worker :D

This is my solution: https://github.com/crazypeace/Url-Shorten-Worker

Demo: https://1ladder.eu.org/6H4wjH

If you don't know the path, just access https://1ladder.eu.org/ , you can not use the service.

You can set a "password" in your KV, it can only be read by cloudflare worker script. So unauthorized user can't know it.

Thanks. This solved the issue. At least will provide basic protection from spammers.

@chiyi4488
Copy link

@xenstar What do you think of cloudflare zero trust service? I personally think this stops spam, done without making any changes to this repo. ✨

@xenstar
Copy link

xenstar commented Nov 5, 2022

@xenstar What do you think of cloudflare zero trust service? I personally think this stops spam, done without making any changes to this repo. ✨

Hi, @chiyi4488 thanks for suggesting this. I have never checked this feature. So I have tried to apply it, and it looks very promising. But one issue I am facing is it is applying policy for the whole subdomain. So even while accessing a redirecting domain, it's asking for authentication. I think this is a policy setting; I will check this more to fix it, but if you know anything or have any tutorial online (Chinese or English), you can share it with me.

@chiyi4488
Copy link

@xenstar I would recommend that you add a link to the settings page and set a path. See discussion above.

@Anpiluo

if(!path){

改這行,改成像是 if(path == "/manage") 之類的,然後把 Cloudflare Access 驗證路徑,設定在 /manage

@Likenttt
Copy link

Likenttt commented May 4, 2023

做了一个新的短链接cloudflare-worker-short-url ,带密码控制和点击历史记录,欢迎试用~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@crazypeace @Likenttt @chiyi4488 @xenstar @xyTom @Anpiluo @8ty and others