Skip to content

Commit 5c2563a

Browse files
Merge pull request #2 from orange-cloudfoundry/release-orange-v2.37.0
Release orange v2.37.0-orange
2 parents 771bf9c + c42367b commit 5c2563a

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
![logo](docs/logos/dex-horizontal-color.png)
99

10-
1110
Dex is an identity service that uses [OpenID Connect][openid-connect] to drive authentication for other apps.
1211

1312
Dex acts as a portal to other identity providers through ["connectors."](#connectors) This lets dex defer authentication to LDAP servers, SAML providers, or established identity providers like GitHub, Google, and Active Directory. Clients write their authentication logic once to talk to dex, then dex handles the protocols for a given backend.

cmd/dex/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ type Web struct {
150150
TLSCert string `json:"tlsCert"`
151151
TLSKey string `json:"tlsKey"`
152152
AllowedOrigins []string `json:"allowedOrigins"`
153+
FrameAncestors []string `json:"frameAncestors"`
153154
}
154155

155156
// Telemetry is the config format for telemetry including the HTTP server config.

cmd/dex/serve.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ func runServe(options serveOptions) error {
253253
logger.Infof("config allowed origins: %s", c.Web.AllowedOrigins)
254254
}
255255

256+
if len(c.Web.FrameAncestors) > 0 {
257+
logger.Infof("config allowed frame ancestors: %s", c.Web.FrameAncestors)
258+
}
259+
256260
// explicitly convert to UTC.
257261
now := func() time.Time { return time.Now().UTC() }
258262

server/oauth2.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ const (
145145
)
146146

147147
const (
148-
responseTypeCode = "code" // "Regular" flow
149-
responseTypeToken = "token" // Implicit flow for frontend apps.
150-
responseTypeIDToken = "id_token" // ID Token in url fragment
148+
responseTypeCode = "code" // "Regular" flow
149+
responseTypeToken = "token" // Implicit flow for frontend apps.
150+
responseTypeIDToken = "id_token" // ID Token in url fragment
151+
responseTypeCodeToken = "code token" // "Regular" flow + Implicit flow
152+
responseTypeCodeIDToken = "code id_token" // "Regular" flow + ID Token
153+
responseTypeIDTokenToken = "id_token token" // ID Token + Implicit flow
154+
responseTypeCodeIDTokenToken = "code id_token token" // "Regular" flow + ID Token + Implicit flow
151155
)
152156

153157
const (

server/server.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ type Config struct {
7777
// domain.
7878
AllowedOrigins []string
7979

80+
// List of domain allowed to frame the content of the application.
81+
// By default no one is accepted to prevent against clickjacking.
82+
// Passing in "*" will allow any domain
83+
FrameAncestors []string
84+
8085
// If enabled, the server won't prompt the user to approve authorization requests.
8186
// Logging in implies approval.
8287
SkipApprovalScreen bool
@@ -225,9 +230,9 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
225230

226231
for _, respType := range c.SupportedResponseTypes {
227232
switch respType {
228-
case responseTypeCode, responseTypeIDToken:
233+
case responseTypeCode, responseTypeIDToken, responseTypeCodeIDToken:
229234
// continue
230-
case responseTypeToken:
235+
case responseTypeToken, responseTypeCodeToken, responseTypeIDTokenToken, responseTypeCodeIDTokenToken:
231236
// response_type=token is an implicit flow, let's add it to the discovery info
232237
// https://datatracker.ietf.org/doc/html/rfc6749#section-4.2.1
233238
allSupportedGrants[grantTypeImplicit] = true
@@ -339,7 +344,27 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
339344
}
340345
}
341346

347+
// frame-ancestors middleware
348+
frameAncestorsMidldleware := func(next http.Handler) http.Handler {
349+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
350+
var ancestors string
351+
if len(c.FrameAncestors) > 0 {
352+
for i := 0; i < len(c.FrameAncestors); i++ {
353+
if c.FrameAncestors[i] == issuerURL.String() {
354+
c.FrameAncestors[i] = "'self'"
355+
}
356+
}
357+
ancestors = strings.Join(c.FrameAncestors, " ")
358+
} else {
359+
ancestors = "'none'"
360+
}
361+
w.Header().Set("Content-Security-Policy", "frame-ancestors "+ancestors)
362+
next.ServeHTTP(w, r)
363+
})
364+
}
365+
342366
r := mux.NewRouter().SkipClean(true).UseEncodedPath()
367+
r.Use(frameAncestorsMidldleware)
343368
handle := func(p string, h http.Handler) {
344369
r.Handle(path.Join(issuerURL.Path, p), instrumentHandlerCounter(p, h))
345370
}

0 commit comments

Comments
 (0)