mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Return correct error message for invalid tokens.
This commit is contained in:
parent
89f947df1f
commit
b8f7c68338
4 changed files with 7 additions and 3 deletions
|
@ -1012,7 +1012,7 @@ func (g *Group) getPermission(creds ClientCredentials) (string, []string, error)
|
||||||
if creds.Token != "" {
|
if creds.Token != "" {
|
||||||
tok, err := token.Parse(creds.Token, desc.AuthKeys)
|
tok, err := token.Parse(creds.Token, desc.AuthKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, &NotAuthorisedError{err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
conf, err := GetConfiguration()
|
conf, err := GetConfiguration()
|
||||||
|
|
|
@ -1426,6 +1426,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
} else if errors.As(err, &autherr) {
|
} else if errors.As(err, &autherr) {
|
||||||
s = "not authorised"
|
s = "not authorised"
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
log.Printf("Join group: %v", err)
|
||||||
} else if _, ok := err.(group.UserError); ok {
|
} else if _, ok := err.(group.UserError); ok {
|
||||||
s = err.Error()
|
s = err.Error()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,6 +137,10 @@ func parseJWT(token string, keys []map[string]interface{}) (*JWT, error) {
|
||||||
jwt.WithLeeway(5*time.Second),
|
jwt.WithLeeway(5*time.Second),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, jwt.ErrTokenMalformed) {
|
||||||
|
// assume this is not a JWT
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return (*JWT)(t), nil
|
return (*JWT)(t), nil
|
||||||
|
|
|
@ -28,7 +28,6 @@ func Parse(token string, keys []map[string]interface{}) (Token, error) {
|
||||||
return nil, err1
|
return nil, err1
|
||||||
} else if err2 != nil {
|
} else if err2 != nil {
|
||||||
return nil, err2
|
return nil, err2
|
||||||
} else {
|
}
|
||||||
return nil, os.ErrNotExist
|
return nil, os.ErrNotExist
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue