Compare commits

...

4 Commits

Author SHA1 Message Date
7bf92a6241 Merge pull request #6 from MarekWojt/features/fixes
Fixed:

- missing response text on authentication failure
- missing response text on internal server error
- updating ipv6 via request for updating both ipv4 and ipv6 didn't work, could reset previously set ipv4
- domain list in auth.toml needed "." suffixes
2023-01-06 01:13:24 +01:00
250cd56b19 fix needed "." suffix in auth domain list 2023-01-05 20:31:38 +01:00
6e2d00bd6c fix ipv6 updating ipv4 in update both action 2023-01-05 20:16:52 +01:00
74aa218cf0 fix missing text on auth/internal failure 2023-01-05 20:15:33 +01:00
2 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package auth package auth
import ( import (
"github.com/MarekWojt/gertdns/util"
"github.com/raja/argon2pw" "github.com/raja/argon2pw"
) )
@@ -40,7 +41,8 @@ func (selfUser *userRaw) Tidy() (user, error) {
// Create a map => faster access times // Create a map => faster access times
parsedDomains := make(map[string]string) parsedDomains := make(map[string]string)
for _, domain := range selfUser.Domains { for _, domain := range selfUser.Domains {
parsedDomains[domain] = domain parsedDomain := util.ParseDomain(domain)
parsedDomains[parsedDomain] = parsedDomain
} }
parsedUser := user{ parsedUser := user{

View File

@@ -148,7 +148,7 @@ func update(ctx *fasthttp.RequestCtx) {
} }
if ipv6 != "" { if ipv6 != "" {
err := dns.UpdateIpv4(domain, ipv4) err := dns.UpdateIpv6(domain, ipv6)
if err != nil { if err != nil {
ctx.WriteString(err.Error()) ctx.WriteString(err.Error())
ctx.SetStatusCode(fasthttp.StatusNotFound) ctx.SetStatusCode(fasthttp.StatusNotFound)
@@ -190,11 +190,13 @@ func authenticatedRequest(request func(ctx *fasthttp.RequestCtx)) func(ctx *fast
authenticated, err := auth.IsPasswordAuthenticated(authRequest) authenticated, err := auth.IsPasswordAuthenticated(authRequest)
if err != nil { if err != nil {
ctx.WriteString("Internal server error")
ctx.SetStatusCode(fasthttp.StatusInternalServerError) ctx.SetStatusCode(fasthttp.StatusInternalServerError)
return return
} }
if !authenticated { if !authenticated {
ctx.WriteString("Authentication failed")
ctx.SetStatusCode(fasthttp.StatusForbidden) ctx.SetStatusCode(fasthttp.StatusForbidden)
return return
} }