Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4536,6 +4536,8 @@ message OIDCConnectorSpecV3 {
// ClientRedirectSettings defines which client redirect URLs are allowed for
// non-browser SSO logins other than the standard localhost ones.
SSOClientRedirectSettings ClientRedirectSettings = 18 [(gogoproto.jsontag) = "client_redirect_settings,omitempty"];
// MFASettings contains settings to enable SSO MFA checks through this auth connector.
OIDCConnectorMFASettings MFASettings = 19 [(gogoproto.jsontag) = "mfa,omitempty"];
}

// MaxAge allows the max_age parameter to be nullable to preserve backwards
Expand All @@ -4556,6 +4558,23 @@ message SSOClientRedirectSettings {
repeated string insecure_allowed_cidr_ranges = 2;
}

// OIDCConnectorMFASettings contains OIDC MFA settings.
message OIDCConnectorMFASettings {
// Enabled specified whether this OIDC connector supports MFA checks. Defaults to false.
bool enabled = 1;
// ClientID is the OIDC OAuth app client ID.
string client_id = 2;
// ClientSecret is the OIDC OAuth app client secret.
string client_secret = 3;
// AcrValues are Authentication Context Class Reference values. The meaning of the ACR
// value is context-specific and varies for identity providers. Some identity providers
// support MFA specific contexts, such Okta with its "phr" (phishing-resistant) ACR.
string acr_values = 4;
// Prompt is an optional OIDC prompt. An empty string omits prompt.
// If not specified, it defaults to select_account for backwards compatibility.
string prompt = 5;
}

// OIDCAuthRequest is a request to authenticate with OIDC
// provider, the state about request is managed by auth server
message OIDCAuthRequest {
Expand Down Expand Up @@ -4728,6 +4747,19 @@ message SAMLConnectorSpecV2 {
SSOClientRedirectSettings ClientRedirectSettings = 15 [(gogoproto.jsontag) = "client_redirect_settings,omitempty"];
// SingleLogoutURL is the SAML Single log-out URL to initiate SAML SLO (single log-out). If this is not provided, SLO is disabled.
string SingleLogoutURL = 16 [(gogoproto.jsontag) = "single_logout_url,omitempty"];
// MFASettings contains settings to enable SSO MFA checks through this auth connector.
SAMLConnectorMFASettings MFASettings = 17 [(gogoproto.jsontag) = "mfa,omitempty"];
}

// SAMLConnectorMFASettings contains SAML MFA settings.
message SAMLConnectorMFASettings {
// Enabled specified whether this SAML connector supports MFA checks. Defaults to false.
bool enabled = 1;
// EntityDescriptor is XML with descriptor. It can be used to supply configuration
// parameters in one XML file rather than supplying them in the individual elements.
string entity_descriptor = 2;
// EntityDescriptorUrl is a URL that supplies a configuration XML.
string entity_descriptor_url = 3;
}

// SAMLAuthRequest is a request to authenticate with SAML
Expand Down
37 changes: 37 additions & 0 deletions api/types/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ type OIDCConnector interface {
GetMaxAge() (time.Duration, bool)
// GetClientRedirectSettings returns the client redirect settings.
GetClientRedirectSettings() *SSOClientRedirectSettings
// GetMFASettings returns the connector's MFA settings.
GetMFASettings() OIDCConnectorMFASettings
// IsMFAEnabled returns whether the connector has MFA enabled.
IsMFAEnabled() bool
// WithMFASettings returns the connector will some settings overwritten set from MFA settings.
WithMFASettings() error
}

// NewOIDCConnector returns a new OIDCConnector based off a name and OIDCConnectorSpecV3.
Expand Down Expand Up @@ -202,6 +208,9 @@ func (o *OIDCConnectorV3) WithoutSecrets() Resource {

o2.SetClientSecret("")
o2.SetGoogleServiceAccount("")
if o2.Spec.MFASettings != nil {
o2.Spec.MFASettings.ClientSecret = ""
}

return &o2
}
Expand Down Expand Up @@ -496,6 +505,34 @@ func (o *OIDCConnectorV3) GetClientRedirectSettings() *SSOClientRedirectSettings
return o.Spec.ClientRedirectSettings
}

// GetMFASettings returns the connector's MFA settings.
func (o *OIDCConnectorV3) GetMFASettings() OIDCConnectorMFASettings {
if o.Spec.MFASettings == nil {
return OIDCConnectorMFASettings{
Enabled: false,
}
}
return *o.Spec.MFASettings
}

// IsMFAEnabled returns whether the connector has MFA enabled.
func (o *OIDCConnectorV3) IsMFAEnabled() bool {
return o.GetMFASettings().Enabled
}

// WithMFASettings returns the connector will some settings overwritten set from MFA settings.
func (o *OIDCConnectorV3) WithMFASettings() error {
if !o.IsMFAEnabled() {
return trace.BadParameter("this connector does not have MFA enabled")
}

o.Spec.ClientID = o.Spec.MFASettings.ClientId
o.Spec.ClientSecret = o.Spec.MFASettings.ClientSecret
o.Spec.ACR = o.Spec.MFASettings.AcrValues
o.Spec.Prompt = o.Spec.MFASettings.Prompt
return nil
}

// Check returns nil if all parameters are great, err otherwise
func (r *OIDCAuthRequest) Check() error {
switch {
Expand Down
32 changes: 32 additions & 0 deletions api/types/saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ type SAMLConnector interface {
GetSingleLogoutURL() string
// SetSingleLogoutURL sets the SAML SLO (single logout) URL for the identity provider.
SetSingleLogoutURL(string)
// GetMFASettings returns the connector's MFA settings.
GetMFASettings() SAMLConnectorMFASettings
// IsMFAEnabled returns whether the connector has MFA enabled.
IsMFAEnabled() bool
// WithMFASettings returns the connector will some settings overwritten set from MFA settings.
WithMFASettings() error
}

// NewSAMLConnector returns a new SAMLConnector based off a name and SAMLConnectorSpecV2.
Expand Down Expand Up @@ -391,6 +397,32 @@ func (o *SAMLConnectorV2) SetSingleLogoutURL(url string) {
o.Spec.SingleLogoutURL = url
}

// GetMFASettings returns the connector's MFA settings.
func (o *SAMLConnectorV2) GetMFASettings() SAMLConnectorMFASettings {
if o.Spec.MFASettings == nil {
return SAMLConnectorMFASettings{
Enabled: false,
}
}
return *o.Spec.MFASettings
}

// IsMFAEnabled returns whether the connector has MFA enabled.
func (o *SAMLConnectorV2) IsMFAEnabled() bool {
return o.GetMFASettings().Enabled
}

// WithMFASettings returns the connector will some settings overwritten set from MFA settings.
func (o *SAMLConnectorV2) WithMFASettings() error {
if !o.IsMFAEnabled() {
return trace.BadParameter("this connector does not have MFA enabled")
}

o.Spec.EntityDescriptor = o.Spec.MFASettings.EntityDescriptor
o.Spec.EntityDescriptorURL = o.Spec.MFASettings.EntityDescriptorUrl
return nil
}

// setStaticFields sets static resource header and metadata fields.
func (o *SAMLConnectorV2) setStaticFields() {
o.Kind = KindSAMLConnector
Expand Down
Loading