mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 12:13:29 +02:00
Add authentication-method: bearer-token
This commit is contained in:
+5
-1
@@ -173,7 +173,11 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
|
||||
token := globals.GetPass()
|
||||
authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", globals.Login.Value, token))))
|
||||
req.Header.Add("Authorization", authHeader)
|
||||
}
|
||||
} else if globals.AuthMethod() == "bearer-token" {
|
||||
token := globals.GetPass()
|
||||
authHeader := fmt.Sprintf("Bearer %s", token)
|
||||
req.Header.Add("Authorization", authHeader)
|
||||
}
|
||||
return req, nil
|
||||
})
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ func CmdLogin(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.Comm
|
||||
log.Noticef("No need to login when using api-token authentication method")
|
||||
return nil
|
||||
}
|
||||
if globals.AuthMethod() == "bearer-token" {
|
||||
log.Noticef("No need to login when using bearer-token authentication method")
|
||||
return nil
|
||||
}
|
||||
|
||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
|
||||
for {
|
||||
|
||||
+3
-3
@@ -30,13 +30,13 @@ func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
|
||||
|
||||
// CmdLogout will attempt to terminate an active Jira session
|
||||
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||
if globals.AuthMethod() == "api-token" {
|
||||
log.Noticef("No need to logout when using api-token authentication method")
|
||||
if (globals.AuthMethod() == "api-token" || globals.AuthMethod() == "bearer-token") {
|
||||
log.Noticef("No need to logout when using api-token or bearer-token authentication method")
|
||||
if globals.GetPass() != "" && terminal.IsTerminal(int(os.Stdin.Fd())) && terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
delete := false
|
||||
err := survey.AskOne(
|
||||
&survey.Confirm{
|
||||
Message: fmt.Sprintf("Delete api-token from password provider [%s]: ", globals.PasswordSource),
|
||||
Message: fmt.Sprintf("Delete token from password provider [%s]: ", globals.PasswordSource),
|
||||
Default: false,
|
||||
},
|
||||
&delete,
|
||||
|
||||
Reference in New Issue
Block a user