go-jira
go-jira copied to clipboard
Allow import/export of session
Description
This adds two functions ImportSession
and ExportSession
. These functions allow you to cache authentication cookies so you don't have to reauthenticate as often. This is especially useful for CLI apps that don't include a long running process to hold the session. The session is exported as a json byte array, so it is very easy to store in just about any caching mechanism. I'll demonstrate Redis below.
Example:
session, err := redisClient.Get("jiraSession").Bytes()
if err != nil {
_, err = jiraClient.Authentication.AcquireSessionCookie(jiraUsername, jiraPassword)
if err != nil {
return nil, err
}
session = jiraClient.Authentication.ExportSession()
_ = redisClient.Set("jiraSession", session, time.Hour).Err()
} else {
jiraClient.Authentication.ImportSession(session)
}
Checklist
- [ ] Unit or Integration tests added
- [ ] Good Path
- [ ] Error Path
- [ ] Commits follow conventions described here:
- [ ] Commits are squashed such that
- [ ] There is 1 commit per isolated change
- [ ] I've not made extraneous commits/changes that are unrelated to my change.
Hey @guywithnose, thanks for your effort and this PR. We, the maintainers, are right now quite packed with other work. Hence, the review of this pull request will take a while. Thanks for understanding.
Hey,
I am very sorry that this pull request has been open for a long time with no final feedback or merge/decline. We work on this project in our spare time, and sometimes, other priorities take over. This is the typical open source dilemma.
However, there is news: We are kicking off v2 of this library 🚀
To provide visibility, we created the Road to v2 Milestone and calling for your feedback in https://github.com/andygrunwald/go-jira/issues/489
The development will take some time; however, I hope you can benefit from the changes. If you seek priority development for your pull request + you like to sponsor it, please contact me.
What does this mean for my pull request?
We will work on this pull request indirectly. We might merge it during the development or pull parts of it into the new version. This means that during the development phase, we aim to tackle it. Maybe in a different way like it is currently handled. Please understand that this will take a while because we are running this in our spare time.
Final words
Thanks for using and contributing to this library. If there is anything else you would like to tell us, let us know!