MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / checkLoginCORS

Method checkLoginCORS

rest/session_api.go:360–369  ·  view source on GitHub ↗

checkLoginCORS validates the auth.CORSConfig.LoginOrigin section of CORS for requests. Note: Validation of the general Origin header against auth.CORSConfig.Origin happens separately in validateAndWriteHeaders.

()

Source from the content-addressed store, hash-verified

358// checkLoginCORS validates the auth.CORSConfig.LoginOrigin section of CORS for requests.
359// Note: Validation of the general Origin header against auth.CORSConfig.Origin happens separately in validateAndWriteHeaders.
360func (h *handler) checkLoginCORS() error {
361 originHeader := h.rq.Header["Origin"]
362 if len(originHeader) > 0 {
363 cors := h.getCORSConfig()
364 if cors.IsEmpty() || auth.MatchedOrigin(cors.LoginOrigin, originHeader) == "" {
365 return base.HTTPErrorf(http.StatusBadRequest, "No CORS")
366 }
367 }
368 return nil
369}

Callers 4

handleFacebookPOSTMethod · 0.95
handleSessionPOSTMethod · 0.95
handleSessionDELETEMethod · 0.95
handleGooglePOSTMethod · 0.95

Calls 4

getCORSConfigMethod · 0.95
MatchedOriginFunction · 0.92
HTTPErrorfFunction · 0.92
IsEmptyMethod · 0.45

Tested by

no test coverage detected