Split user
This commit is contained in:
parent
414654585b
commit
0358eeac53
4 changed files with 43 additions and 25 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@ blas
|
|||
!cmd/blas/
|
||||
Session.vim
|
||||
coverage.txt
|
||||
*.dlv
|
||||
*.core
|
||||
|
|
|
@ -20,6 +20,7 @@ var (
|
|||
)
|
||||
|
||||
type Authenticator struct {
|
||||
store AuthStore
|
||||
flows FlowStore
|
||||
sessions SessionStore
|
||||
providers map[string]AuthProvider
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type SessionStore struct {
|
||||
|
@ -77,25 +75,6 @@ func (ss *SessionStore) verifyAndGetCredential(tr *TokenRequest, r *http.Request
|
|||
return &Credential{user: user}
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string
|
||||
Active bool
|
||||
}
|
||||
|
||||
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().Str("user", c.user.ProviderUsername()).Msg("getOrCreateUser")
|
||||
panic("not implemented")
|
||||
return &User{}, nil
|
||||
}
|
||||
|
||||
const defaultExpiration = 2 * time.Hour
|
||||
|
||||
func (a *Authenticator) NewToken(r *http.Request, user ProviderUser, f *Flow) TokenID {
|
||||
|
|
36
pkg/auth/user.go
Normal file
36
pkg/auth/user.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthKey = "auth"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Username string
|
||||
UserMetadata
|
||||
}
|
||||
|
||||
type UserMetadata struct {
|
||||
Active bool
|
||||
}
|
||||
|
||||
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().Str("user", c.user.ProviderUsername()).Msg("getOrCreateUser")
|
||||
panic("not implemented")
|
||||
return &User{}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue