server

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SessionKey is the name for the HTTP cookie containing the session
	SessionKey = "GOSESSION"

	// SlackOpenIDConnectURL is the base URL for Slack's OIDC discovery
	SlackOpenIDConnectURL = "https://slack.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the API server

func New

func New(ctx context.Context, logger hclog.Logger, c *config.Config) (*Server, error)

New creates a new API server

func NewTestServer

func NewTestServer(opts *ServerOptions) *Server

NewTestServer returns a Server suitable for use in tests

func (*Server) FetchIDToken

func (s *Server) FetchIDToken(ctx context.Context, code string) (*oauth2.Token, error)

FetchIDToken exchanges an authorization code for a OIDC token

func (*Server) GenerateAuthCodeURL

func (s *Server) GenerateAuthCodeURL(state, nonce string) string

GenerateAuthCodeURL generates the OIDC URL for Single Sign On with Slack

func (*Server) GetBaseURL

func (s *Server) GetBaseURL() string

GetBaseURL returns the base URL of the server

func (*Server) GetCache

func (s *Server) GetCache() *ristretto.Cache

GetCache retrieves the in-memory cache

func (*Server) GetChatRouletteConfig

func (s *Server) GetChatRouletteConfig() config.ChatRouletteConfig

GetConfig retrieves the chat roulette config

func (*Server) GetDB

func (s *Server) GetDB() *gorm.DB

GetDB retrieves the gorm DB

func (*Server) GetHTTPClient

func (s *Server) GetHTTPClient() *http.Client

GetHTTPClient retrieves the http client

func (*Server) GetMux

func (s *Server) GetMux() *mux.Router

GetMux retrieves the router

func (*Server) GetSession

func (s *Server) GetSession(r *http.Request) (*sessions.Session, error)

GetSession retrieves an existing or new session

func (*Server) GetSlackBotUserID

func (s *Server) GetSlackBotUserID() string

GetSlackBotUserID returns the user_id of the chat roulette Slack bot

func (*Server) GetSlackClient

func (s *Server) GetSlackClient() *slack.Client

GetSlackClient retrieves the Slack client

func (*Server) GetSlackSigningSecret

func (s *Server) GetSlackSigningSecret() string

GetSlackSigningSecret retrieves the Slack signing secret from the config

func (*Server) IsDevMode

func (s *Server) IsDevMode() bool

IsDevMode returns true if the Server is running in Dev Mode

func (*Server) Start

func (s *Server) Start(ctx context.Context, ch chan error)

Start runs the HTTP server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context, wg *sync.WaitGroup, stop chan os.Signal, ch chan error)

Stop gracefully stops the HTTP server

func (*Server) VerifyIDToken

func (s *Server) VerifyIDToken(ctx context.Context, token string) (*oidc.IDToken, error)

VerifyIDToken verifies that a raw ID token is valid

type ServerOptions

type ServerOptions struct {
	Config         *config.Config
	DB             *gorm.DB
	DevMode        bool
	HTTPClient     *http.Client
	HTTPServer     *http.Server
	SlackBotUserID string
	SlackClient    *slack.Client
	SessionsStore  *sessions.CookieStore
}

Directories

Path Synopsis
api
v1

Jump to

Keyboard shortcuts

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