Commit fd228b09 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix checking for username when token is present.

parent 0416976e
...@@ -1075,11 +1075,10 @@ func GetDescription(name string) (*Description, error) { ...@@ -1075,11 +1075,10 @@ func GetDescription(name string) (*Description, error) {
} }
func (desc *Description) GetPermission(group string, creds ClientCredentials) (string, []string, error) { func (desc *Description) GetPermission(group string, creds ClientCredentials) (string, []string, error) {
if !desc.AllowAnonymous && creds.Username == "" {
return "", nil, ErrAnonymousNotAuthorised
}
if creds.Token == "" { if creds.Token == "" {
if !desc.AllowAnonymous && creds.Username == "" {
return "", nil, ErrAnonymousNotAuthorised
}
if found, good := matchClient(group, creds, desc.Op); found { if found, good := matchClient(group, creds, desc.Op); found {
if good { if good {
var p []string var p []string
...@@ -1111,6 +1110,9 @@ func (desc *Description) GetPermission(group string, creds ClientCredentials) (s ...@@ -1111,6 +1110,9 @@ func (desc *Description) GetPermission(group string, creds ClientCredentials) (s
log.Printf("Token authentication: %v", err) log.Printf("Token authentication: %v", err)
return "", nil, ErrNotAuthorised return "", nil, ErrNotAuthorised
} }
if !desc.AllowAnonymous && sub == "" {
return "", nil, ErrAnonymousNotAuthorised
}
conf, err := GetConfiguration() conf, err := GetConfiguration()
if err != nil { if err != nil {
log.Printf("Read config.json: %v", err) log.Printf("Read config.json: %v", err)
...@@ -1154,7 +1156,7 @@ type Status struct { ...@@ -1154,7 +1156,7 @@ type Status struct {
ClientCount *int `json:"clientCount,omitempty"` ClientCount *int `json:"clientCount,omitempty"`
} }
func (g *Group) Status (authentified bool) Status { func (g *Group) Status(authentified bool) Status {
desc := g.Description() desc := g.Description()
d := Status{ d := Status{
Name: g.name, Name: g.name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment