diff --git a/pkg/auth/flow.go b/pkg/auth/flow.go index 3d1c143..861f417 100644 --- a/pkg/auth/flow.go +++ b/pkg/auth/flow.go @@ -35,14 +35,14 @@ const ( ) type Flow struct { - Type FlowType `json:"type"` - ID FlowID `json:"flow_id"` - Handler []*string `json:"handler"` - StepID *Step `json:"step_id,omitempty"` + Type FlowType `json:"type"` + ID FlowID `json:"flow_id"` + Handler []*string `json:"handler"` + StepID *Step `json:"step_id,omitempty"` Schema []provider.FlowSchemaItem `json:"data_schema"` - Errors interface{} `json:"errors"` - DescPlace *string `json:"description_placeholders"` - LastStep *string `json:"last_step"` + Errors interface{} `json:"errors"` + DescPlace *string `json:"description_placeholders"` + LastStep *string `json:"last_step"` request *FlowRequest ctime time.Time diff --git a/pkg/auth/provider/hass/provider.go b/pkg/auth/provider/hass/provider.go index edb56fa..df95a5d 100644 --- a/pkg/auth/provider/hass/provider.go +++ b/pkg/auth/provider/hass/provider.go @@ -39,7 +39,7 @@ func (h *HAUser) ProviderUserData() interface{} { return h.UserData() } type HomeAssistantProvider struct { provider.AuthProviderBase `json:"-"` - Users []HAUser `json:"users"` + Users []HAUser `json:"users"` } func NewHAProvider(s storage.Store) (provider.AuthProvider, error) { @@ -127,4 +127,3 @@ func (hap *HomeAssistantProvider) FlowSchema() []provider.FlowSchemaItem { func init() { provider.Register(HomeAssistant, NewHAProvider) } - diff --git a/pkg/auth/provider/provider.go b/pkg/auth/provider/provider.go index 8dbd09d..3a2e903 100644 --- a/pkg/auth/provider/provider.go +++ b/pkg/auth/provider/provider.go @@ -49,5 +49,3 @@ type FlowSchemaItem struct { Name string `json:"name"` Required bool `json:"required"` } - - diff --git a/pkg/auth/provider/trustednets/trustednets.go b/pkg/auth/provider/trustednets/trustednets.go index d284602..ccc3443 100644 --- a/pkg/auth/provider/trustednets/trustednets.go +++ b/pkg/auth/provider/trustednets/trustednets.go @@ -46,7 +46,7 @@ func New(s storage.Store) (provider.AuthProvider, error) { func (hap *TrustedNetworksProvider) ValidateCreds(r *http.Request, rm map[string]interface{}) (provider.ProviderUser, bool) { /* - if req.RemoteAddr in allowed then do the thing + if req.RemoteAddr in allowed then do the thing */ return nil, false } @@ -73,4 +73,3 @@ func (hap *TrustedNetworksProvider) FlowSchema() []provider.FlowSchemaItem { func init() { provider.Register(TrustedNetworks, New) } - diff --git a/pkg/auth/session.go b/pkg/auth/session.go index e8988b9..d24ca93 100644 --- a/pkg/auth/session.go +++ b/pkg/auth/session.go @@ -66,20 +66,20 @@ func (ss *SessionStore) verify(tr *TokenRequest, r *http.Request) (provider.Prov } type Credential struct { - ID CredID `json:"id"` - UserID UserID `json:"user_id"` - AuthProviderType string `json:"auth_provider_type"` - AuthProviderID *string `json:"auth_provider_id"` - DataRaw json.RawMessage `json:"data,omitempty"` - user provider.ProviderUser + ID CredID `json:"id"` + UserID UserID `json:"user_id"` + AuthProviderType string `json:"auth_provider_type"` + AuthProviderID *string `json:"auth_provider_id"` + DataRaw json.RawMessage `json:"data,omitempty"` + user provider.ProviderUser } func (cred *Credential) MarshalJSON() ([]byte, error) { rm := map[string]interface{}{ - "id": cred.ID, - "user_id": cred.UserID, + "id": cred.ID, + "user_id": cred.UserID, "auth_provider_type": cred.user.ProviderType(), - "auth_provider_id": cred.user.ProviderID(), + "auth_provider_id": cred.user.ProviderID(), } providerData := cred.user.ProviderUserData() @@ -123,7 +123,7 @@ type GrantType string const ( GTAuthorizationCode GrantType = "authorization_code" - GTRefreshToken GrantType = "refresh_token" + GTRefreshToken GrantType = "refresh_token" ) type ClientID string @@ -135,8 +135,8 @@ func (c *ClientID) IsValid() bool { type TokenRequest struct { ClientID ClientID `form:"client_id"` - Code TokenID `form:"code"` - GrantType GrantType `form:"grant_type"` + Code TokenID `form:"code"` + GrantType GrantType `form:"grant_type"` } func (a *Authenticator) TokenHandler(c echo.Context) error { @@ -163,7 +163,7 @@ func (a *Authenticator) TokenHandler(c echo.Context) error { return c.JSON(http.StatusUnauthorized, AuthError{Error: "access_denied", Description: "bad user"}) } - if err := user.allowedToAuth(); err != nil { + if err := user.allowedToAuth(); err != nil { return c.JSON(http.StatusUnauthorized, AuthError{Error: "access_denied", Description: err.Error()}) } return c.String(http.StatusOK, "token good I guess") diff --git a/pkg/auth/store.go b/pkg/auth/store.go index b52f119..027a9c8 100644 --- a/pkg/auth/store.go +++ b/pkg/auth/store.go @@ -1,8 +1,8 @@ package auth import ( - "fmt" "encoding/json" + "fmt" "dynatron.me/x/blasphem/pkg/storage" ) @@ -11,13 +11,12 @@ const ( AuthStoreKey = "auth" ) - type AuthStore interface { } type authStore struct { - Users []User `json:"users"` - Groups interface {} `json:"groups"` + Users []User `json:"users"` + Groups interface{} `json:"groups"` Credentials []Credential `json:"credentials"` userMap map[UserID]*User diff --git a/pkg/auth/user.go b/pkg/auth/user.go index 820c2b9..219e285 100644 --- a/pkg/auth/user.go +++ b/pkg/auth/user.go @@ -11,18 +11,18 @@ type GroupID string type CredID string type User struct { - ID UserID `json:"id"` - GroupIDs []GroupID `json:"group_ids"` - Data interface{} `json:"data,omitempty"` + ID UserID `json:"id"` + GroupIDs []GroupID `json:"group_ids"` + Data interface{} `json:"data,omitempty"` UserMetadata } type UserMetadata struct { - Active bool `json:"is_active"` - Owner bool `json:"is_owner"` - LocalOnly bool `json:"local_only"` - SystemGenerated bool `json:"system_generated"` - Name string `json:"name"` + Active bool `json:"is_active"` + Owner bool `json:"is_owner"` + LocalOnly bool `json:"local_only"` + SystemGenerated bool `json:"system_generated"` + Name string `json:"name"` } func (u *User) allowedToAuth() error { @@ -38,5 +38,3 @@ func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) { panic("not implemented") return &User{}, nil } - -