Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update oauth2.go #1301

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PATH := $(PWD)/bin:$(PATH)

VERSION ?= $(shell ./scripts/git-version)

DOCKER_REPO=quay.io/dexidp/dex
DOCKER_REPO=quay.io/profects/dex
DOCKER_IMAGE=$(DOCKER_REPO):$(VERSION)

$( shell mkdir -p bin )
Expand Down
4 changes: 3 additions & 1 deletion connector/microsoft/microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ func (c *microsoftConnector) oauth2Config(scopes connector.Scopes) *oauth2.Confi
if c.groupsRequired(scopes.Groups) {
microsoftScopes = append(microsoftScopes, scopeGroups)
}

if scopes.OfflineAccess {
microsoftScopes = append(microsoftScopes, "offline_access")
}
return &oauth2.Config{
ClientID: c.clientID,
ClientSecret: c.clientSecret,
Expand Down
12 changes: 7 additions & 5 deletions server/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,14 @@ func (s *Server) validateCrossClientTrust(clientID, peerID string) (trusted bool
}

func validateRedirectURI(client storage.Client, redirectURI string) bool {
if !client.Public {
for _, uri := range client.RedirectURIs {
if redirectURI == uri {
return true
}

for _, uri := range client.RedirectURIs {
if redirectURI == uri {
return true
}
}
// If no redirect url matches for non-public client the redirect url is not valid
if !client.Public {
return false
}

Expand Down
14 changes: 10 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,16 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
}
handleWithCORS := func(p string, h http.HandlerFunc) {
var handler http.Handler = h
if len(c.AllowedOrigins) > 0 {
corsOption := handlers.AllowedOrigins(c.AllowedOrigins)
handler = handlers.CORS(corsOption)(handler)
}

// if len(c.AllowedOrigins) > 0 {
// corsOption := handlers.AllowedOrigins(c.AllowedOrigins)
// handler = handlers.CORS(corsOption)(handler)
// }

corsOptions := handlers.IgnoreOptions()
corsSettings := handlers.AllowedOrigins(c.AllowedOrigins)
handler = handlers.CORS(corsSettings, corsOptions)(handler)

r.Handle(path.Join(issuerURL.Path, p), handler)
}
r.NotFoundHandler = http.HandlerFunc(http.NotFound)
Expand Down