Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
add skip auth path
Browse files Browse the repository at this point in the history
  • Loading branch information
perrornet committed Feb 25, 2022
1 parent b775133 commit 2da3387
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 15 additions & 2 deletions cmd/miner-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,23 @@ func (p *proxyService) startHttpServer() {
app := gin.New()
app.Use(gin.Recovery(), middleware.Cors())

skipAuthPaths := []string{
"/download/",
}

if p.args.String("p") != "" {
app.Use(gin.BasicAuth(gin.Accounts{
middlewareFunc := gin.BasicAuth(gin.Accounts{
"admin": p.args.String("p"),
}))
})
app.Use(func(ctx *gin.Context) {
for _, v := range skipAuthPaths {
if strings.HasPrefix(ctx.Request.URL.Path, v) {
return
}
}
middlewareFunc(ctx)
return
})
}

port := strings.Split(p.args.String("l"), ":")[1]
Expand Down
4 changes: 3 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ <h2 class="h4 fw-bolder" style="margin-top: 8%; margin-left: 40%">示例网络
alert_text.append(`<p>${count}. 复制命令, 并在机器上运行 <code>chmod +x ./miner-proxy_${params.client_system_type}_${params.client_system_struct}</code>`)
let cmd = `./miner-proxy_${params.client_system_type}_${params.client_system_struct} -l :${params.port} -a :${params.web_port} -k "${params.password}"`
if (params.client_run_type === "service"){
cmd = `sudo su && ${cmd} install`
count++
alert_text.append(`<p>${count}. 复制命令, 并在机器上运行 <code>sudo su</code> 并输入密码, 如果已经是root用户则不需要输入`)
cmd = `${cmd} install`
}
if (params.client_run_type === "backend"){
cmd = `nohup ${cmd} > miner.log 2>& 1&`
Expand Down

0 comments on commit 2da3387

Please sign in to comment.