mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AuthN: Cleanup authn package (#63456)
* AuthN: Update comments for ClientParams * AuthN: Update flag name from SyncTeamMembers to SyncTeams * UserSync: rename function and fix order of parameters so it is correct * UserSync: Fix so we skip check if no authModule or authID is passed * UserSync: move quota check to create user function * UserSync: Move FetchSyncedUserHook to UserSync * UserSync: Move last seen user hook to user sync service * ApiKey: Implement last seen hook as a client hook instead
This commit is contained in:
@@ -37,16 +37,16 @@ const (
|
||||
// ClientParams are hints to the auth service about how to handle the identity management
|
||||
// from the authenticating client.
|
||||
type ClientParams struct {
|
||||
// Update the internal representation of the entity from the identity provided
|
||||
// SyncUser updates the internal representation of the identity from the identity provided
|
||||
SyncUser bool
|
||||
// Add entity to teams
|
||||
SyncTeamMembers bool
|
||||
// Create entity in the DB if it doesn't exist
|
||||
// AllowSignUp Adds identity to DB if it doesn't exist when, only work if SyncUser is enabled
|
||||
AllowSignUp bool
|
||||
// EnableDisabledUsers is a hint to the auth service that it should re-enable disabled users
|
||||
// EnableDisabledUsers will enable disabled user, only work if SyncUser is enabled
|
||||
EnableDisabledUsers bool
|
||||
// FetchSyncedUser ensure that all required information is added to the identity
|
||||
FetchSyncedUser bool
|
||||
// SyncTeams will sync the groups from identity to teams in grafana, enterprise only feature
|
||||
SyncTeams bool
|
||||
// CacheAuthProxyKey if this key is set we will try to cache the user id for proxy client
|
||||
CacheAuthProxyKey string
|
||||
// LookUpParams are the arguments used to look up the entity in the DB.
|
||||
@@ -222,26 +222,20 @@ func (i *Identity) Role() org.RoleType {
|
||||
return i.OrgRoles[i.OrgID]
|
||||
}
|
||||
|
||||
// TODO: improve error handling
|
||||
// NamespacedID returns the namespace, e.g. "user" and the id for that namespace
|
||||
func (i *Identity) NamespacedID() (string, int64) {
|
||||
var (
|
||||
id int64
|
||||
namespace string
|
||||
)
|
||||
|
||||
split := strings.Split(i.ID, ":")
|
||||
if len(split) != 2 {
|
||||
return "", -1
|
||||
}
|
||||
|
||||
id, errI := strconv.ParseInt(split[1], 10, 64)
|
||||
if errI != nil {
|
||||
id, err := strconv.ParseInt(split[1], 10, 64)
|
||||
if err != nil {
|
||||
// FIXME (kalleep): Improve error handling
|
||||
return "", -1
|
||||
}
|
||||
|
||||
namespace = split[0]
|
||||
|
||||
return namespace, id
|
||||
return split[0], id
|
||||
}
|
||||
|
||||
// NamespacedID builds a namespaced ID from a namespace and an ID.
|
||||
|
||||
Reference in New Issue
Block a user