Skip to content

Commit 9cfb6c9

Browse files
committed
Update settings for the demo application, fix response for add token to memory storage
1 parent 77ba650 commit 9cfb6c9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

example/main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
)
1717

1818
var (
19-
clientID = "5c7fd8c50dd75d000162c69f"
20-
clientSecret = "TVzu97mMqsn4bRQbgS07MdIuf3TMgZHEm0fjKWWP5DvzppyTtXA8sgQtqazr91zq"
19+
clientID = "5cb26c6592e0d90001683757"
20+
clientSecret = "eUvn3orwIhXp7jY1QLOuFO1Z1ZqSkJWJx3yLoXbwP2pJeWbcnlM3uHR5XjRz4DUF"
2121
scopes = []string{"openid", "offline"}
2222
responseType = "code"
2323
redirectUri = "http://127.0.0.1:1323/auth/callback"
@@ -95,6 +95,8 @@ func main() {
9595
e.GET("/logout", logout)
9696
// Logout callback for clean local tokens, session and etc.
9797
e.GET("/logout_result", logoutResult)
98+
// Logout callback for clean local tokens, session and etc.
99+
e.GET("/introspect", introspectTest)
98100

99101
// Start server
100102
e.Logger.Fatal(e.Start(":1323"))
@@ -258,3 +260,11 @@ func validateIdToken(c context.Context, token *jwtverifier.Token) (*jwtverifier.
258260
fmt.Printf("ID token: %+v\n", t)
259261
return t, nil
260262
}
263+
264+
func introspectTest(ctx echo.Context) error {
265+
token := ctx.QueryParam("token")
266+
t, err := jwtv.Introspect(ctx.Request().Context(), token)
267+
fmt.Println(t)
268+
fmt.Println(err)
269+
return nil
270+
}

storage/memory/memory_storage.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
)
99

1010
const (
11-
ErrorTokenAdd = "unbale to add token"
1211
ErrorTokenNotExists = "token not exists"
1312
ErrorTokenIsExpired = "token is expired"
1413
MaxSize = 5000
@@ -35,9 +34,7 @@ func (tsm tokenStorageMemory) Set(token string, expire int64, introspect []byte)
3534
value: introspect,
3635
duration: time.Unix(expire, 0).Sub(time.Now()),
3736
}
38-
if false == tsm.cache.Add(token, e) {
39-
return errors.New(ErrorTokenAdd)
40-
}
37+
tsm.cache.Add(token, e)
4138
return nil
4239
}
4340

0 commit comments

Comments
 (0)