First implementation of authentication handling
This commit is contained in:
@@ -269,3 +269,49 @@ where each item identifies either @racket['stdout] or @racket['stderr].
|
||||
#:input "protocol=https\nhost=git.dijkewijk.nl\n\n")
|
||||
]
|
||||
}
|
||||
|
||||
@section{Authentication retry}
|
||||
|
||||
Git commands recognize common authentication failures immediately after the
|
||||
Git process finishes and before command-specific result processing takes
|
||||
place. Such a failure is represented by @racket[exn:fail:git-auth?].
|
||||
|
||||
@defparam[current-git-authentication-handler handler procedure?]{
|
||||
Controls the callback used when an authentication failure is detected. The
|
||||
callback receives the Git command symbol, the processed Git argument list and
|
||||
the @racket[exn:fail:git-auth] exception.
|
||||
|
||||
The callback returns a true value when it has handled authentication and the
|
||||
original Git command should be tried again. A command is retried at most once.
|
||||
The default callback returns @racket[#f], preserving the normal Git error
|
||||
behavior.
|
||||
|
||||
@racketblock[
|
||||
(current-git-authentication-handler
|
||||
(lambda (cmd args e)
|
||||
;; Perform credential handling here.
|
||||
#t))
|
||||
]
|
||||
}
|
||||
|
||||
@defproc[(exn:fail:git-auth? [v any/c]) boolean?]{
|
||||
Recognizes the authentication exception used internally by git-cli.
|
||||
}
|
||||
|
||||
@defproc[(exn:fail:git-auth-command [e exn:fail:git-auth?]) symbol?]{
|
||||
Returns the Git command of the failed invocation.
|
||||
}
|
||||
|
||||
@defproc[(exn:fail:git-auth-args [e exn:fail:git-auth?]) list?]{
|
||||
Returns the processed Git arguments of the failed invocation.
|
||||
}
|
||||
|
||||
@defproc[(exn:fail:git-auth-exit-code [e exn:fail:git-auth?]) exact-integer?]{
|
||||
Returns Git's exit code.
|
||||
}
|
||||
|
||||
@defproc[(exn:fail:git-auth-output [e exn:fail:git-auth?]) list?]{
|
||||
Returns the ordered @racket['stdout]/@racket['stderr] output items from the
|
||||
failed Git process.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user