Documentation ¶
Index ¶
- func ExpiresIn(expiry time.Time) (expiresInSeconds int64, ok bool)
- type Config
- type Persistence
- type Provider
- type Server
- type Service
- func (s *Service) AddDevice(ctx context.Context, request *pb.AddDeviceRequest) (*pb.AddDeviceResponse, error)
- func (s *Service) GetUserDevices(request *pb.GetUserDevicesRequest, ...) error
- func (s *Service) HandleAccessToken(ctx *fasthttp.RequestCtx)
- func (s *Service) HandleAuthorizationCode(ctx *fasthttp.RequestCtx)
- func (s *Service) HandleJWKs(ctx *fasthttp.RequestCtx)
- func (s *Service) HandleOAuthCallback(ctx *fasthttp.RequestCtx)
- func (s *Service) Healthcheck(ctx *fasthttp.RequestCtx)
- func (s *Service) RefreshToken(ctx context.Context, request *pb.RefreshTokenRequest) (*pb.RefreshTokenResponse, error)
- func (s *Service) RemoveDevice(ctx context.Context, request *pb.RemoveDeviceRequest) (*pb.RemoveDeviceResponse, error)
- func (s *Service) SignIn(ctx context.Context, request *pb.SignInRequest) (*pb.SignInResponse, error)
- func (s *Service) SignOff(ctx context.Context, request *pb.SignOffRequest) (*pb.SignOffResponse, error)
- func (s *Service) SignOut(ctx context.Context, request *pb.SignOutRequest) (*pb.SignOutResponse, error)
- func (s *Service) SignUp(ctx context.Context, request *pb.SignUpRequest) (*pb.SignUpResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Log log.Config Device provider.Config `envconfig:"DEVICE" env:"DEVICE"` SDK oauth.Config `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.
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.
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 cloud2cloud connector.
func (*Service) GetUserDevices ¶
func (s *Service) GetUserDevices(request *pb.GetUserDevicesRequest, srv pb.AuthorizationService_GetUserDevicesServer) error
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 cloud2cloud 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.