Skip to content

Commit 9e94122

Browse files
committed
TUN-9820: Add support for FedRAMP in originRequest Access config
* TUN-9820: Add support for FedRAMP in originRequest Access config Closes TUN-9820
1 parent 173396b commit 9e94122

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

cmd/cloudflared/tunnel/configuration.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
const (
3737
secretValue = "*****"
3838
icmpFunnelTimeout = time.Second * 10
39-
fedRampRegion = "fed" // const string denoting the region used to connect to FEDRamp servers
4039
)
4140

4241
var (

config/configuration.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ type AccessConfig struct {
242242

243243
// AudTag is the AudTag to verify access JWT against.
244244
AudTag []string `yaml:"audTag" json:"audTag"`
245+
246+
Environment string `yaml:"environment" json:"environment,omitempty"`
245247
}
246248

247249
type IngressIPRule struct {

ingress/ingress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
317317
return Ingress{}, err
318318
}
319319
if access.Required {
320-
verifier := middleware.NewJWTValidator(access.TeamName, "", access.AudTag)
320+
verifier := middleware.NewJWTValidator(access.TeamName, access.Environment, access.AudTag)
321321
handlers = append(handlers, verifier)
322322
}
323323
}

ingress/middleware/jwtvalidator.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import (
66
"net/http"
77

88
"github.com/coreos/go-oidc/v3/oidc"
9+
10+
"github.com/cloudflare/cloudflared/credentials"
911
)
1012

1113
const (
1214
headerKeyAccessJWTAssertion = "Cf-Access-Jwt-Assertion"
1315
)
1416

1517
var (
16-
cloudflareAccessCertsURL = "https://%s.cloudflareaccess.com"
18+
cloudflareAccessCertsURL = "https://%s.cloudflareaccess.com"
19+
cloudflareAccessFedCertsURL = "https://%s.fed.cloudflareaccess.com"
1720
)
1821

1922
// JWTValidator is an implementation of Verifier that validates access based JWT tokens.
@@ -22,10 +25,14 @@ type JWTValidator struct {
2225
audTags []string
2326
}
2427

25-
func NewJWTValidator(teamName string, certsURL string, audTags []string) *JWTValidator {
26-
if certsURL == "" {
28+
func NewJWTValidator(teamName string, environment string, audTags []string) *JWTValidator {
29+
var certsURL string
30+
if environment == credentials.FedEndpoint {
31+
certsURL = fmt.Sprintf(cloudflareAccessFedCertsURL, teamName)
32+
} else {
2733
certsURL = fmt.Sprintf(cloudflareAccessCertsURL, teamName)
2834
}
35+
2936
certsEndpoint := fmt.Sprintf("%s/cdn-cgi/access/certs", certsURL)
3037

3138
config := &oidc.Config{

0 commit comments

Comments
 (0)