mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-01 10:22:43 +02:00
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
d5d180aa01
commit
4491d1b0e9
1 changed files with 22 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package sessions
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
@ -182,3 +183,24 @@ func (s *State) accessTokenHash() string {
|
|||
}
|
||||
return fmt.Sprintf("%x", hash)
|
||||
}
|
||||
|
||||
// UnmarshalJSON parses the JSON-encoded session state.
|
||||
// TODO(BDD): remove in v0.8.0
|
||||
func (s *State) UnmarshalJSON(b []byte) error {
|
||||
type Alias State
|
||||
t := &struct {
|
||||
*Alias
|
||||
OldToken *oauth2.Token `json:"access_token,omitempty"` // < v0.5.0
|
||||
}{
|
||||
Alias: (*Alias)(s),
|
||||
}
|
||||
if err := json.Unmarshal(b, &t); err != nil {
|
||||
return err
|
||||
}
|
||||
if t.AccessToken == nil {
|
||||
t.AccessToken = t.OldToken
|
||||
}
|
||||
*s = *(*State)(t.Alias)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue