Compare commits
3 commits
1aa1296732
...
9f39049dd6
Author | SHA1 | Date | |
---|---|---|---|
9f39049dd6 | |||
a540f94108 | |||
25c3e9421f |
7 changed files with 47 additions and 44 deletions
|
@ -127,4 +127,3 @@ func (hap *HomeAssistantProvider) FlowSchema() []provider.FlowSchemaItem {
|
|||
func init() {
|
||||
provider.Register(HomeAssistant, NewHAProvider)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,5 +49,3 @@ type FlowSchemaItem struct {
|
|||
Name string `json:"name"`
|
||||
Required bool `json:"required"`
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,4 +73,3 @@ func (hap *TrustedNetworksProvider) FlowSchema() []provider.FlowSchemaItem {
|
|||
func init() {
|
||||
provider.Register(TrustedNetworks, New)
|
||||
}
|
||||
|
||||
|
|
|
@ -103,11 +103,12 @@ const defaultExpiration = 2 * time.Hour
|
|||
|
||||
func (a *Authenticator) NewToken(r *http.Request, user provider.ProviderUser, f *Flow) TokenID {
|
||||
id := TokenID(genUUID())
|
||||
now := time.Now()
|
||||
|
||||
t := &Token{
|
||||
ID: id,
|
||||
Ctime: time.Now(),
|
||||
Expires: time.Now().Add(defaultExpiration),
|
||||
Ctime: now,
|
||||
Expires: now.Add(defaultExpiration),
|
||||
Addr: r.RemoteAddr,
|
||||
|
||||
user: user,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"dynatron.me/x/blasphem/pkg/storage"
|
||||
)
|
||||
|
@ -11,8 +11,8 @@ const (
|
|||
AuthStoreKey = "auth"
|
||||
)
|
||||
|
||||
|
||||
type AuthStore interface {
|
||||
User(UserID) *User
|
||||
}
|
||||
|
||||
type authStore struct {
|
||||
|
@ -49,3 +49,7 @@ func (a *Authenticator) newAuthStore(s storage.Store) (as *authStore, err error)
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *authStore) User(uid UserID) *User {
|
||||
return s.userMap[uid]
|
||||
}
|
||||
|
|
|
@ -35,8 +35,10 @@ func (u *User) allowedToAuth() error {
|
|||
|
||||
func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) {
|
||||
log.Debug().Interface("userdata", c.user.ProviderUserData()).Msg("getOrCreateUser")
|
||||
panic("not implemented")
|
||||
return &User{}, nil
|
||||
u := a.store.User(c.UserID)
|
||||
if u == nil {
|
||||
return nil, errors.New("no such user)
|
||||
}
|
||||
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue