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() {
provider.Register(HomeAssistant, NewHAProvider)
}

View file

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

View file

@ -73,4 +73,3 @@ func (hap *TrustedNetworksProvider) FlowSchema() []provider.FlowSchemaItem {
func init() {
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 {
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,

View file

@ -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]
}

View file

@ -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
}