public

package
v0.0.0-...-95aad33 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: CC0-1.0 Imports: 22 Imported by: 0

Documentation

Overview

Package public (ssas/service/api/public) contains API functions, middleware, and a router designed to:

  1. Be accessible to the public
  2. Offer system self-registration and self-management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommonClaims

func CreateCommonClaims(tokenType, oktaID, systemID, clientID, data, systemXData string, groupIDs []string) (claims service.CommonClaims)

func MintRegistrationToken

func MintRegistrationToken(oktaID string, groupIDs []string) (*jwt.Token, string, error)

MintRegistrationToken generates a tokenstring for system self-registration endpoints

func RegisterSystem

func RegisterSystem(w http.ResponseWriter, r *http.Request)
	RegisterSystem is mounted at POST /auth/register and allows for self-registration.  It requires that a
	registration token containing one or more group ids be presented and parsed by middleware, with the
    GroupID[s] placed in the context key "rd".

func ResetSecret

func ResetSecret(w http.ResponseWriter, r *http.Request)

ResetSecret is mounted at POST /reset and allows the authenticated manager of a system to rotate their secret.

func Server

func Server() *service.Server

func SetMockAccessTokenCreator

func SetMockAccessTokenCreator(t *testing.T, other *MockTokenCreator)

SetMockTokenCreator sets the current token creator to the one that's supplied in this function. It leverages the Cleanup() func to ensure the original token creator is restored at the end of the test.

func ValidateSecret

func ValidateSecret(system ssas.System, secret string, w http.ResponseWriter, r *http.Request) (err error)

Types

type AccessTokenCreator

type AccessTokenCreator struct {
}

AccessTokenCreator is an implementation of TokenCreator that creates access tokens.

func (AccessTokenCreator) GenerateToken

func (accessTokenCreator AccessTokenCreator) GenerateToken(claims service.CommonClaims) (*jwt.Token, string, error)

GenerateToken generates a tokenstring that expires in server.tokenTTL time

type JWKS

type JWKS struct {
	Keys []Key `json:"keys"`
}

type Key

type Key struct {
	E   string `json:"e"`
	N   string `json:"n"`
	KTY string `json:"kty"`
	Use string `json:"use,omitempty"`
}

type MockTokenCreator

type MockTokenCreator struct {
	mock.Mock
}

MockTokenCreator is an autogenerated mock type for the TokenCreator type

func NewMockTokenCreator

func NewMockTokenCreator(t mockConstructorTestingTNewMockTokenCreator) *MockTokenCreator

NewMockTokenCreator creates a new instance of MockTokenCreator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockTokenCreator) GenerateToken

func (_m *MockTokenCreator) GenerateToken(claims service.CommonClaims) (*jwt.Token, string, error)

GenerateToken provides a mock function with given fields: claims

type RegistrationRequest

type RegistrationRequest struct {
	ClientID    string   `json:"client_id"`
	ClientName  string   `json:"client_name"`
	Scope       string   `json:"scope,omitempty"`
	JSONWebKeys JWKS     `json:"jwks"`
	IPs         []string `json:"ips"`
}

type ResetRequest

type ResetRequest struct {
	ClientID string `json:"client_id"`
}

type SystemResponse

type SystemResponse struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	ExpiresAt    int64  `json:"client_secret_expires_at"`
	ClientName   string `json:"client_name"`
}

type TokenCreator

type TokenCreator interface {
	GenerateToken(claims service.CommonClaims) (*jwt.Token, string, error)
}

TokenCreator provides methods for the creation of tokens. Currently only AccessTokenCreator implements this interface. TO DO: Define a MFATokenCreator & a RegistrationTokenCreator that will implement TokenCreator interface, then add CreateCommonClaims to this interface that all 3 can share.

func GetAccessTokenCreator

func GetAccessTokenCreator() TokenCreator

type TokenResponse

type TokenResponse struct {
	Scope       string `json:"scope,omitempty"`
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   string `json:"expires_in"`
}

Jump to

Keyboard shortcuts

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