Compare commits

...

3 commits

Author SHA1 Message Date
9f39049dd6 user 2022-11-12 17:50:01 -05:00
a540f94108 gofmt 2022-11-12 17:42:51 -05:00
25c3e9421f fix now 2022-11-12 17:42:36 -05:00
7 changed files with 47 additions and 44 deletions

View file

@ -127,4 +127,3 @@ func (hap *HomeAssistantProvider) FlowSchema() []provider.FlowSchemaItem {
func init() { func init() {
provider.Register(HomeAssistant, NewHAProvider) provider.Register(HomeAssistant, NewHAProvider)
} }

View file

@ -49,5 +49,3 @@ type FlowSchemaItem struct {
Name string `json:"name"` Name string `json:"name"`
Required bool `json:"required"` Required bool `json:"required"`
} }

View file

@ -73,4 +73,3 @@ func (hap *TrustedNetworksProvider) FlowSchema() []provider.FlowSchemaItem {
func init() { func init() {
provider.Register(TrustedNetworks, New) provider.Register(TrustedNetworks, New)
} }

View file

@ -103,11 +103,12 @@ const defaultExpiration = 2 * time.Hour
func (a *Authenticator) NewToken(r *http.Request, user provider.ProviderUser, f *Flow) TokenID { func (a *Authenticator) NewToken(r *http.Request, user provider.ProviderUser, f *Flow) TokenID {
id := TokenID(genUUID()) id := TokenID(genUUID())
now := time.Now()
t := &Token{ t := &Token{
ID: id, ID: id,
Ctime: time.Now(), Ctime: now,
Expires: time.Now().Add(defaultExpiration), Expires: now.Add(defaultExpiration),
Addr: r.RemoteAddr, Addr: r.RemoteAddr,
user: user, user: user,

View file

@ -1,8 +1,8 @@
package auth package auth
import ( import (
"fmt"
"encoding/json" "encoding/json"
"fmt"
"dynatron.me/x/blasphem/pkg/storage" "dynatron.me/x/blasphem/pkg/storage"
) )
@ -11,8 +11,8 @@ const (
AuthStoreKey = "auth" AuthStoreKey = "auth"
) )
type AuthStore interface { type AuthStore interface {
User(UserID) *User
} }
type authStore struct { type authStore struct {
@ -49,3 +49,7 @@ func (a *Authenticator) newAuthStore(s storage.Store) (as *authStore, err error)
return return
} }
func (s *authStore) User(uid UserID) *User {
return s.userMap[uid]
}

View file

@ -35,8 +35,10 @@ func (u *User) allowedToAuth() error {
func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) { func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) {
log.Debug().Interface("userdata", c.user.ProviderUserData()).Msg("getOrCreateUser") log.Debug().Interface("userdata", c.user.ProviderUserData()).Msg("getOrCreateUser")
panic("not implemented") u := a.store.User(c.UserID)
return &User{}, nil if u == nil {
return nil, errors.New("no such user)
} }
return u, nil
}