Skip to content

Commit

Permalink
add option to allow client redirects from IPs in specified CIDR range…
Browse files Browse the repository at this point in the history
…s in SSO client logins (#44556)

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
  • Loading branch information
capnspacehook authored Jul 30, 2024
1 parent ee29097 commit bca2943
Show file tree
Hide file tree
Showing 30 changed files with 1,341 additions and 742 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4436,6 +4436,8 @@ message MaxAge {
message SSOClientRedirectSettings {
// a list of hostnames allowed for https client redirect URLs
repeated string allowed_https_hostnames = 1;
// a list of CIDRs allowed for HTTP or HTTPS client redirect URLs
repeated string insecure_allowed_cidr_ranges = 2;
}

// OIDCAuthRequest is a request to authenticate with OIDC
Expand Down
23 changes: 23 additions & 0 deletions api/types/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package types

import (
"net/netip"
"net/url"
"slices"
"time"
Expand All @@ -35,6 +36,11 @@ type OIDCConnector interface {
// ResourceWithSecrets provides common methods for objects
ResourceWithSecrets
ResourceWithOrigin
// Validate will preform checks not found in CheckAndSetDefaults
// that should only be preformed when the OIDC connector resource
// itself is being created or updated, not when a OIDCConnector
// object is being created or updated.
Validate() error
// Issuer URL is the endpoint of the provider, e.g. https://accounts.google.com
GetIssuerURL() string
// ClientID is id for authentication client (in our case it's our Auth server)
Expand Down Expand Up @@ -449,6 +455,23 @@ func (o *OIDCConnectorV3) CheckAndSetDefaults() error {
return nil
}

// Validate will preform checks not found in CheckAndSetDefaults
// that should only be preformed when the OIDC connector resource
// itself is being created or updated, not when a OIDCConnector
// object is being created or updated.
func (o *OIDCConnectorV3) Validate() error {
if o.Spec.ClientRedirectSettings != nil {
for _, cidrStr := range o.Spec.ClientRedirectSettings.InsecureAllowedCidrRanges {
_, err := netip.ParsePrefix(cidrStr)
if err != nil {
return trace.BadParameter("bad CIDR range in insecure_allowed_cidr_ranges '%s': %v", cidrStr, err)
}
}
}

return nil
}

// GetAllowUnverifiedEmail returns true if unverified emails should be allowed in received users.
func (o *OIDCConnectorV3) GetAllowUnverifiedEmail() bool {
return o.Spec.AllowUnverifiedEmail
Expand Down
Loading

0 comments on commit bca2943

Please sign in to comment.