MCPcopy Create free account
hub / github.com/daodst/chat / ResponseWithChallenge

Method ResponseWithChallenge

clientapi/auth/user_interactive.go:179–199  ·  view source on GitHub ↗

ResponseWithChallenge mixes together a JSON body (e.g an error with errcode/message) with the standard challenge response.

(sessionID string, response interface{})

Source from the content-addressed store, hash-verified

177// ResponseWithChallenge mixes together a JSON body (e.g an error with errcode/message) with the
178// standard challenge response.
179func (u *UserInteractive) ResponseWithChallenge(sessionID string, response interface{}) *util.JSONResponse {
180 mixedObjects := make(map[string]interface{})
181 b, err := json.Marshal(response)
182 if err != nil {
183 ise := jsonerror.InternalServerError()
184 return &ise
185 }
186 _ = json.Unmarshal(b, &mixedObjects)
187 challenge := u.Challenge(sessionID)
188 b, err = json.Marshal(challenge.JSON)
189 if err != nil {
190 ise := jsonerror.InternalServerError()
191 return &ise
192 }
193 _ = json.Unmarshal(b, &mixedObjects)
194
195 return &util.JSONResponse{
196 Code: 401,
197 JSON: mixedObjects,
198 }
199}
200
201// Verify returns an error/challenge response to send to the client, or nil if the user is authenticated.
202// `bodyBytes` is the HTTP request body which must contain an `auth` key.

Callers 1

VerifyMethod · 0.95

Calls 1

ChallengeMethod · 0.95

Tested by

no test coverage detected