server

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorToCode added in v0.21.1

func ErrorToCode(err error) codes.Code

ErrorToCode maps an error to a gRPC code for logging. It wraps the default behavior and adds handling of context errors.

func GRPCCodeToLevel added in v0.21.1

func GRPCCodeToLevel(code codes.Code) logging.Level

GRPCCodeToLevel overrides the log level of various gRPC codes. We're currently not doing very granular error handling, so we get quite a lot of codes.Unknown errors, which we do not want to emit as error logs.

func HTTPErrorHandler added in v0.21.1

func HTTPErrorHandler(ctx context.Context, mux *gateway.ServeMux, marshaler gateway.Marshaler, w http.ResponseWriter, r *http.Request, err error)

HTTPErrorHandler wraps gateway.DefaultHTTPErrorHandler to map gRPC unknown errors (i.e. errors without an explicit code) to HTTP status code 400 instead of 500.

func IsAuthenticated

func IsAuthenticated(next echo.HandlerFunc) echo.HandlerFunc

IsAuthenticated is a middleware that checks if the user has already been authenticated previously.

Types

type Authenticator

type Authenticator struct {
	*oidc.Provider
	oauth2.Config
}

Authenticator is used to authenticate our users. Refereance link - https://auth0.com/docs/quickstart/webapp/golang/01-login for sample auth setup.

func (*Authenticator) VerifyIDToken

func (a *Authenticator) VerifyIDToken(ctx context.Context, token *oauth2.Token) (*oidc.IDToken, error)

VerifyIDToken verifies that an *oauth2.Token is a valid *oidc.IDToken.

type Config

type Config struct {
	HTTPPort         int
	GRPCPort         int
	AuthDomain       string
	AuthClientID     string
	AuthClientSecret string
	AuthCallbackURL  string
	SessionSecret    string
}

type Server

type Server struct {
	adminv1.UnsafeAdminServiceServer
	// contains filtered or unexported fields
}

func New

func New(logger *zap.Logger, adm *admin.Service, conf Config) (*Server, error)

func (*Server) CreateOrganization

CreateOrganization implements AdminService. (POST /organizations)

func (*Server) CreateProject

(POST /v1/organizations/{organization}/projects)

func (*Server) DeleteOrganization

(DELETE /organizations/{name})

func (*Server) DeleteProject

(DELETE /v1/organizations/{organization}/project/{name})

func (*Server) FindOrganization

(GET /organizations/{name})

func (*Server) FindOrganizations

FindOrganizations implements AdminService. (GET /v1/organizations)

func (*Server) FindProject

(GET /v1/organizations/{organization}/project/{name})

func (*Server) FindProjects

FindProjects implements AdminService. (GET /v1/organizations/{organization}/projects)

func (*Server) HTTPHandler added in v0.21.1

func (s *Server) HTTPHandler(ctx context.Context) (http.Handler, error)

HTTPHandler HTTP handler serving REST gateway.

func (*Server) IsAuthenticated1 added in v0.21.1

func (s *Server) IsAuthenticated1(next http.HandlerFunc) http.HandlerFunc

IsAuthenticated is a middleware that checks if the user has already been authenticated previously.

func (*Server) Ping added in v0.21.1

Ping implements AdminService

func (*Server) ServeGRPC added in v0.21.1

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

ServeGRPC Starts the gRPC server.

func (*Server) ServeHTTP added in v0.21.1

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

Starts the HTTP server.

func (*Server) UpdateOrganization

(PUT /organizations/{name})

func (*Server) UpdateProject

(PUT /v1/organizations/{organization}/project/{name})

Jump to

Keyboard shortcuts

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