mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LDAP: validate organization role during parsing (#37188)
* LDAP: validate organization role during parsing * Trigger a new build * Check if grafana_admin is present
This commit is contained in:
committed by
GitHub
parent
18f089d1bd
commit
c41397a6e7
@@ -1,9 +1,9 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -61,18 +61,14 @@ func (r RoleType) Parents() []RoleType {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RoleType) UnmarshalJSON(data []byte) error {
|
||||
var str string
|
||||
err := json.Unmarshal(data, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (r *RoleType) UnmarshalText(data []byte) error {
|
||||
// make sure "viewer" and "Viewer" are both correct
|
||||
str := strings.Title(string(data))
|
||||
|
||||
*r = RoleType(str)
|
||||
|
||||
if !r.IsValid() {
|
||||
if (*r) != "" {
|
||||
return fmt.Errorf("JSON validation error: invalid role value: %s", *r)
|
||||
return fmt.Errorf("invalid role value: %s", *r)
|
||||
}
|
||||
|
||||
*r = ROLE_VIEWER
|
||||
|
||||
Reference in New Issue
Block a user