@@ -209,6 +209,12 @@ func (webauthn *WebAuthn) FinishLogin(user User, session SessionData, response *
209209// FinishDiscoverableLogin takes the response from the client and validate it against the handler and stored session data.
210210// The handler helps to find out which user must be used to validate the response. This is a function defined in your
211211// business code that will retrieve the user from your persistent data.
212+ //
213+ // As with all Finish functions this function requires a *http.Request but you can perform the same steps with the
214+ // protocol.ParseCredentialRequestResponseBody or protocol.ParseCredentialRequestResponseBytes which require an
215+ // io.Reader or byte array respectively, you can also use an arbitrary *protocol.ParsedCredentialAssertionData which is
216+ // returned from all of these functions i.e. by implementing a custom parser. The DiscoverableUserHandler, *SessionData,
217+ // and *protocol.ParsedCredentialAssertionData can then be used with the ValidatePasskeyLogin function.
212218func (webauthn * WebAuthn ) FinishDiscoverableLogin (handler DiscoverableUserHandler , session SessionData , response * http.Request ) (credential * Credential , err error ) {
213219 var parsedResponse * protocol.ParsedCredentialAssertionData
214220
@@ -222,6 +228,12 @@ func (webauthn *WebAuthn) FinishDiscoverableLogin(handler DiscoverableUserHandle
222228// FinishPasskeyLogin takes the response from the client and validate it against the handler and stored session data.
223229// The handler helps to find out which user must be used to validate the response. This is a function defined in your
224230// business code that will retrieve the user from your persistent data.
231+ //
232+ // As with all Finish functions this function requires a *http.Request but you can perform the same steps with the
233+ // protocol.ParseCredentialRequestResponseBody or protocol.ParseCredentialRequestResponseBytes which require an
234+ // io.Reader or byte array respectively, you can also use an arbitrary *protocol.ParsedCredentialAssertionData which is
235+ // returned from all of these functions i.e. by implementing a custom parser. The DiscoverableUserHandler, *SessionData,
236+ // and *protocol.ParsedCredentialAssertionData can then be used with the ValidatePasskeyLogin function.
225237func (webauthn * WebAuthn ) FinishPasskeyLogin (handler DiscoverableUserHandler , session SessionData , response * http.Request ) (user User , credential * Credential , err error ) {
226238 var parsedResponse * protocol.ParsedCredentialAssertionData
227239
@@ -233,6 +245,9 @@ func (webauthn *WebAuthn) FinishPasskeyLogin(handler DiscoverableUserHandler, se
233245}
234246
235247// ValidateLogin takes a parsed response and validates it against the user credentials and session data.
248+ //
249+ // If you wish to skip performing the step required to parse the *protocol.ParsedCredentialAssertionData and
250+ // you're using net/http then you can use FinishLogin instead.
236251func (webauthn * WebAuthn ) ValidateLogin (user User , session SessionData , parsedResponse * protocol.ParsedCredentialAssertionData ) (credential * Credential , err error ) {
237252 if ! bytes .Equal (user .WebAuthnID (), session .UserID ) {
238253 return nil , protocol .ErrBadRequest .WithDetails ("ID mismatch for User and Session" )
@@ -247,6 +262,9 @@ func (webauthn *WebAuthn) ValidateLogin(user User, session SessionData, parsedRe
247262
248263// ValidateDiscoverableLogin is an overloaded version of ValidateLogin that allows for discoverable credentials.
249264//
265+ // If you wish to skip performing the step required to parse the *protocol.ParsedCredentialAssertionData and
266+ // you're using net/http then you can use FinishDiscoverableLogin instead.
267+ //
250268// Note: this is just a backwards compatibility layer over ValidatePasskeyLogin which returns more information.
251269func (webauthn * WebAuthn ) ValidateDiscoverableLogin (handler DiscoverableUserHandler , session SessionData , parsedResponse * protocol.ParsedCredentialAssertionData ) (credential * Credential , err error ) {
252270 _ , credential , err = webauthn .ValidatePasskeyLogin (handler , session , parsedResponse )
@@ -255,6 +273,9 @@ func (webauthn *WebAuthn) ValidateDiscoverableLogin(handler DiscoverableUserHand
255273}
256274
257275// ValidatePasskeyLogin is an overloaded version of ValidateLogin that allows for passkey credentials.
276+ //
277+ // If you wish to skip performing the step required to parse the *protocol.ParsedCredentialAssertionData and
278+ // you're using net/http then you can use FinishPasskeyLogin instead.
258279func (webauthn * WebAuthn ) ValidatePasskeyLogin (handler DiscoverableUserHandler , session SessionData , parsedResponse * protocol.ParsedCredentialAssertionData ) (user User , credential * Credential , err error ) {
259280 if len (session .UserID ) != 0 {
260281 return nil , nil , protocol .ErrBadRequest .WithDetails ("Session was not initiated as a client-side discoverable login" )
@@ -275,7 +296,7 @@ func (webauthn *WebAuthn) ValidatePasskeyLogin(handler DiscoverableUserHandler,
275296 return user , credential , nil
276297}
277298
278- // ValidateLogin takes a parsed response and validates it against the user credentials and session data.
299+ // validateLogin takes a parsed response and validates it against the user credentials and session data.
279300func (webauthn * WebAuthn ) validateLogin (user User , session SessionData , parsedResponse * protocol.ParsedCredentialAssertionData ) (* Credential , error ) {
280301 // Step 1. If the allowCredentials option was given when this authentication ceremony was initiated,
281302 // verify that credential.id identifies one of the public key credentials that were listed in
0 commit comments