Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
3df5f6c6
Commit
3df5f6c6
authored
2 years ago
by
Jano Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
Return session token if JWT is expired
parent
6c47a19e
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/session.go
+6
-4
6 additions, 4 deletions
auth/session.go
with
6 additions
and
4 deletions
auth/session.go
+
6
−
4
View file @
3df5f6c6
...
...
@@ -51,17 +51,19 @@ func GetSignedSessionTokenString(request events.APIGatewayProxyRequest, secretKe
// ValidateJWTWithSessionTokens attempts to validate the JWT string by signing each session token using the secret, and
// using the resulting signed session token to validate the JWT. If the JWT can be validated using a session token, the
// JsonWebToken is returned, otherwise nil is returned.
func
ValidateJWTWithSessionTokens
(
jsonWebTokenString
string
,
secretKey
string
,
sessionTokens
[]
string
)
*
JsonWebToken
{
// JsonWebToken is returned, otherwise nil is returned.
If the JWT is expired, nil is returned along with the session token.
func
ValidateJWTWithSessionTokens
(
jsonWebTokenString
string
,
secretKey
string
,
sessionTokens
[]
string
)
(
validJsonWebToken
*
JsonWebToken
,
expiredSessionToken
*
string
)
{
// Test each session token to find one that is valid
for
_
,
sessionToken
:=
range
sessionTokens
{
jsonWebToken
,
err
:=
ValidateJWTWithSessionToken
(
jsonWebTokenString
,
secretKey
,
sessionToken
)
if
err
==
nil
{
return
&
jsonWebToken
return
&
jsonWebToken
,
nil
}
else
if
err
.
Error
()
==
"token has expired"
{
return
nil
,
&
sessionToken
}
}
return
nil
return
nil
,
nil
}
// FindAndRemoveCurrentSessionToken attempts to validate the JWT string by signing each session token using the secret,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment