Clone returns a deep-enough copy that fosite handlers can mutate the returned session without affecting the original. Required by the fosite.Session interface contract — fosite calls Clone() before handing a session to a handler that may extend it.
()
| 53 | // fosite.Session interface contract — fosite calls Clone() before |
| 54 | // handing a session to a handler that may extend it. |
| 55 | func (s *Session) Clone() fosite.Session { |
| 56 | if s == nil { |
| 57 | return nil |
| 58 | } |
| 59 | cp := *s |
| 60 | if s.ExpiresAtMap != nil { |
| 61 | cp.ExpiresAtMap = make(map[fosite.TokenType]time.Time, len(s.ExpiresAtMap)) |
| 62 | for k, v := range s.ExpiresAtMap { |
| 63 | cp.ExpiresAtMap[k] = v |
| 64 | } |
| 65 | } |
| 66 | return &cp |
| 67 | } |
| 68 | |
| 69 | // Compile-time check. |
| 70 | var _ fosite.Session = (*Session)(nil) |
no test coverage detected