1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Fix checking for username when token is present.

This commit is contained in:
Juliusz Chroboczek 2022-04-29 01:36:02 +02:00
parent 0416976e20
commit fd228b09c2

View file

@ -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 creds.Token == "" {
if !desc.AllowAnonymous && creds.Username == "" { if !desc.AllowAnonymous && creds.Username == "" {
return "", nil, ErrAnonymousNotAuthorised return "", nil, ErrAnonymousNotAuthorised
} }
if creds.Token == "" {
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
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)