Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keycloak-proxy
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
keycloak-proxy
Commits
24f11d0e
Commit
24f11d0e
authored
Aug 1, 2016
by
Rohith
Browse files
Options
Downloads
Patches
Plain Diff
- fixing the refresh token bug in the forwarding
- adding some extra debugging and logging
parent
c03e4e25
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
forwarding.go
+17
-3
17 additions, 3 deletions
forwarding.go
with
17 additions
and
3 deletions
forwarding.go
+
17
−
3
View file @
24f11d0e
...
@@ -96,7 +96,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -96,7 +96,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
if
state
.
login
{
if
state
.
login
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"username"
:
r
.
config
.
ForwardingUsername
,
"username"
:
r
.
config
.
ForwardingUsername
,
})
.
Debug
f
(
"requesting access token for user"
)
})
.
Info
f
(
"requesting access token for user"
)
// step: login into the service
// step: login into the service
resp
,
err
:=
client
.
UserCredsToken
(
r
.
config
.
ForwardingUsername
,
r
.
config
.
ForwardingPassword
)
resp
,
err
:=
client
.
UserCredsToken
(
r
.
config
.
ForwardingUsername
,
r
.
config
.
ForwardingPassword
)
...
@@ -127,6 +127,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -127,6 +127,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
state
.
identity
=
identity
state
.
identity
=
identity
state
.
expiration
=
identity
.
ExpiresAt
state
.
expiration
=
identity
.
ExpiresAt
state
.
wait
=
true
state
.
wait
=
true
state
.
login
=
false
state
.
refresh
=
resp
.
RefreshToken
state
.
refresh
=
resp
.
RefreshToken
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
...
@@ -139,7 +140,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -139,7 +140,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"subject"
:
state
.
identity
.
ID
,
"subject"
:
state
.
identity
.
ID
,
"email"
:
state
.
identity
.
Email
,
"email"
:
state
.
identity
.
Email
,
})
.
Debug
f
(
"access token is about to expiry"
)
})
.
Info
f
(
"access token is about to expiry"
)
// step: if we a have a refresh token, we need to login again
// step: if we a have a refresh token, we need to login again
if
state
.
refresh
!=
""
{
if
state
.
refresh
!=
""
{
...
@@ -147,7 +148,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -147,7 +148,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
"subject"
:
state
.
identity
.
ID
,
"subject"
:
state
.
identity
.
ID
,
"email"
:
state
.
identity
.
Email
,
"email"
:
state
.
identity
.
Email
,
"expires"
:
state
.
expiration
.
Format
(
time
.
RFC822Z
),
"expires"
:
state
.
expiration
.
Format
(
time
.
RFC822Z
),
})
.
Debug
f
(
"attempting to refresh the access token"
)
})
.
Info
f
(
"attempting to refresh the access token"
)
// step: attempt to refresh the access
// step: attempt to refresh the access
token
,
expiration
,
err
:=
getRefreshedToken
(
r
.
client
,
state
.
refresh
)
token
,
expiration
,
err
:=
getRefreshedToken
(
r
.
client
,
state
.
refresh
)
...
@@ -173,7 +174,19 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -173,7 +174,19 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
state
.
wait
=
true
state
.
wait
=
true
state
.
login
=
false
state
.
login
=
false
// step: add some debugging
log
.
WithFields
(
log
.
Fields
{
"subject"
:
state
.
identity
.
ID
,
"email"
:
state
.
identity
.
Email
,
"expires"
:
state
.
expiration
.
Format
(
time
.
RFC822Z
),
})
.
Infof
(
"successfully refreshed the access token"
)
}
else
{
}
else
{
log
.
WithFields
(
log
.
Fields
{
"subject"
:
state
.
identity
.
ID
,
"email"
:
state
.
identity
.
Email
,
})
.
Infof
(
"session does not support refresh token, acquiring new token"
)
// step: we don't have a refresh token, we must perform a login again
// step: we don't have a refresh token, we must perform a login again
state
.
wait
=
false
state
.
wait
=
false
state
.
login
=
true
state
.
login
=
true
...
@@ -189,6 +202,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
...
@@ -189,6 +202,7 @@ func (r *oauthProxy) forwardProxyHandler() func(*http.Request, *http.Response) {
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"token_expiration"
:
state
.
expiration
.
Format
(
time
.
RFC822Z
),
"token_expiration"
:
state
.
expiration
.
Format
(
time
.
RFC822Z
),
"token_renewel"
:
waiting
.
Format
(
time
.
RFC822Z
),
"token_renewel"
:
waiting
.
Format
(
time
.
RFC822Z
),
"duration"
:
duration
.
String
(),
})
.
Debugf
(
"waiting for expiration of access token"
)
})
.
Debugf
(
"waiting for expiration of access token"
)
<-
time
.
After
(
duration
)
<-
time
.
After
(
duration
)
...
...
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