Documentation
¶
Index ¶
- Constants
- Variables
- func GetProviderMetadata() map[ProviderType]ProviderMetadata
- type AccountType
- type Address
- type ApiKeyConfig
- type ApiKeyEntry
- type ApiKeyId
- type ApiKeySecret
- type ApiKeyTable
- func (t *ApiKeyTable) DeleteIdByUser(ctx context.Context, id string, info *ApiKeyUserInfo) error
- func (t *ApiKeyTable) FindByUser(ctx context.Context, info *ApiKeyUserInfo) ([]*ApiKeyEntry, error)
- func (t *ApiKeyTable) FindIdByUser(ctx context.Context, id string, info *ApiKeyUserInfo) (*ApiKeyEntry, error)
- type ApiKeyUserInfo
- type Contact
- type CustomerConfig
- type CustomerEntry
- type CustomerKey
- type CustomerTable
- type Email
- type EmailVerificationEntry
- type EmailVerificationTable
- type GoogleOAuth2Config
- type IdentityProviderEntry
- type IdentityProviderKey
- type IdentityProviderTable
- type MicrosoftOAuth2Config
- type OIDCConfig
- type OrgUnitEntry
- type OrgUnitKey
- type OrgUnitTable
- type OrgUnitUser
- type OrgUnitUserKey
- type OrgUnitUserTable
- func (t *OrgUnitUserTable) CountByOrgUnitId(ctx context.Context, orgUnitId string) (int32, error)
- func (t *OrgUnitUserTable) DeleteByUser(ctx context.Context, tenant, user string) error
- func (t *OrgUnitUserTable) GetByOrgUnitId(ctx context.Context, orgUnitId string, offset, limit int32) ([]*OrgUnitUser, error)
- func (t *OrgUnitUserTable) GetByUser(ctx context.Context, tenant, user string) ([]*OrgUnitUser, error)
- func (t *OrgUnitUserTable) StartEventLogger() error
- type ProviderConfigField
- type ProviderMetadata
- type ProviderSecrets
- type ProviderType
- type SAMLConfig
- type TaxInfo
- type TenancyType
- type TenantAdminStatus
- type TenantAuthClientStatus
- type TenantConfig
- type TenantEntry
- type TenantKCStatus
- type TenantKey
- type TenantRoleStatus
- type TenantTable
- type UserCredentials
- type UserEntry
- type UserInfo
- type UserKey
- type UserKeycloakStatus
- type UserPreferenceEntry
- type UserPreferenceTable
- type UserTable
- type UserTempPassword
- type ValidationError
Constants ¶
const ( // customers collection name CustomersCollectionName = "customers" // tenants collection name TenantsCollectionName = "tenants" // api keys collection name ApiKeyCollectionName = "api-keys" // users collection name UserCollectionName = "users" // email verification collection name EmailVerificationCollectionName = "verify-emails" // Org Unit collection name OrgUnitCollectionName = "org-units" // Org Unit User collection name OrgUnitUserCollectionName = "org-unit-users" // Identity Provider collection name IdentityProviderCollectionName = "identity-providers" )
const ( // Environment variable for encryptor key EncryptorKeyEnvVar = "ENCRYPTOR_KEY" // default value for encryptor key if not provided // as part of environment DefaultEncryptorKey = "MySuperSecretKey" )
const (
// Auth database name
AuthDatabaseName = "auth-gateway"
)
Variables ¶
Functions ¶
func GetProviderMetadata ¶
func GetProviderMetadata() map[ProviderType]ProviderMetadata
GetProviderMetadata returns metadata for all supported provider types
Types ¶
type AccountType ¶
type AccountType int32
const ( UnknownAccount AccountType = iota CompanyAccount PersonalAccount )
type Address ¶
type Address struct {
// Postal Code
PostalCode string `bson:"postalCode,omitempty"`
// Country Code
Country string `bson:"country,omitempty"`
// State / Province / Region / County
State string `bson:"state,omitempty"`
// City
City string `bson:"city,omitempty"`
// Address Line 1
Addr1 string `bson:"addr1,omitempty"`
// Address Line 2
Addr2 string `bson:"addr2,omitempty"`
// Address Line 3
Addr3 string `bson:"addr3,omitempty"`
// Name for which the address is
Name string `bson:"name,omitempty"`
}
type ApiKeyConfig ¶
type ApiKeyConfig struct {
// name of the api key, used for display purposes
Name string `bson:"name,omitempty"`
// ExpireAt is the timestamp when the API key will expire.
ExpireAt int64 `bson:"expireAt,omitempty"`
// IsDisabled indicates whether the API key is disabled.
IsDisabled *bool `bson:"isDisabled,omitempty"`
}
type ApiKeyEntry ¶
type ApiKeyEntry struct {
// ID of the API Key
Key ApiKeyId `bson:"key"`
// Secret is the actual secret key used for authentication.
// It is typically a long random string that is
// generated when the API key is created.
// It should be kept secret and not exposed to the public.
// It is used to authenticate the API key when making requests.
Secret *ApiKeySecret `bson:"secret,omitempty"`
// userinfo corresponding to this key,
// if this field is nil, typically the key will
// be considered invalid and no access will be
// granted upon its usage
UserInfo *ApiKeyUserInfo `bson:"userInfo,omitempty"`
// created timestamp
Created int64 `bson:"created,omitempty"`
// last used timestamp
LastUsed int64 `bson:"lastUsed,omitempty"`
// config for the API key
Config *ApiKeyConfig `bson:"config,omitempty"`
}
type ApiKeyId ¶
type ApiKeyId struct {
// API Key ID
Id string `bson:"id,omitempty"`
}
ApiKeyId is the key for the API Key table.
type ApiKeySecret ¶
type ApiKeySecret struct {
Value string `bson:"value,omitempty"`
}
func (*ApiKeySecret) MarshalBSON ¶
func (s *ApiKeySecret) MarshalBSON() ([]byte, error)
func (*ApiKeySecret) UnmarshalBSON ¶
func (s *ApiKeySecret) UnmarshalBSON(data []byte) error
type ApiKeyTable ¶
type ApiKeyTable struct {
table.Table[ApiKeyId, ApiKeyEntry]
// contains filtered or unexported fields
}
func GetApiKeyTable ¶
func GetApiKeyTable() (*ApiKeyTable, error)
func LocateApiKeyTable ¶
func LocateApiKeyTable(client db.StoreClient) (*ApiKeyTable, error)
func (*ApiKeyTable) DeleteIdByUser ¶
func (t *ApiKeyTable) DeleteIdByUser(ctx context.Context, id string, info *ApiKeyUserInfo) error
func (*ApiKeyTable) FindByUser ¶
func (t *ApiKeyTable) FindByUser(ctx context.Context, info *ApiKeyUserInfo) ([]*ApiKeyEntry, error)
func (*ApiKeyTable) FindIdByUser ¶
func (t *ApiKeyTable) FindIdByUser(ctx context.Context, id string, info *ApiKeyUserInfo) (*ApiKeyEntry, error)
type ApiKeyUserInfo ¶
type CustomerConfig ¶
type CustomerConfig struct {
// Customer Display Name
Name string `bson:"name,omitempty"`
// Descriptive text for the tenant
Desc string `bson:"desc,omitempty"`
// Registered Address of the customer
Addr *Address `bson:"addr,omitempty"`
// Billing Contact for the customer
Contact *Contact `bson:"contact,omitempty"`
// User ID of Default Admin for the customer
DefaultAdmin *UserCredentials `bson:"defaultAdmin,omitempty"`
// additional customer additional bill information,
// requirement based on local laws
Info *TaxInfo `bson:"taxInfo,omitempty"`
}
type CustomerEntry ¶
type CustomerEntry struct {
// Customer Key
Key CustomerKey `bson:"key,omitempty"`
// Customer Type Company / Personal
Type AccountType `bson:"type,omitempty"`
// Customer Tenancy Type Dedicated / Shared
Tenancy TenancyType `bson:"tenancy,omitempty"`
// Tenant Name associated with the customer
Tenant string `bson:"tenant,omitempty"`
// is this customer is root customer
IsRoot bool `bson:"isRoot,omitempty"`
// Configuration provided for the customer
Config CustomerConfig `bson:"config,omitempty"`
// created by
CreatedBy string `bson:"createdBy,omitempty"`
// created at timestamp
Created int64 `bson:"created,omitempty"`
// updated at timestamp
Updated int64 `bson:"updated,omitempty"`
}
type CustomerKey ¶
type CustomerKey struct {
// Name or customer id as a key for the customer information
Id string `bson:"id,omitempty"`
}
type CustomerTable ¶
type CustomerTable struct {
table.Table[CustomerKey, CustomerEntry]
// contains filtered or unexported fields
}
func GetCustomerTable ¶
func GetCustomerTable() (*CustomerTable, error)
func LocateCustomerTable ¶
func LocateCustomerTable(client db.StoreClient) (*CustomerTable, error)
type EmailVerificationEntry ¶
type EmailVerificationTable ¶
type EmailVerificationTable struct {
table.Table[Email, EmailVerificationEntry]
// contains filtered or unexported fields
}
func GetEmailVerificationTable ¶
func GetEmailVerificationTable() (*EmailVerificationTable, error)
func LocateEmailVerificationTable ¶
func LocateEmailVerificationTable(client db.StoreClient) (*EmailVerificationTable, error)
type GoogleOAuth2Config ¶
type GoogleOAuth2Config struct {
ClientID string `json:"client_id" validate:"required"`
ClientSecret string `json:"client_secret" validate:"required"`
RedirectURI string `json:"redirect_uri,omitempty"`
HostedDomain string `json:"hosted_domain,omitempty"`
Prompt string `json:"prompt,omitempty"`
UseUserIPParam bool `json:"use_userip_param"`
RequestRefreshToken bool `json:"request_refresh_token"`
AdditionalScopes string `json:"additional_scopes,omitempty"`
LoginHint string `json:"login_hint,omitempty"`
IncludeGrantedScopes bool `json:"include_granted_scopes"`
}
GoogleOAuth2Config represents Google OAuth2 provider configuration
type IdentityProviderEntry ¶
type IdentityProviderEntry struct {
Key *IdentityProviderKey `bson:"key,omitempty"`
ProviderType ProviderType `bson:"providerType,omitempty"`
DisplayName string `bson:"displayName,omitempty"`
DisplayOrder int `bson:"displayOrder,omitempty"`
Enabled bool `bson:"enabled,omitempty"`
Configuration map[string]interface{} `bson:"configuration,omitempty"`
Secrets *ProviderSecrets `bson:"secrets,omitempty"`
Created int64 `bson:"created,omitempty"`
Updated int64 `bson:"updated,omitempty"`
CreatedBy string `bson:"createdBy,omitempty"`
UpdatedBy string `bson:"updatedBy,omitempty"`
}
IdentityProviderEntry represents a complete identity provider configuration
type IdentityProviderKey ¶
IdentityProviderKey represents the composite key for identity providers
type IdentityProviderTable ¶
type IdentityProviderTable struct {
table.Table[IdentityProviderKey, IdentityProviderEntry]
// contains filtered or unexported fields
}
IdentityProviderTable implements the table interface for identity providers
func GetIdentityProviderTable ¶
func GetIdentityProviderTable() (*IdentityProviderTable, error)
GetIdentityProviderTable returns the identity provider table instance
func LocateIdentityProviderTable ¶
func LocateIdentityProviderTable(client db.StoreClient) (*IdentityProviderTable, error)
LocateIdentityProviderTable locates and initializes the identity provider table
func (*IdentityProviderTable) ValidateConfiguration ¶
func (t *IdentityProviderTable) ValidateConfiguration(ctx context.Context, providerType ProviderType, config map[string]interface{}) error
ValidateConfiguration validates provider configuration based on type
type MicrosoftOAuth2Config ¶
type MicrosoftOAuth2Config struct {
ClientID string `json:"client_id" validate:"required"`
ClientSecret string `json:"client_secret" validate:"required"`
RedirectURI string `json:"redirect_uri,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
Prompt string `json:"prompt,omitempty"`
AdditionalScopes string `json:"additional_scopes,omitempty"`
DomainHint string `json:"domain_hint,omitempty"`
LoginHint string `json:"login_hint,omitempty"`
}
MicrosoftOAuth2Config represents Microsoft OAuth2 provider configuration
type OIDCConfig ¶
type OIDCConfig struct {
ClientID string `json:"client_id" validate:"required"`
ClientSecret string `json:"client_secret" validate:"required"`
DiscoveryEndpoint string `json:"discovery_endpoint" validate:"required"`
RedirectURI string `json:"redirect_uri,omitempty"`
UseDiscoveryEndpoint bool `json:"use_discovery_endpoint"`
ClientAuthentication string `json:"client_authentication,omitempty"`
ClientAssertionSignatureAlgorithm string `json:"client_assertion_signature_algorithm,omitempty"`
AdditionalScopes string `json:"additional_scopes,omitempty"`
ValidateSignatures bool `json:"validate_signatures"`
UseJWKSURL bool `json:"use_jwks_url"`
JWKSURL string `json:"jwks_url,omitempty"`
}
OIDCConfig represents OpenID Connect provider configuration
type OrgUnitEntry ¶
type OrgUnitEntry struct {
// Org Unit Key
Key *OrgUnitKey `bson:"key,omitempty"`
// display name of the Org unit
Name string `bson:"name,omitempty"`
// description for the Org unit
Desc string `bson:"desc,omitempty"`
// Created timestamp
Created int64 `bson:"created,omitempty"`
// created by
CreatedBy string `bson:"createdBy,omitempty"`
// Tenant this OU belongs to
Tenant string `bson:"tenant,omitempty"`
}
type OrgUnitKey ¶
type OrgUnitKey struct {
// id as a key for the tenant
ID string `bson:"id,omitempty"`
}
type OrgUnitTable ¶
type OrgUnitTable struct {
table.Table[OrgUnitKey, OrgUnitEntry]
// contains filtered or unexported fields
}
func GetOrgUnitTable ¶
func GetOrgUnitTable() (*OrgUnitTable, error)
func LocateOrgUnitTable ¶
func LocateOrgUnitTable(client db.StoreClient) (*OrgUnitTable, error)
func (*OrgUnitTable) FindByTenant ¶
func (t *OrgUnitTable) FindByTenant(ctx context.Context, tenant, ouId string) ([]*OrgUnitEntry, error)
func (*OrgUnitTable) StartEventLogger ¶
func (t *OrgUnitTable) StartEventLogger() error
type OrgUnitUser ¶
type OrgUnitUser struct {
// org unit user key
Key *OrgUnitUserKey `bson:"key,omitempty"`
// created timestamp
Created int64 `bson:"created,omitempty"`
// created by
CreatedBy string `bson:"createdBy,omitempty"`
// Role assigned to the user in the org unit
Role string `bson:"role,omitempty"`
}
type OrgUnitUserKey ¶
type OrgUnitUserTable ¶
type OrgUnitUserTable struct {
table.Table[OrgUnitUserKey, OrgUnitUser]
// contains filtered or unexported fields
}
func GetOrgUnitUserTable ¶
func GetOrgUnitUserTable() (*OrgUnitUserTable, error)
func LocateOrgUnitUserTable ¶
func LocateOrgUnitUserTable(client db.StoreClient) (*OrgUnitUserTable, error)
func (*OrgUnitUserTable) CountByOrgUnitId ¶
func (*OrgUnitUserTable) DeleteByUser ¶
func (t *OrgUnitUserTable) DeleteByUser(ctx context.Context, tenant, user string) error
func (*OrgUnitUserTable) GetByOrgUnitId ¶
func (t *OrgUnitUserTable) GetByOrgUnitId(ctx context.Context, orgUnitId string, offset, limit int32) ([]*OrgUnitUser, error)
func (*OrgUnitUserTable) GetByUser ¶
func (t *OrgUnitUserTable) GetByUser(ctx context.Context, tenant, user string) ([]*OrgUnitUser, error)
func (*OrgUnitUserTable) StartEventLogger ¶
func (t *OrgUnitUserTable) StartEventLogger() error
type ProviderConfigField ¶
type ProviderConfigField struct {
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required"`
Sensitive bool `json:"sensitive"`
Description string `json:"description"`
DefaultValue interface{} `json:"default_value,omitempty"`
Validation string `json:"validation,omitempty"`
}
ProviderConfigField represents metadata about configuration fields
type ProviderMetadata ¶
type ProviderMetadata struct {
ProviderType ProviderType `json:"provider_type"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
ConfigFields []ProviderConfigField `json:"config_fields"`
SupportedScopes []string `json:"supported_scopes,omitempty"`
DefaultScopes []string `json:"default_scopes,omitempty"`
Documentation string `json:"documentation,omitempty"`
}
ProviderMetadata contains metadata about each provider type
type ProviderSecrets ¶
type ProviderSecrets struct {
ClientSecret string `bson:"clientSecret,omitempty"`
PrivateKey string `bson:"privateKey,omitempty"`
Certificate string `bson:"certificate,omitempty"`
AdditionalSecrets map[string]string `bson:"additionalSecrets,omitempty"`
}
ProviderSecrets contains encrypted sensitive configuration data
func (*ProviderSecrets) MarshalBSON ¶
func (s *ProviderSecrets) MarshalBSON() ([]byte, error)
MarshalBSON implements custom BSON marshaling for encryption
func (*ProviderSecrets) UnmarshalBSON ¶
func (s *ProviderSecrets) UnmarshalBSON(data []byte) error
UnmarshalBSON implements custom BSON unmarshaling for decryption
type ProviderType ¶
type ProviderType string
ProviderType represents the type of identity provider
const ( ProviderTypeUnspecified ProviderType = "" ProviderTypeGoogle ProviderType = "google" ProviderTypeMicrosoft ProviderType = "microsoft" ProviderTypeOIDC ProviderType = "oidc" ProviderTypeSAML ProviderType = "saml" )
type SAMLConfig ¶
type SAMLConfig struct {
ServiceProviderEntityID string `json:"service_provider_entity_id" validate:"required"`
SAMLEntityDescriptor string `json:"saml_entity_descriptor" validate:"required"`
SSOServiceURL string `json:"sso_service_url" validate:"required"`
RedirectURI string `json:"redirect_uri,omitempty"`
IdentityProviderEntityID string `json:"identity_provider_entity_id,omitempty"`
SingleLogoutServiceURL string `json:"single_logout_service_url,omitempty"`
NameIDPolicyFormat string `json:"nameid_policy_format,omitempty"`
WantAuthnRequestsSigned bool `json:"want_authn_requests_signed"`
ValidateSignatures bool `json:"validate_signatures"`
SigningCertificate string `json:"signing_certificate,omitempty"`
EncryptionCertificate string `json:"encryption_certificate,omitempty"`
ForceAuthentication bool `json:"force_authentication"`
PostBindingResponse bool `json:"post_binding_response"`
PostBindingLogout bool `json:"post_binding_logout"`
WantAssertionsSigned bool `json:"want_assertions_signed"`
WantAssertionsEncrypted bool `json:"want_assertions_encrypted"`
SignatureAlgorithm string `json:"signature_algorithm,omitempty"`
SAMLSignatureKeyName string `json:"saml_signature_key_name,omitempty"`
CanonalizationMethod string `json:"canonicalization_method,omitempty"`
}
SAMLConfig represents SAML provider configuration
type TenantAdminStatus ¶
type TenantAuthClientStatus ¶
type TenantConfig ¶
type TenantConfig struct {
// Display name for the tenant
DispName string `bson:"dispName,omitempty"`
// Descriptive text for the tenant
Desc string `bson:"desc,omitempty"`
// Registered Address of the tenant
Addr *Address `bson:"addr,omitempty"`
// Billing Contact for the tenant
Contact *Contact `bson:"contact,omitempty"`
// User ID of Default Admin for the tenant
DefaultAdmin *UserCredentials `bson:"defaultAdmin,omitempty"`
// additional tenant information, requirement based on
// local laws
Info *TaxInfo `bson:"info,omitempty"`
// is this tenant root tenant
IsRoot bool `bson:"isRoot,omitempty"`
}
type TenantEntry ¶
type TenantEntry struct {
// Tenant Type Company / Personal
Type AccountType `bson:"type,omitempty"`
// Configuration provided for the tenant
Config *TenantConfig `bson:"config,omitempty"`
// keycloak Status - as per the setup manager
KCStatus *TenantKCStatus `bson:"kcStatus,omitempty"`
// Roles status - as per roles manager
RoleStatus *TenantRoleStatus `bson:"roleStatus,omitempty"`
// admin status
AdminStatus *TenantAdminStatus `bson:"adminStatus,omitempty"`
// auth client status
AuthClient *TenantAuthClientStatus `bson:"authClient,omitempty"`
}
type TenantKCStatus ¶
type TenantKey ¶
type TenantKey struct {
// Name as a key for the tenant
Name string `bson:"name,omitempty"`
}
type TenantRoleStatus ¶
type TenantRoleStatus struct {
// time when last updated
UpdateTime int64 `bson:"updateTime,omitempty"`
}
type TenantTable ¶
type TenantTable struct {
table.Table[TenantKey, TenantEntry]
// contains filtered or unexported fields
}
func GetTenantTable ¶
func GetTenantTable() (*TenantTable, error)
func LocateTenantTable ¶
func LocateTenantTable(client db.StoreClient) (*TenantTable, error)
type UserCredentials ¶
type UserCredentials struct {
// User Id - username or email id using which user would login
UserID string `bson:"userID,omitempty"`
// Password - first time password for the user
// this will be stored by cryptographically encoding
Password string `bson:"password,omitempty"`
}
func (*UserCredentials) MarshalBSON ¶
func (c *UserCredentials) MarshalBSON() ([]byte, error)
func (*UserCredentials) UnmarshalBSON ¶
func (c *UserCredentials) UnmarshalBSON(data []byte) error
type UserEntry ¶
type UserEntry struct {
Key *UserKey `bson:"key,omitempty"`
Created int64 `bson:"created,omitempty"`
Updated int64 `bson:"updated,omitempty"`
LastAccess int64 `bson:"lastAccess,omitempty"`
Info *UserInfo `bson:"info,omitempty"`
Password *UserTempPassword `bson:"password,omitempty"`
Disabled *bool `bson:"disabled,omitempty"`
Deleted *bool `bson:"deleted,omitempty"`
KCStatus *UserKeycloakStatus `bson:"kcStatus,omitempty"`
RealmRoles *[]string `bson:"realmRoles,omitempty"`
}
type UserKeycloakStatus ¶
type UserPreferenceEntry ¶
type UserPreferenceTable ¶
type UserPreferenceTable struct {
table.Table[UserKey, UserPreferenceEntry]
// contains filtered or unexported fields
}
func GetUserPreferenceTable ¶
func GetUserPreferenceTable() (*UserPreferenceTable, error)
func LocateUserPreferenceTable ¶
func LocateUserPreferenceTable(client db.StoreClient) (*UserPreferenceTable, error)
type UserTable ¶
func GetUserTable ¶
func LocateUserTable ¶
func LocateUserTable(client db.StoreClient) (*UserTable, error)
func (*UserTable) CountByTenant ¶
type UserTempPassword ¶
type UserTempPassword struct {
Value string `bson:"val,omitempty"`
}
func (*UserTempPassword) MarshalBSON ¶
func (s *UserTempPassword) MarshalBSON() ([]byte, error)
func (*UserTempPassword) UnmarshalBSON ¶
func (s *UserTempPassword) UnmarshalBSON(data []byte) error
type ValidationError ¶
Custom error types
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string