Skip to content
Open
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 auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func ProtectedResourceMetadataHandler(metadata *oauthex.ProtectedResourceMetadat
// Set CORS headers for cross-origin client discovery.
// OAuth metadata is public information, so allowing any origin is safe.
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Methods", "GET")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")

// Handle CORS preflight requests
Expand Down
4 changes: 2 additions & 2 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func TestProtectedResourceMetadataHandler(t *testing.T) {
t.Errorf("Access-Control-Allow-Origin = %q, want %q", got, "*")
}

if got := rec.Header().Get("Access-Control-Allow-Methods"); got != "GET, OPTIONS" {
t.Errorf("Access-Control-Allow-Methods = %q, want %q", got, "GET, OPTIONS")
if got := rec.Header().Get("Access-Control-Allow-Methods"); got != "GET" {
t.Errorf("Access-Control-Allow-Methods = %q, want %q", got, "GET")
}

// Validate error response body for disallowed methods
Expand Down
4 changes: 2 additions & 2 deletions examples/server/auth-middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ import "github.com/rs/cors"

c := cors.New(cors.Options{
AllowedOrigins: []string{"https://example.com"},
AllowedMethods: []string{"GET", "OPTIONS"},
AllowedMethods: []string{"GET"},
})
http.Handle("/.well-known/oauth-protected-resource",
c.Handler(auth.ProtectedResourceMetadataHandler(metadata)))
Expand All @@ -258,7 +258,7 @@ import "github.com/jub0bs/cors"

corsMiddleware, err := cors.NewMiddleware(cors.Config{
Origins: []string{"https://example.com"},
Methods: []string{"GET", "OPTIONS"},
Methods: []string{"GET"},
})
http.Handle("/.well-known/oauth-protected-resource",
corsMiddleware.Wrap(auth.ProtectedResourceMetadataHandler(metadata)))
Expand Down
2 changes: 1 addition & 1 deletion internal/oauthtest/fake_authorization_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (s *FakeAuthorizationServer) handleMetadata(w http.ResponseWriter, r *http.
}
// Set CORS headers for cross-origin client discovery.
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Methods", "GET")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")

// Handle CORS preflight requests
Expand Down