service

package
v0.0.0-...-7b6f2c3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpiresIn

func ExpiresIn(expiry time.Time) (expiresInSeconds int64, ok bool)

ExpiresIn calculates the remaining time until expiration. No expiration is denoted by expiry = 0 for which -1 is returned. When expired, ok is false.

Types

type Config

type Config struct {
	Log log.Config

	Device provider.Config      `envconfig:"DEVICE" env:"DEVICE"`
	SDK    provider.OAuthConfig `envconfig:"SDK_OAUTH" env:"SDK_OAUTH"`

	MongoDB  mongodb.Config     `envconfig:"MONGODB" env:"MONGODB"`
	Listen   certManager.Config `envconfig:"LISTEN" env:"LISTEN"`
	Dial     certManager.Config `envconfig:"DIAL" env:"DIAL"`
	Addr     string             `envconfig:"ADDRESS" env:"ADDRESS" default:"0.0.0.0:9100"`
	HTTPAddr string             `envconfig:"HTTP_ADDRESS" env:"HTTP_ADDRESS" default:"0.0.0.0:9200"`
}

Config provides defaults and enables configuring via env variables.

func (Config) String

func (c Config) String() string

String return string representation of Config

type Persistence

type Persistence = interface {
	NewTransaction(ctx context.Context) persistence.PersistenceTx
	Clear(ctx context.Context) error
	Close(ctx context.Context) error
}

Provider defines interface for authentification against auth service

type Provider

type Provider = interface {
	Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*provider.Token, error)
	Refresh(ctx context.Context, refreshToken string) (*provider.Token, error)
	AuthCodeURL(csrfToken string) string
}

Provider defines interface for authentification against auth service

type Server

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

Server is an HTTP server for the Service.

func New

func New(cfg Config, persistence Persistence, deviceProvider, sdkProvider provider.Provider) (*Server, error)

New creates the service's HTTP server.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the service's GRPC and HTTP server and blocks.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown ends serving

type Service

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

Service holds dependencies of the authorization Service.

func (*Service) AddDevice

func (s *Service) AddDevice(ctx context.Context, request *pb.AddDeviceRequest) (*pb.AddDeviceResponse, error)

AddDevice adds a device to user. It is used by openapi connector.

func (*Service) GetUserDevices

GetUserDevices returns a list of user's devices if the access token is valid.

func (*Service) HandleAccessToken

func (s *Service) HandleAccessToken(ctx *fasthttp.RequestCtx)

HandleAccessToken requests the access token for the user

func (*Service) HandleAuthorizationCode

func (s *Service) HandleAuthorizationCode(ctx *fasthttp.RequestCtx)

HandleAuthorizationCode requests the authorization code for the device on behalf of the user

func (*Service) HandleJWKs

func (s *Service) HandleJWKs(ctx *fasthttp.RequestCtx)

func (*Service) HandleOAuthCallback

func (s *Service) HandleOAuthCallback(ctx *fasthttp.RequestCtx)

func (*Service) Healthcheck

func (s *Service) Healthcheck(ctx *fasthttp.RequestCtx)

func (*Service) RefreshToken

func (s *Service) RefreshToken(ctx context.Context, request *pb.RefreshTokenRequest) (*pb.RefreshTokenResponse, error)

RefreshToken renews AccessToken using RefreshToken.

func (*Service) RemoveDevice

func (s *Service) RemoveDevice(ctx context.Context, request *pb.RemoveDeviceRequest) (*pb.RemoveDeviceResponse, error)

RemoveDevice remove a device from user. It is used by openapi connector.

func (*Service) SignIn

func (s *Service) SignIn(ctx context.Context, request *pb.SignInRequest) (*pb.SignInResponse, error)

SignIn verifies device's AccessToken and Expiry required for signing in.

func (*Service) SignOff

func (s *Service) SignOff(ctx context.Context, request *pb.SignOffRequest) (*pb.SignOffResponse, error)

SignOff invalidates device's Access Token.

func (*Service) SignOut

func (s *Service) SignOut(ctx context.Context, request *pb.SignOutRequest) (*pb.SignOutResponse, error)

SignOut verifies device's AccessToken and Expiry required for signing out.

func (*Service) SignUp

func (s *Service) SignUp(ctx context.Context, request *pb.SignUpRequest) (*pb.SignUpResponse, error)

SignUp exchanges Auth Code for Access Token via OAuth. The Access Token can be used for signing the device in/out, or for authorizing the device to act as the user.

Jump to

Keyboard shortcuts

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