Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
5586a3c1
Commit
5586a3c1
authored
Mar 13, 2017
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/sql: add missing WHERE statement to refresh token update
parent
29af9b4c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
conformance.go
storage/conformance/conformance.go
+29
-0
crud.go
storage/sql/crud.go
+3
-1
No files found.
storage/conformance/conformance.go
View file @
5586a3c1
...
@@ -269,6 +269,32 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
...
@@ -269,6 +269,32 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
getAndCompare
(
id
,
refresh
)
getAndCompare
(
id
,
refresh
)
id2
:=
storage
.
NewID
()
refresh2
:=
storage
.
RefreshToken
{
ID
:
id2
,
Token
:
"bar_2"
,
Nonce
:
"foo_2"
,
ClientID
:
"client_id_2"
,
ConnectorID
:
"client_secret"
,
Scopes
:
[]
string
{
"openid"
,
"email"
,
"profile"
},
CreatedAt
:
time
.
Now
()
.
UTC
()
.
Round
(
time
.
Millisecond
),
LastUsed
:
time
.
Now
()
.
UTC
()
.
Round
(
time
.
Millisecond
),
Claims
:
storage
.
Claims
{
UserID
:
"2"
,
Username
:
"john"
,
Email
:
"john.doe@example.com"
,
EmailVerified
:
true
,
Groups
:
[]
string
{
"a"
,
"b"
},
},
ConnectorData
:
[]
byte
(
`{"some":"data"}`
),
}
if
err
:=
s
.
CreateRefresh
(
refresh2
);
err
!=
nil
{
t
.
Fatalf
(
"create second refresh token: %v"
,
err
)
}
getAndCompare
(
id2
,
refresh2
)
updatedAt
:=
time
.
Now
()
.
UTC
()
.
Round
(
time
.
Millisecond
)
updatedAt
:=
time
.
Now
()
.
UTC
()
.
Round
(
time
.
Millisecond
)
updater
:=
func
(
r
storage
.
RefreshToken
)
(
storage
.
RefreshToken
,
error
)
{
updater
:=
func
(
r
storage
.
RefreshToken
)
(
storage
.
RefreshToken
,
error
)
{
...
@@ -283,6 +309,9 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
...
@@ -283,6 +309,9 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
refresh
.
LastUsed
=
updatedAt
refresh
.
LastUsed
=
updatedAt
getAndCompare
(
id
,
refresh
)
getAndCompare
(
id
,
refresh
)
// Ensure that updating the first token doesn't impact the second. Issue #847.
getAndCompare
(
id2
,
refresh2
)
if
err
:=
s
.
DeleteRefresh
(
id
);
err
!=
nil
{
if
err
:=
s
.
DeleteRefresh
(
id
);
err
!=
nil
{
t
.
Fatalf
(
"failed to delete refresh request: %v"
,
err
)
t
.
Fatalf
(
"failed to delete refresh request: %v"
,
err
)
}
}
...
...
storage/sql/crud.go
View file @
5586a3c1
...
@@ -299,12 +299,14 @@ func (c *conn) UpdateRefreshToken(id string, updater func(old storage.RefreshTok
...
@@ -299,12 +299,14 @@ func (c *conn) UpdateRefreshToken(id string, updater func(old storage.RefreshTok
token = $11,
token = $11,
created_at = $12,
created_at = $12,
last_used = $13
last_used = $13
where
id = $14
`
,
`
,
r
.
ClientID
,
encoder
(
r
.
Scopes
),
r
.
Nonce
,
r
.
ClientID
,
encoder
(
r
.
Scopes
),
r
.
Nonce
,
r
.
Claims
.
UserID
,
r
.
Claims
.
Username
,
r
.
Claims
.
Email
,
r
.
Claims
.
EmailVerified
,
r
.
Claims
.
UserID
,
r
.
Claims
.
Username
,
r
.
Claims
.
Email
,
r
.
Claims
.
EmailVerified
,
encoder
(
r
.
Claims
.
Groups
),
encoder
(
r
.
Claims
.
Groups
),
r
.
ConnectorID
,
r
.
ConnectorData
,
r
.
ConnectorID
,
r
.
ConnectorData
,
r
.
Token
,
r
.
CreatedAt
,
r
.
LastUsed
,
r
.
Token
,
r
.
CreatedAt
,
r
.
LastUsed
,
id
,
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"update refresh token: %v"
,
err
)
return
fmt
.
Errorf
(
"update refresh token: %v"
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment