Documentation
¶
Overview ¶
SPDX-FileCopyrightText: (C) 2026 Intel Corporation SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func ExtractAllProjectIDsFromJWT(authHeader string) (map[string]bool, error)
- func ExtractAllProjectIDsFromJWTWithVerification(authHeader string) (map[string]bool, error)
- func ExtractProjectIDFromJWT(authHeader string) (string, error)
- func ExtractProjectIDFromJWTWithVerification(authHeader string) (string, error)
- func ValidateProjectAccess(authHeader string, projectID string) error
- func ValidateProjectAccessWithVerification(authHeader string, projectID string) error
- type Authenticator
- type ClientSecretData
- type JwtAuthenticator
- type KeycloakClient
- type KeycloakSecret
- type VaultAuth
Constants ¶
const ( SharedSecretKey = "SHARED_SECRET_KEY" // OIDCServerURL - will be accessed as Environment variable OIDCServerURL = "OIDC_SERVER_URL" // OIDCTlsInsecureSkipVerify - will be accessed as Environment variable OIDCTlsInsecureSkipVerify = "OIDC_TLS_INSECURE_SKIP_VERIFY" // OpenidConfiguration is the discovery point on the OIDC server OpenidConfiguration = ".well-known/openid-configuration" // HS prefix for HS family algorithms HS = "HS" // RS prefix for RS family algorithms RS = "RS" // PS prefix for PS family algorithms PS = "PS" )
Variables ¶
var (
K8STokenFile = vaultK8STokenFile
)
Functions ¶
func ExtractAllProjectIDsFromJWT ¶
ExtractAllProjectIDsFromJWT extracts all project UUIDs from JWT token roles without signature verification. Returns a map of project IDs for quick lookup. This function assumes the JWT has already been validated by upstream authentication middleware. Use ExtractAllProjectIDsFromJWTWithVerification if you need signature verification.
func ExtractAllProjectIDsFromJWTWithVerification ¶
ExtractAllProjectIDsFromJWTWithVerification extracts all project UUIDs from JWT token roles and verifies the JWT signature using ORCH_JWT_SIGNING_KEY. Use this when the JWT has NOT been validated by upstream middleware.
func ExtractProjectIDFromJWT ¶
ExtractProjectIDFromJWT extracts the project UUID from JWT token roles without signature verification. This function assumes the JWT has already been validated by upstream authentication middleware. Use ExtractProjectIDFromJWTWithVerification if you need signature verification.
func ExtractProjectIDFromJWTWithVerification ¶
ExtractProjectIDFromJWTWithVerification extracts the project UUID from JWT token roles and verifies the JWT signature using ORCH_JWT_SIGNING_KEY. Use this when the JWT has NOT been validated by upstream middleware.
func ValidateProjectAccess ¶
ValidateProjectAccess checks if the ProjectID is accessible under the given user's JWT token without signature verification. It extracts all project UUIDs from the JWT roles and verifies that projectID is among them. This prevents users from accessing projects they don't have permissions for. This function assumes the JWT has already been validated by upstream authentication middleware. Use ValidateProjectAccessWithVerification if you need signature verification.
func ValidateProjectAccessWithVerification ¶
ValidateProjectAccessWithVerification checks if the ProjectID is accessible under the given user's JWT token and verifies the JWT signature using ORCH_JWT_SIGNING_KEY. Use this when the JWT has NOT been validated by upstream middleware.
Types ¶
type Authenticator ¶
type Authenticator interface {
// Authenticate authenticates a given string token
Authenticate(string) (jwt.MapClaims, error)
}
Authenticator an authenticator interface to implement different authentication methods
type ClientSecretData ¶
type JwtAuthenticator ¶
type JwtAuthenticator struct {
}
JwtAuthenticator jwt authenticator
func (*JwtAuthenticator) ParseAndValidate ¶
func (j *JwtAuthenticator) ParseAndValidate(tokenString string) (jwt.Claims, error)
ParseAndValidate parse a jwt string token and validate it
type KeycloakClient ¶
type KeycloakClient struct {
ID string `json:"id"`
ClientID string `json:"clientId"`
Name string `json:"name"`
Description string `json:"description"`
SurrogateAuthRequired bool `json:"surrogateAuthRequired"`
Enabled bool `json:"enabled"`
AlwaysDisplayInConsole bool `json:"alwaysDisplayInConsole"`
ClientAuthenticatorType string `json:"clientAuthenticatorType"`
Secret string `json:"secret"`
RedirectUris []interface{} `json:"redirectUris"`
WebOrigins []interface{} `json:"webOrigins"`
NotBefore int `json:"notBefore"`
BearerOnly bool `json:"bearerOnly"`
ConsentRequired bool `json:"consentRequired"`
StandardFlowEnabled bool `json:"standardFlowEnabled"`
ImplicitFlowEnabled bool `json:"implicitFlowEnabled"`
DirectAccessGrantsEnabled bool `json:"directAccessGrantsEnabled"`
ServiceAccountsEnabled bool `json:"serviceAccountsEnabled"`
AuthorizationServicesEnabled bool `json:"authorizationServicesEnabled"`
PublicClient bool `json:"publicClient"`
FrontchannelLogout bool `json:"frontchannelLogout"`
Protocol string `json:"protocol"`
Attributes struct {
OidcCibaGrantEnabled string `json:"oidc.ciba.grant.enabled"`
Oauth2DeviceAuthorizationGrantEnabled string `json:"oauth2.device.authorization.grant.enabled"`
ClientSecretCreationTime string `json:"client.secret.creation.time"`
BackchannelLogoutSessionRequired string `json:"backchannel.logout.session.required"`
BackchannelLogoutRevokeOfflineTokens string `json:"backchannel.logout.revoke.offline.tokens"`
} `json:"attributes"`
AuthenticationFlowBindingOverrides struct {
} `json:"authenticationFlowBindingOverrides"`
FullScopeAllowed bool `json:"fullScopeAllowed"`
NodeReRegistrationTimeout int `json:"nodeReRegistrationTimeout"`
ProtocolMappers []struct {
ID string `json:"id"`
Name string `json:"name"`
Protocol string `json:"protocol"`
ProtocolMapper string `json:"protocolMapper"`
ConsentRequired bool `json:"consentRequired"`
Config struct {
UserSessionNote string `json:"user.session.note"`
IDTokenClaim string `json:"id.token.claim"`
AccessTokenClaim string `json:"access.token.claim"`
ClaimName string `json:"claim.name"`
JSONTypeLabel string `json:"jsonType.label"`
} `json:"config"`
} `json:"protocolMappers"`
DefaultClientScopes []string `json:"defaultClientScopes"`
OptionalClientScopes []string `json:"optionalClientScopes"`
Access struct {
View bool `json:"view"`
Configure bool `json:"configure"`
Manage bool `json:"manage"`
} `json:"access"`
}