Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions internal/auth/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,18 @@
package auth

import (
"context"
"encoding/json"
"os"
"path/filepath"

"namespacelabs.dev/foundation/internal/clerk"
"namespacelabs.dev/foundation/internal/fnerrors"
"namespacelabs.dev/foundation/internal/workspace/dirs"
)

const userAuthJson = "auth.json"

type UserAuth struct {
Username string `json:"username,omitempty"`
Org string `json:"org,omitempty"` // The organization this user is acting as. Only really relevant for robot accounts which authenticate against a repository.
InternalOpaque []byte `json:"opaque,omitempty"`

Clerk *clerk.State `json:"clerk,omitempty"`
IsGithubAction bool `json:"is_github_action,omitempty"`
}

func StoreMarshalledUser(ctx context.Context, userAuthData []byte) error {
configDir, err := dirs.Ensure(dirs.Config())
if err != nil {
return err
}

if err := os.WriteFile(filepath.Join(configDir, userAuthJson), userAuthData, 0600); err != nil {
return fnerrors.Newf("failed to write user auth data: %w", err)
}

return nil
Username string `json:"username,omitempty"`
}

func LoadUser() (*UserAuth, error) {
Expand Down
Loading