Skip to content

Commit fedc666

Browse files
committed
Add authentication-method: bearer-token
1 parent a59fdc8 commit fedc666

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

jiracli/cli.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
173173
token := globals.GetPass()
174174
authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", globals.Login.Value, token))))
175175
req.Header.Add("Authorization", authHeader)
176-
}
176+
} else if globals.AuthMethod() == "bearer-token" {
177+
token := globals.GetPass()
178+
authHeader := fmt.Sprintf("Bearer %s", token)
179+
req.Header.Add("Authorization", authHeader)
180+
}
177181
return req, nil
178182
})
179183

jiracmd/login.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func CmdLogin(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.Comm
5050
log.Noticef("No need to login when using api-token authentication method")
5151
return nil
5252
}
53+
if globals.AuthMethod() == "bearer-token" {
54+
log.Noticef("No need to login when using bearer-token authentication method")
55+
return nil
56+
}
5357

5458
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
5559
for {

jiracmd/logout.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
3030

3131
// CmdLogout will attempt to terminate an active Jira session
3232
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
33-
if globals.AuthMethod() == "api-token" {
34-
log.Noticef("No need to logout when using api-token authentication method")
33+
if (globals.AuthMethod() == "api-token" || globals.AuthMethod() == "bearer-token") {
34+
log.Noticef("No need to logout when using api-token or bearer-token authentication method")
3535
if globals.GetPass() != "" && terminal.IsTerminal(int(os.Stdin.Fd())) && terminal.IsTerminal(int(os.Stdout.Fd())) {
3636
delete := false
3737
err := survey.AskOne(
3838
&survey.Confirm{
39-
Message: fmt.Sprintf("Delete api-token from password provider [%s]: ", globals.PasswordSource),
39+
Message: fmt.Sprintf("Delete token from password provider [%s]: ", globals.PasswordSource),
4040
Default: false,
4141
},
4242
&delete,

0 commit comments

Comments
 (0)