markbates / markbates/goth

Feat: Allow adding custom values to session

Open
#611 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
6.6k
Forks
631
PR merge metrics
No merged PRs in 30d

Description

I ran into a situation where I needed to retain a small state between the oauth initialization and callback step

the package currently exposes a `StoreInSession` function to write key/value to the session. The issue is that it commits the session to the request after setting that value, so any other calls to the function will overrides the previous values

to work around this, I ended up creating a separate short-lived session (alongside the gothic session) that lives only during the oauth flow, it works but it adds unnecessary complexity for just storing a couple of values temporarily

I think its fine to have separate session to manage long-lived states, but for use cases like mine, it would be more efficient to have a way to write multiple values at once

something like:

``` go
// current
StoreInSession(key string, value string, req *http.Request, res http.ResponseWriter)

// suggested
StoreInSessionValues(values map[string]string, req *http.Request, res http.ResponseWriter)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing StoreInSession function and its session commit behavior. Add a way to write multiple key/value pairs in one session operation, then verify that values such as temporary OAuth state survive together from initialization through the callback.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.