platform

package
v0.0.0-...-78b922b Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: Apache-2.0 Imports: 34 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ContextOAuthRoles             string = "OAuthRoles"
	ContextOAuthClientToken       string = "OAuthClientToken"
	ContextOAuthPreferredUsername string = "OAuthPreferredUsername"
	ContextOAuthIssuer            string = "OAuthIssuer"
	ContextLocalJwtClaims         string = "LocalJwtClaims"
)

Variables

View Source
var (
	Database              PlatformDatabases
	ErrNoEntryFoundInDB   = errors.New("No entry found in the database")
	ErrBoltDbIsNotEnabled = errors.New("Bolt DB is not enabled")
)
View Source
var (
	ErrGRPCMissingMetadata = status.Errorf(codes.InvalidArgument, "missing grpc auth metadata")
	ErrGRPCInvalidToken    = status.Errorf(codes.Unauthenticated, "invalid token")
)
View Source
var (
	ErrLocalJwtInvalidToken               = errors.New("local JWT token is invalid")
	ErrLocalJwtNotEnabled                 = errors.New("local JWT authentication is not enabled in the configuration")
	ErrLocalJwtSigningKeyNotConfigured    = errors.New("JWT signing key is not configured")
	ErrLocalJwtSigningMethodNotConfigured = errors.New("JWT signing method is not configured or invalid")

	LocalJwt localJwtOrganizer
)
View Source
var (
	ErrOAuthClientConfigNotFound   = errors.New("oauth client config not found")
	ErrOAuthIncorrectIDPStatusCode = errors.New("incorrect status code on token request to idp")

	OAuth oAuthOrganiser
)
View Source
var (
	Vault platformVault

	ErrVaultNotEnabled              = errors.New("Vault not enabled")
	ErrVaultUnableToReadSecrets     = errors.New("Unable to read secrets from Vault")
	ErrVaultNoAuthMethodsConfigured = errors.New("No auth methods configured for Vault")
)
View Source
var (
	ErrBoltDBNoDBObject = errors.New("no db object")
)
View Source
var (
	ErrHttpClientConfigNotFound = errors.New("http client config not found")
)
View Source
var (
	ErrInvalidConfigFilePath = errors.New("Invalid config file path for settings platform.log.logfilepath")
)
View Source
var (
	JsonMarshaller jsonMarshallerOrganizer
)

Functions

func AllowCorsForLocalDevelopment

func AllowCorsForLocalDevelopment(inner http.Handler) http.Handler

func CreateHttpClient

func CreateHttpClient(id string) (*http.Client, error)

func GetComponentConfiguration

func GetComponentConfiguration(key string, object interface{}) error

func InitializeLogger

func InitializeLogger()

func SetPlatformConfiguration

func SetPlatformConfiguration(conf Config)

func SetupBoltDB

func SetupBoltDB() error

SetupBoltDB initializes BoltDB based on the platform configuration. This function must be called explicitly before using any BoltDB functions. Returns an error if BoltDB is not enabled in the configuration or if initialization fails.

func StartGrpcServer

func StartGrpcServer(services []GRPCService)

func StartGrpcServerWithWeb

func StartGrpcServerWithWeb(services []GRPCService, webDirectoryName string, webAssets *embed.FS)

func StartHttpServer

func StartHttpServer(routes Routes) error

func StartHttpServerWithHtmlHosting deprecated

func StartHttpServerWithHtmlHosting(routes Routes, dist embed.FS) error

Deprecated: Use StartHttpServerWithWeb

func StartHttpServerWithWeb

func StartHttpServerWithWeb(routes Routes, dist embed.FS) error

Types

type Config

type Config struct {
	Log struct {
		Level              string
		FileLoggingEnabled bool
		FilePath           string
		//MegaBytes
		MaxSize    int
		MaxBackups int
		// Days
		MaxAge int
	}

	HTTP struct {
		Server struct {
			ListeningAddress             string
			TLSCertFileName              string
			TLSKeyFileName               string
			TLSEnabled                   bool
			AllowCorsForLocalDevelopment bool
		}

		Clients []httpClientConfig
	}

	Grpc struct {
		Server struct {
			ListeningAddress string
			TLSCertFileName  string
			TLSKeyFileName   string
			TLSEnabled       bool

			// For things like login paths that wonth have security
			UnAuthenticatedPaths []string
		}
	}

	Auth struct {
		Server struct {
			OAuth struct {
				Enabled           bool
				IdpWellKnownURL   string
				ClientID          string
				AllowedAlgorithms []string
			}
			// If you have a proper IDP use OAuth and if you just want local tokens use LocalJwt
			LocalJwt struct {
				Enabled       bool
				JwtSigningKey string
				// JWT signing method, e.g., "HS256", "HS384", "HS512"
				JwtSigningMethod string
				JwtExpiration    int64 // In Minutes
			}

			Basic struct {
				Enabled      bool
				AllowedUsers map[string]string
			}
		}

		Client struct {
			OAuth []clientTokenConfig
		}
	}

	Component struct {
		ComponentName string
	}

	Database struct {
		BoltDB struct {
			Enabled  bool
			FileName string
		}
	}

	Vault struct {
		Enabled            bool
		AddressList        []string
		IsLocalAgent       bool
		InsecureSkipVerify bool
		CaCert             string
		TimeoutSeconds     int64
		MaxRetries         int
		Token              struct {
			Enabled   bool
			TokenPath string
			Token     string
		}
		Cert struct {
			Enabled  bool
			CertFile string
			KeyFile  string
		}
	}
}

Config ... Platform configuration

func GetPlatformConfiguration

func GetPlatformConfiguration() (*Config, error)

type GRPCService

type GRPCService interface {
	Register(server *grpc.Server)
}

type IDPWellKnownConfiguration

type IDPWellKnownConfiguration struct {
	Issuer                                                    string   `json:"issuer"`
	AuthorizationEndpoint                                     string   `json:"authorization_endpoint"`
	TokenEndpoint                                             string   `json:"token_endpoint"`
	IntrospectionEndpoint                                     string   `json:"introspection_endpoint"`
	UserinfoEndpoint                                          string   `json:"userinfo_endpoint"`
	EndSessionEndpoint                                        string   `json:"end_session_endpoint"`
	JwksURI                                                   string   `json:"jwks_uri"`
	CheckSessionIframe                                        string   `json:"check_session_iframe"`
	GrantTypesSupported                                       []string `json:"grant_types_supported"`
	ResponseTypesSupported                                    []string `json:"response_types_supported"`
	SubjectTypesSupported                                     []string `json:"subject_types_supported"`
	IDTokenSigningAlgValuesSupported                          []string `json:"id_token_signing_alg_values_supported"`
	IDTokenEncryptionAlgValuesSupported                       []string `json:"id_token_encryption_alg_values_supported"`
	IDTokenEncryptionEncValuesSupported                       []string `json:"id_token_encryption_enc_values_supported"`
	UserinfoSigningAlgValuesSupported                         []string `json:"userinfo_signing_alg_values_supported"`
	RequestObjectSigningAlgValuesSupported                    []string `json:"request_object_signing_alg_values_supported"`
	RequestObjectEncryptionAlgValuesSupported                 []string `json:"request_object_encryption_alg_values_supported"`
	RequestObjectEncryptionEncValuesSupported                 []string `json:"request_object_encryption_enc_values_supported"`
	ResponseModesSupported                                    []string `json:"response_modes_supported"`
	RegistrationEndpoint                                      string   `json:"registration_endpoint"`
	TokenEndpointAuthMethodsSupported                         []string `json:"token_endpoint_auth_methods_supported"`
	TokenEndpointAuthSigningAlgValuesSupported                []string `json:"token_endpoint_auth_signing_alg_values_supported"`
	IntrospectionEndpointAuthMethodsSupported                 []string `json:"introspection_endpoint_auth_methods_supported"`
	IntrospectionEndpointAuthSigningAlgValuesSupported        []string `json:"introspection_endpoint_auth_signing_alg_values_supported"`
	AuthorizationSigningAlgValuesSupported                    []string `json:"authorization_signing_alg_values_supported"`
	AuthorizationEncryptionAlgValuesSupported                 []string `json:"authorization_encryption_alg_values_supported"`
	AuthorizationEncryptionEncValuesSupported                 []string `json:"authorization_encryption_enc_values_supported"`
	ClaimsSupported                                           []string `json:"claims_supported"`
	ClaimTypesSupported                                       []string `json:"claim_types_supported"`
	ClaimsParameterSupported                                  bool     `json:"claims_parameter_supported"`
	ScopesSupported                                           []string `json:"scopes_supported"`
	RequestParameterSupported                                 bool     `json:"request_parameter_supported"`
	RequestURIParameterSupported                              bool     `json:"request_uri_parameter_supported"`
	RequireRequestURIRegistration                             bool     `json:"require_request_uri_registration"`
	CodeChallengeMethodsSupported                             []string `json:"code_challenge_methods_supported"`
	TLSClientCertificateBoundAccessTokens                     bool     `json:"tls_client_certificate_bound_access_tokens"`
	RevocationEndpoint                                        string   `json:"revocation_endpoint"`
	RevocationEndpointAuthMethodsSupported                    []string `json:"revocation_endpoint_auth_methods_supported"`
	RevocationEndpointAuthSigningAlgValuesSupported           []string `json:"revocation_endpoint_auth_signing_alg_values_supported"`
	BackchannelLogoutSupported                                bool     `json:"backchannel_logout_supported"`
	BackchannelLogoutSessionSupported                         bool     `json:"backchannel_logout_session_supported"`
	DeviceAuthorizationEndpoint                               string   `json:"device_authorization_endpoint"`
	BackchannelTokenDeliveryModesSupported                    []string `json:"backchannel_token_delivery_modes_supported"`
	BackchannelAuthenticationEndpoint                         string   `json:"backchannel_authentication_endpoint"`
	BackchannelAuthenticationRequestSigningAlgValuesSupported []string `json:"backchannel_authentication_request_signing_alg_values_supported"`
	RequirePushedAuthorizationRequests                        bool     `json:"require_pushed_authorization_requests"`
	PushedAuthorizationRequestEndpoint                        string   `json:"pushed_authorization_request_endpoint"`
	MtlsEndpointAliases                                       struct {
		TokenEndpoint                      string `json:"token_endpoint"`
		RevocationEndpoint                 string `json:"revocation_endpoint"`
		IntrospectionEndpoint              string `json:"introspection_endpoint"`
		DeviceAuthorizationEndpoint        string `json:"device_authorization_endpoint"`
		RegistrationEndpoint               string `json:"registration_endpoint"`
		UserinfoEndpoint                   string `json:"userinfo_endpoint"`
		PushedAuthorizationRequestEndpoint string `json:"pushed_authorization_request_endpoint"`
		BackchannelAuthenticationEndpoint  string `json:"backchannel_authentication_endpoint"`
	} `json:"mtls_endpoint_aliases"`
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}
var (
	Log                *Logger
	ErrInvalidLogLevel = errors.New("incorrect log level: unable to translate to zap log level")
)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

type PlatformDatabases

type PlatformDatabases struct {
	BoltDb boltDbDatabase
}

type Route

type Route struct {
	Path               string
	Method             string
	HandlerFunc        http.HandlerFunc
	SlaMs              int64
	RolesRequired      []string
	AllowedContentType string
	AuthRequired       bool
}

type Routes

type Routes []Route

Jump to

Keyboard shortcuts

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