application

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextWithAuthenticatedUser added in v0.1.3

func NewContextWithAuthenticatedUser(ctx context.Context, user *User) context.Context

Types

type ArchiveService

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

func (*ArchiveService) CreateArchive

func (service *ArchiveService) CreateArchive(ctx context.Context, owner string, name string) (dbArchive, error)

type AuthenticationController

type AuthenticationController struct {
	UserRepository *UserRepository
}

func (*AuthenticationController) RegisterRoutes

func (c *AuthenticationController) RegisterRoutes(r chi.Router)

type Config

type Config struct {
	DataPath string

	GRPC GRPCConfig
	HTTP HTTPConfig
}

func (Config) Listen

func (c Config) Listen() (ServerListeners, error)

type GRPCConfig

type GRPCConfig struct {
	Enable bool

	Port uint16

	ListenOnAllInterfaces bool
}

type HTTPConfig

type HTTPConfig struct {
	Enable bool

	Port       uint16
	PublicPath string

	ListenOnAllInterfaces bool
}

type PersonalAccessToken

type PersonalAccessToken struct {
	ID             int64
	UserID         int64
	Name           string
	TokenSalt      string
	TokenHash      string
	Token          string
	TokenLastEight string
}

type PersonalAccessTokenRepository

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

func (*PersonalAccessTokenRepository) CreatePersonalAccessToken

func (r *PersonalAccessTokenRepository) CreatePersonalAccessToken(token PersonalAccessToken) (PersonalAccessToken, error)

func (*PersonalAccessTokenRepository) FindPersonalAccessTokensByLastEight

func (r *PersonalAccessTokenRepository) FindPersonalAccessTokensByLastEight(
	tokenLastEight string,
) ([]PersonalAccessToken, error)

type Server

type Server struct {
	UserRepository *UserRepository

	ArchiveService                *ArchiveService
	PersonalAccessTokenRepository *PersonalAccessTokenRepository
	UserService                   *UserService

	ArchiveApplicationService             *archiveApplicationService
	ArchivePermissionApplicationService   *archivePermissionApplicationService
	PersonalAccessTokenApplicationService *personalAccessTokenApplicationService

	SessionBasedAuthentication *SessionBasedAuthentication

	Config Config

	HTTP struct {
		Listeners []net.Listener
	}
}

Server is an application server

func CreateServer

func CreateServer(config Config) (*Server, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, listeners ServerListeners) error

type ServerListeners

type ServerListeners struct {
	GRPC struct {
		Listeners []net.Listener
	}
	HTTP struct {
		Listeners []net.Listener
	}
}

type Session

type Session struct {
	ID     int64
	Token  string
	UserID int64
}

type SessionBasedAuthentication

type SessionBasedAuthentication struct {
	UserService *UserService

	UserRepository    *UserRepository
	SessionRepository *SessionRepository
}

func (*SessionBasedAuthentication) Middleware

func (a *SessionBasedAuthentication) Middleware() func(http.Handler) http.Handler

func (*SessionBasedAuthentication) RegisterRoutes

func (a *SessionBasedAuthentication) RegisterRoutes(r chi.Router)

type SessionRepository

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

func (*SessionRepository) Create

func (r *SessionRepository) Create(userID int64) (string, error)

func (*SessionRepository) Delete

func (r *SessionRepository) Delete(id int64) error

func (*SessionRepository) GetSessionByToken

func (r *SessionRepository) GetSessionByToken(token string) (*Session, error)

type User

type User struct {
	ID       int64
	Email    string
	Password string
}

func (User) ByEmailResourceName added in v0.1.3

func (u User) ByEmailResourceName() string

func (User) ResourceName

func (u User) ResourceName() string

type UserRepository

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

func (*UserRepository) CreateUser

func (r *UserRepository) CreateUser(user User) (User, error)

func (*UserRepository) GetUserByUserID

func (r *UserRepository) GetUserByUserID(id int64) (*User, error)

func (*UserRepository) GetUserByUserName

func (r *UserRepository) GetUserByUserName(username string) (*User, error)

type UserService

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

func (*UserService) CreateUser

func (s *UserService) CreateUser(emailAddress string, password string) (User, error)

func (*UserService) VerifyLogin

func (s *UserService) VerifyLogin(context context.Context, username string, password string) (*User, error)

Jump to

Keyboard shortcuts

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