Skip to content

Commit

Permalink
make setting owners implicitly enable auth required
Browse files Browse the repository at this point in the history
  • Loading branch information
mleku committed Dec 6, 2024
1 parent 8e0a748 commit 8893354
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/realy/app/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (r *Relay) CheckOwnerLists(c cx) {
}
}

func (r *Relay) AuthEnabled() bo { return r.C.AuthRequired }
func (r *Relay) AuthEnabled() bo { return r.C.AuthRequired || len(r.C.Owners) > 0 }

// ServiceUrl returns the address of the relay to send back in auth responses.
// If auth is disabled this returns an empty string.
Expand Down
2 changes: 1 addition & 1 deletion realy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ out:
// environment variable key/value pair list, one per line. Note you must dereference a pointer
// type to use this. This allows the composition of the config in this file with an extended
// form with a customized variant of realy to produce correct environment variables both read
// and write.
// and write, including replacing the default values and descriptions when printing the usage.
func EnvKV(cfg any) (m KVSlice) {
t := reflect.TypeOf(cfg)
for i := 0; i < t.NumField(); i++ {
Expand Down
2 changes: 2 additions & 0 deletions realy/handleAdmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

func (s *Server) auth(r *http.Request) (authed bo) {
if s.adminUser == "" || s.adminPass == "" {
log.W.Ln("admin user and/or password not set")
// disallow this if it hasn't been configured, the default values are empty.
return
}
Expand All @@ -32,6 +33,7 @@ func (s *Server) auth(r *http.Request) (authed bo) {
return true
}
}
log.W.Ln("admin user failed to auth")
return
}

Expand Down
3 changes: 3 additions & 0 deletions realy/handleEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
)

func (s *Server) handleEvent(c cx, ws *web.Socket, req by, sto store.I) (msg by) {
if ws.AuthRequested() && len(ws.Authed()) == 0 {
return by("auth has been requested, awaiting authentication response")
}
log.T.F("handleEvent %s %s", ws.RealRemote(), req)
var err er
var ok bo
Expand Down
2 changes: 1 addition & 1 deletion realy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.2.37
v1.2.38

0 comments on commit 8893354

Please sign in to comment.