This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix bug where users were logged out of Concourse every hour

concourse/concourse#2547

Signed-off-by: Mark Huang <mhuang@pivotal.io>
  • Loading branch information...
ddadlani committed Sep 5, 2018
1 parent dd434fb commit f7374f5fa79e0593e16a6382f60a06a2cdb440fa
Showing with 8 additions and 8 deletions.
  1. +4 −4 token/generator.go
  2. +4 −4 token/generator_test.go
@@ -55,11 +55,11 @@ func (self *generator) Generate(claims map[string]interface{}) (*oauth2.Token, e

var expiry time.Time

exp, ok := claims["exp"].(int)
if !ok {
expiry = time.Now().Add(time.Hour)
exp, ok := claims["exp"].(int64)
if ok {
expiry = time.Unix(exp, 0)
} else {
expiry = time.Unix(int64(exp), 0)
expiry = time.Now().Add(24 * time.Hour)
}

oauth2Token := &oauth2.Token{
@@ -51,7 +51,7 @@ var _ = Describe("Token Generator", func() {
JustBeforeEach(func() {
claims := map[string]interface{}{
"sub": "1234567890",
"exp": 2524608000,
"exp": int64(2524608000),
"teams": []string{"some-team"},
}

@@ -76,19 +76,19 @@ var _ = Describe("Token Generator", func() {
It("returns a jwt token with claims", func() {
var claims struct {
Sub string `json:"sub"`
Exp int `json:"exp"`
Exp int64 `json:"exp"`
Teams []string `json:"teams"`
}
err := parse(oauthToken.AccessToken, signingKey, &claims)
Expect(err).NotTo(HaveOccurred())
Expect(claims.Sub).To(Equal("1234567890"))
Expect(claims.Exp).To(Equal(2524608000))
Expect(claims.Exp).To(Equal(int64(2524608000)))
Expect(claims.Teams).To(ContainElement("some-team"))
})

It("includes the claims in the token extras", func() {
Expect(oauthToken.Extra("sub")).To(Equal("1234567890"))
Expect(oauthToken.Extra("exp")).To(Equal(2524608000))
Expect(oauthToken.Extra("exp")).To(Equal(int64(2524608000)))
Expect(oauthToken.Extra("teams")).To(ContainElement("some-team"))
})
})

0 comments on commit f7374f5

Please sign in to comment.