40 lines
846 B
Go
40 lines
846 B
Go
package auth
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
type UserID string
|
|
type GroupID string
|
|
type CredID string
|
|
|
|
type User struct {
|
|
ID UserID `json:"id"`
|
|
GroupIDs []GroupID `json:"group_ids"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
UserMetadata
|
|
}
|
|
|
|
type UserMetadata struct {
|
|
Active bool `json:"is_active"`
|
|
Owner bool `json:"is_owner"`
|
|
LocalOnly bool `json:"local_only"`
|
|
SystemGenerated bool `json:"system_generated"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (u *User) allowedToAuth() error {
|
|
if !u.Active {
|
|
return errors.New("user disabled")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) {
|
|
log.Debug().Interface("userdata", c.user.ProviderUserData()).Msg("getOrCreateUser")
|
|
panic("not implemented")
|
|
return &User{}, nil
|
|
}
|