Documentation ¶
Index ¶
- Variables
- func MakeAuthnRequest(sp saml.ServiceProvider, idpUrl string) string
- func MockAssertion(opts ...AssertionOptions) *saml.Assertion
- func MockAttribute(name, value string, opts ...AttributeOptions) saml.Attribute
- func MockLogoutResponse(opts ...LogoutResponseOptions) *saml.LogoutResponse
- func MustNewMockedIDP(opts ...IDPMockOptions) *saml.IdentityProvider
- func MustNewMockedSP(opts ...SPMockOptions) *saml.ServiceProvider
- func NewMockedIDP(opts ...IDPMockOptions) (*saml.IdentityProvider, error)
- func NewMockedSP(opts ...SPMockOptions) (*saml.ServiceProvider, error)
- func RequestWithSAMLPostBinding[T BindableSamlTypes](samlObj *T, relayState string) webtest.RequestOptions
- type AssertionOption
- type AssertionOptions
- type AttributeOptions
- type BindableSamlTypes
- type BindingParseResult
- type ClientStoreMockOption
- type ClientStoreMockOptions
- type ExtIDPProperties
- type ExtSamlMetadata
- type IDPMockOption
- type IDPMockOptions
- type IDPProperties
- type IdpManagerMockOption
- type IdpManagerMockOptions
- type LogoutResponseOption
- type LogoutResponseOptions
- type MockSamlClientStore
- type MockedClientOption
- type MockedClientOptions
- type MockedClientProperties
- type MockedIdpManager
- func (m MockedIdpManager) GetIdentityProviderByDomain(ctx context.Context, domain string) (idp.IdentityProvider, error)
- func (m MockedIdpManager) GetIdentityProviderByEntityId(ctx context.Context, entityId string) (idp.IdentityProvider, error)
- func (m MockedIdpManager) GetIdentityProvidersWithFlow(ctx context.Context, flow idp.AuthenticationFlow) (ret []idp.IdentityProvider)
- type MockedIdpProvider
- func (i MockedIdpProvider) Domain() string
- func (i MockedIdpProvider) EntityId() string
- func (i MockedIdpProvider) ExternalIdName() string
- func (i MockedIdpProvider) ExternalIdpName() string
- func (i MockedIdpProvider) GetAutoCreateUserDetails() security.AutoCreateUserDetails
- func (i MockedIdpProvider) GetMetadataTrustedKeys() []string
- func (i MockedIdpProvider) MetadataLocation() string
- func (i MockedIdpProvider) ShouldMetadataRequireSignature() bool
- func (i MockedIdpProvider) ShouldMetadataTrustCheck() bool
- type MockedSamlAssertionAuthentication
- func (sa *MockedSamlAssertionAuthentication) Assertion() *saml.Assertion
- func (sa *MockedSamlAssertionAuthentication) Details() interface{}
- func (sa *MockedSamlAssertionAuthentication) Permissions() security.Permissions
- func (sa *MockedSamlAssertionAuthentication) Principal() interface{}
- func (sa *MockedSamlAssertionAuthentication) State() security.AuthenticationState
- type MockedSamlClient
- func (c MockedSamlClient) GetEntityId() string
- func (c MockedSamlClient) GetMetadataSource() string
- func (c MockedSamlClient) GetMetadataTrustedKeys() []string
- func (c MockedSamlClient) GetTenantRestrictionType() string
- func (c MockedSamlClient) GetTenantRestrictions() utils.StringSet
- func (c MockedSamlClient) ShouldMetadataRequireSignature() bool
- func (c MockedSamlClient) ShouldMetadataTrustCheck() bool
- func (c MockedSamlClient) ShouldSkipAssertionEncryption() bool
- func (c MockedSamlClient) ShouldSkipAuthRequestSignatureVerification() bool
- type ProviderProperties
- type SPMockOption
- type SPMockOptions
- type SPProperties
Constants ¶
This section is empty.
Variables ¶
var DefaultIssuer = security.NewIssuer(func(opt *security.DefaultIssuerDetails) { *opt = security.DefaultIssuerDetails{ Protocol: "http", Domain: "vms.com", Port: 8080, ContextPath: webtest.DefaultContextPath, IncludePort: true, } })
Functions ¶
func MakeAuthnRequest ¶
func MakeAuthnRequest(sp saml.ServiceProvider, idpUrl string) string
MakeAuthnRequest create a SAML AuthnRequest, sign it and returns
func MockAssertion ¶
func MockAssertion(opts ...AssertionOptions) *saml.Assertion
func MockAttribute ¶
func MockAttribute(name, value string, opts ...AttributeOptions) saml.Attribute
func MockLogoutResponse ¶
func MockLogoutResponse(opts ...LogoutResponseOptions) *saml.LogoutResponse
func MustNewMockedIDP ¶
func MustNewMockedIDP(opts ...IDPMockOptions) *saml.IdentityProvider
MustNewMockedIDP similar to NewMockedIDP, panic instead of returning error
func MustNewMockedSP ¶
func MustNewMockedSP(opts ...SPMockOptions) *saml.ServiceProvider
MustNewMockedSP similar to NewMockedSP, panic instead of returning error
func NewMockedIDP ¶
func NewMockedIDP(opts ...IDPMockOptions) (*saml.IdentityProvider, error)
NewMockedIDP create a mocked IDP with given IDPMockOptions. Returns error if any mocked value are incorrect. e.g. file not exists
func NewMockedSP ¶
func NewMockedSP(opts ...SPMockOptions) (*saml.ServiceProvider, error)
NewMockedSP create a mocked SP with given SPMockOptions. Returns error if any mocked value are incorrect. e.g. file not exists
func RequestWithSAMLPostBinding ¶
func RequestWithSAMLPostBinding[T BindableSamlTypes](samlObj *T, relayState string) webtest.RequestOptions
RequestWithSAMLPostBinding returns a webtest.RequestOptions that inject given SAML Request/Response using Post binding. Note: request need to be POST
Types ¶
type AssertionOption ¶
type AssertionOptions ¶
type AssertionOptions func(opt *AssertionOption)
type AttributeOptions ¶
type BindableSamlTypes ¶
type BindableSamlTypes interface { saml.LogoutRequest | saml.LogoutResponse | saml.AuthnRequest | saml.Response }
type BindingParseResult ¶
func ParseBinding ¶
func ParseBinding[T samlutils.ParsableSamlTypes](resp *http.Response, dest *T) (ret BindingParseResult, err error)
ParseBinding parse redirect/post binding from given HTTP response
type ClientStoreMockOption ¶
type ClientStoreMockOption struct { Clients []samlctx.SamlClient SPs []*saml.ServiceProvider ClientsProperties map[string]MockedClientProperties }
type ClientStoreMockOptions ¶
type ClientStoreMockOptions func(opt *ClientStoreMockOption)
func ClientsWithPropertiesPrefix ¶
func ClientsWithPropertiesPrefix(appCfg bootstrap.ApplicationConfig, prefix string) ClientStoreMockOptions
ClientsWithPropertiesPrefix returns a ClientStoreMockOptions that bind a map of properties from application config with given prefix
func ClientsWithSPs ¶
func ClientsWithSPs(sps ...*saml.ServiceProvider) ClientStoreMockOptions
ClientsWithSPs returns a ClientStoreMockOptions that convert given SPs to Clients
type ExtIDPProperties ¶
type ExtSamlMetadata ¶
type IDPMockOption ¶
type IDPMockOption struct {
Properties IDPProperties
}
type IDPMockOptions ¶
type IDPMockOptions func(opt *IDPMockOption)
func IDPWithPropertiesPrefix ¶
func IDPWithPropertiesPrefix(appCfg bootstrap.ApplicationConfig, prefix string) IDPMockOptions
IDPWithPropertiesPrefix returns a IDP mock option that bind properties from application config and with given prefix
type IDPProperties ¶
type IDPProperties struct { ProviderProperties ExtIDPProperties SSOPath string `json:"sso"` SLOPath string `json:"slo"` }
type IdpManagerMockOption ¶
type IdpManagerMockOption struct { IDPList []idp.IdentityProvider IDPProperties map[string]IDPProperties Delegates []idp.IdentityProviderManager }
type IdpManagerMockOptions ¶
type IdpManagerMockOptions func(opt *IdpManagerMockOption)
func IDPsWithFallback ¶
func IDPsWithFallback(delegates ...idp.IdentityProviderManager) IdpManagerMockOptions
IDPsWithFallback returns a IdpManagerMockOptions that set a fallback implementation for non-SAML IDPs
func IDPsWithPropertiesPrefix ¶
func IDPsWithPropertiesPrefix(appCfg bootstrap.ApplicationConfig, prefix string) IdpManagerMockOptions
IDPsWithPropertiesPrefix returns a IdpManagerMockOptions that bind a map of properties from application config and with given prefix
type LogoutResponseOption ¶
type LogoutResponseOptions ¶
type LogoutResponseOptions func(opt *LogoutResponseOption)
type MockSamlClientStore ¶
type MockSamlClientStore struct {
// contains filtered or unexported fields
}
func NewMockedClientStore ¶
func NewMockedClientStore(opts ...ClientStoreMockOptions) *MockSamlClientStore
func (*MockSamlClientStore) GetAllSamlClient ¶
func (t *MockSamlClientStore) GetAllSamlClient(_ context.Context) ([]samlctx.SamlClient, error)
func (*MockSamlClientStore) GetSamlClientByEntityId ¶
func (t *MockSamlClientStore) GetSamlClientByEntityId(_ context.Context, id string) (samlctx.SamlClient, error)
type MockedClientOption ¶
type MockedClientOption struct { Properties MockedClientProperties SP *saml.ServiceProvider }
type MockedClientOptions ¶
type MockedClientOptions func(opt *MockedClientOption)
type MockedClientProperties ¶
type MockedClientProperties struct { SPProperties SkipEncryption bool `json:"skip-encryption"` SkipSignatureVerification bool `json:"skip-signature-verification"` TenantRestriction utils.CommaSeparatedSlice `json:"tenant-restriction"` TenantRestrictionType string `json:"tenant-restriction-type"` }
type MockedIdpManager ¶
type MockedIdpManager struct {
// contains filtered or unexported fields
}
func NewMockedIdpManager ¶
func NewMockedIdpManager(opts ...IdpManagerMockOptions) *MockedIdpManager
NewMockedIdpManager create a mocked samllogin.SamlIdentityProviderManager that returns SAML IDP based on given options
func (MockedIdpManager) GetIdentityProviderByDomain ¶
func (m MockedIdpManager) GetIdentityProviderByDomain(ctx context.Context, domain string) (idp.IdentityProvider, error)
func (MockedIdpManager) GetIdentityProviderByEntityId ¶
func (m MockedIdpManager) GetIdentityProviderByEntityId(ctx context.Context, entityId string) (idp.IdentityProvider, error)
func (MockedIdpManager) GetIdentityProvidersWithFlow ¶
func (m MockedIdpManager) GetIdentityProvidersWithFlow(ctx context.Context, flow idp.AuthenticationFlow) (ret []idp.IdentityProvider)
type MockedIdpProvider ¶
type MockedIdpProvider struct {
ExtSamlMetadata
}
func NewMockedIdpProvider ¶
func NewMockedIdpProvider(opts ...IDPMockOptions) *MockedIdpProvider
func (MockedIdpProvider) Domain ¶
func (i MockedIdpProvider) Domain() string
func (MockedIdpProvider) EntityId ¶
func (i MockedIdpProvider) EntityId() string
func (MockedIdpProvider) ExternalIdName ¶
func (i MockedIdpProvider) ExternalIdName() string
func (MockedIdpProvider) ExternalIdpName ¶
func (i MockedIdpProvider) ExternalIdpName() string
func (MockedIdpProvider) GetAutoCreateUserDetails ¶
func (i MockedIdpProvider) GetAutoCreateUserDetails() security.AutoCreateUserDetails
func (MockedIdpProvider) GetMetadataTrustedKeys ¶
func (i MockedIdpProvider) GetMetadataTrustedKeys() []string
func (MockedIdpProvider) MetadataLocation ¶
func (i MockedIdpProvider) MetadataLocation() string
func (MockedIdpProvider) ShouldMetadataRequireSignature ¶
func (i MockedIdpProvider) ShouldMetadataRequireSignature() bool
func (MockedIdpProvider) ShouldMetadataTrustCheck ¶
func (i MockedIdpProvider) ShouldMetadataTrustCheck() bool
type MockedSamlAssertionAuthentication ¶
type MockedSamlAssertionAuthentication struct { Account security.Account DetailsMap map[string]interface{} SamlAssertion *saml.Assertion }
func (*MockedSamlAssertionAuthentication) Assertion ¶
func (sa *MockedSamlAssertionAuthentication) Assertion() *saml.Assertion
func (*MockedSamlAssertionAuthentication) Details ¶
func (sa *MockedSamlAssertionAuthentication) Details() interface{}
func (*MockedSamlAssertionAuthentication) Permissions ¶
func (sa *MockedSamlAssertionAuthentication) Permissions() security.Permissions
func (*MockedSamlAssertionAuthentication) Principal ¶
func (sa *MockedSamlAssertionAuthentication) Principal() interface{}
func (*MockedSamlAssertionAuthentication) State ¶
func (sa *MockedSamlAssertionAuthentication) State() security.AuthenticationState
type MockedSamlClient ¶
type MockedSamlClient struct { EntityId string MetadataSource string SkipAssertionEncryption bool SkipAuthRequestSignatureVerification bool MetadataRequireSignature bool MetadataTrustCheck bool MetadataTrustedKeys []string TenantRestrictions utils.StringSet TenantRestrictionType string }
func NewMockedSamlClient ¶
func NewMockedSamlClient(opts ...MockedClientOptions) *MockedSamlClient
func (MockedSamlClient) GetEntityId ¶
func (c MockedSamlClient) GetEntityId() string
func (MockedSamlClient) GetMetadataSource ¶
func (c MockedSamlClient) GetMetadataSource() string
func (MockedSamlClient) GetMetadataTrustedKeys ¶
func (c MockedSamlClient) GetMetadataTrustedKeys() []string
func (MockedSamlClient) GetTenantRestrictionType ¶
func (c MockedSamlClient) GetTenantRestrictionType() string
func (MockedSamlClient) GetTenantRestrictions ¶
func (c MockedSamlClient) GetTenantRestrictions() utils.StringSet
func (MockedSamlClient) ShouldMetadataRequireSignature ¶
func (c MockedSamlClient) ShouldMetadataRequireSignature() bool
func (MockedSamlClient) ShouldMetadataTrustCheck ¶
func (c MockedSamlClient) ShouldMetadataTrustCheck() bool
func (MockedSamlClient) ShouldSkipAssertionEncryption ¶
func (c MockedSamlClient) ShouldSkipAssertionEncryption() bool
func (MockedSamlClient) ShouldSkipAuthRequestSignatureVerification ¶
func (c MockedSamlClient) ShouldSkipAuthRequestSignatureVerification() bool
type ProviderProperties ¶
type SPMockOption ¶
type SPMockOption struct { Properties SPProperties IDP *saml.IdentityProvider }
type SPMockOptions ¶
type SPMockOptions func(opt *SPMockOption)
func SPWithIDP ¶
func SPWithIDP(idp *saml.IdentityProvider) SPMockOptions
SPWithIDP returns a SP mock option that set given IDP
func SPWithPropertiesPrefix ¶
func SPWithPropertiesPrefix(appCfg bootstrap.ApplicationConfig, prefix string) SPMockOptions
SPWithPropertiesPrefix returns a SP mock option that bind properties from application config and with given prefix
type SPProperties ¶
type SPProperties struct { ProviderProperties ACSPath string `json:"acs"` SLOPath string `json:"slo"` IDP *IDPProperties `json:"idp"` }