MCPcopy Index your code
hub / github.com/openshift/osin / getClientAuth

Method getClientAuth

util.go:95–120  ·  view source on GitHub ↗

getClientAuth checks client basic authentication in params if allowed, otherwise gets it from the header. Sets an error on the response if no auth is present or a server error occurs.

(w *Response, r *http.Request, allowQueryParams bool)

Source from the content-addressed store, hash-verified

93// otherwise gets it from the header.
94// Sets an error on the response if no auth is present or a server error occurs.
95func (s Server) getClientAuth(w *Response, r *http.Request, allowQueryParams bool) *BasicAuth {
96
97 if allowQueryParams {
98 // Allow for auth without password
99 if _, hasSecret := r.Form["client_secret"]; hasSecret {
100 auth := &BasicAuth{
101 Username: r.FormValue("client_id"),
102 Password: r.FormValue("client_secret"),
103 }
104 if auth.Username != "" {
105 return auth
106 }
107 }
108 }
109
110 auth, err := CheckBasicAuth(r)
111 if err != nil {
112 s.setErrorAndLog(w, E_INVALID_REQUEST, err, "get_client_auth=%s", "check auth error")
113 return nil
114 }
115 if auth == nil {
116 s.setErrorAndLog(w, E_INVALID_REQUEST, errors.New("Client authentication not sent"), "get_client_auth=%s", "client authentication not sent")
117 return nil
118 }
119 return auth
120}

Calls 2

setErrorAndLogMethod · 0.95
CheckBasicAuthFunction · 0.85

Tested by 1

TestGetClientAuthFunction · 0.76