[go: up one dir, main page]

Skip to content

Commit

Permalink
Add authentication-method: bearer-token
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Aug 3, 2021
1 parent a59fdc8 commit fedc666
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion jiracli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
4 changes: 4 additions & 0 deletions jiracmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions jiracmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fedc666

Please sign in to comment.