auth

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package auth provides authentication-related business logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigService

type ConfigService struct {
	// contains filtered or unexported fields
}

ConfigService handles configuration operations.

func NewConfigService

func NewConfigService(config ports.ConfigStore, secrets ports.SecretStore) *ConfigService

NewConfigService creates a new config service.

func (*ConfigService) EnsureConfig

func (s *ConfigService) EnsureConfig() (*domain.Config, bool, error)

EnsureConfig ensures config exists, regenerating if necessary.

func (*ConfigService) GetAPIKey

func (s *ConfigService) GetAPIKey() (string, error)

GetAPIKey retrieves the API key from keystore.

func (*ConfigService) GetClientID

func (s *ConfigService) GetClientID() (string, error)

GetClientID retrieves the client ID from keystore.

func (*ConfigService) GetClientSecret

func (s *ConfigService) GetClientSecret() (string, error)

GetClientSecret retrieves the client secret from keystore.

func (*ConfigService) GetOrgID

func (s *ConfigService) GetOrgID() (string, error)

GetOrgID retrieves the organization ID from keystore.

func (*ConfigService) GetStatus

func (s *ConfigService) GetStatus() (*domain.ConfigStatus, error)

GetStatus returns the current configuration status.

func (*ConfigService) HasKeystoreCredentials

func (s *ConfigService) HasKeystoreCredentials() bool

HasKeystoreCredentials checks if credentials are stored in keystore.

func (*ConfigService) IsConfigured

func (s *ConfigService) IsConfigured() bool

IsConfigured checks if the application is configured.

func (*ConfigService) ResetConfig

func (s *ConfigService) ResetConfig() error

ResetConfig clears all configuration and secrets.

func (*ConfigService) SetupConfig

func (s *ConfigService) SetupConfig(region, clientID, clientSecret, apiKey, orgID string) error

SetupConfig saves the initial configuration.

func (*ConfigService) UpdateCallbackPort

func (s *ConfigService) UpdateCallbackPort(port int) error

UpdateCallbackPort updates the OAuth callback port.

type GrantService

type GrantService struct {
	// contains filtered or unexported fields
}

GrantService handles grant operations.

func NewGrantService

func NewGrantService(client ports.NylasClient, grantStore ports.GrantStore, config ports.ConfigStore) *GrantService

NewGrantService creates a new grant service.

func (*GrantService) AddGrant

func (s *GrantService) AddGrant(grantID, email string, provider domain.Provider, setDefault bool) error

AddGrant manually adds a grant to local storage.

func (*GrantService) FetchGrantFromNylas

func (s *GrantService) FetchGrantFromNylas(ctx context.Context, grantID string) (*domain.Grant, error)

FetchGrantFromNylas fetches grant details directly from Nylas API.

func (*GrantService) GetCurrentGrant

func (s *GrantService) GetCurrentGrant(ctx context.Context) (*domain.GrantStatus, error)

GetCurrentGrant returns the current (default) grant info.

func (*GrantService) GetDefaultGrantID

func (s *GrantService) GetDefaultGrantID() (string, error)

GetDefaultGrantID returns the default grant ID.

func (*GrantService) ListGrants

func (s *GrantService) ListGrants(ctx context.Context) ([]domain.GrantStatus, error)

ListGrants returns all grants with their status.

func (*GrantService) SwitchGrant

func (s *GrantService) SwitchGrant(grantID string) error

SwitchGrant switches the default grant to the specified ID.

func (*GrantService) SwitchGrantByEmail

func (s *GrantService) SwitchGrantByEmail(email string) error

SwitchGrantByEmail switches the default grant by email.

func (*GrantService) ValidateGrant

func (s *GrantService) ValidateGrant(ctx context.Context, grantID string) (bool, error)

ValidateGrant checks if a grant is valid.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles authentication operations.

func NewService

func NewService(
	client ports.NylasClient,
	grantStore ports.GrantStore,
	config ports.ConfigStore,
	server ports.OAuthServer,
	browser ports.Browser,
) *Service

NewService creates a new auth service.

func (*Service) Login

func (s *Service) Login(ctx context.Context, provider domain.Provider) (*domain.Grant, error)

Login performs OAuth login with the specified provider.

func (*Service) Logout

func (s *Service) Logout(ctx context.Context) error

Logout revokes the current grant.

func (*Service) LogoutGrant

func (s *Service) LogoutGrant(ctx context.Context, grantID string) error

LogoutGrant revokes a specific grant.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL