blasphem/pkg/auth/user.go

43 lines
787 B
Go
Raw Permalink Normal View History

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