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
ee9738d6
Commit
ee9738d6
authored
Nov 17, 2016
by
rithu john
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api: adding a gRPC call for listing passwords.
parent
19c22807
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
api.pb.go
api/api.pb.go
+0
-0
api.proto
api/api.proto
+10
-0
api.go
server/api.go
+23
-0
conformance.go
storage/conformance/conformance.go
+9
-0
No files found.
api/api.pb.go
View file @
ee9738d6
This diff is collapsed.
Click to expand it.
api/api.proto
View file @
ee9738d6
...
@@ -80,6 +80,14 @@ message DeletePasswordResp {
...
@@ -80,6 +80,14 @@ message DeletePasswordResp {
bool
not_found
=
1
;
bool
not_found
=
1
;
}
}
// ListPasswordReq is a request to enumerate passwords.
message
ListPasswordReq
{}
// ListPasswordResp returs a list of passwords.
message
ListPasswordResp
{
repeated
Password
passwords
=
1
;
}
// VersionReq is a request to fetch version info.
// VersionReq is a request to fetch version info.
message
VersionReq
{}
message
VersionReq
{}
...
@@ -104,6 +112,8 @@ service Dex {
...
@@ -104,6 +112,8 @@ service Dex {
rpc
UpdatePassword
(
UpdatePasswordReq
)
returns
(
UpdatePasswordResp
)
{};
rpc
UpdatePassword
(
UpdatePasswordReq
)
returns
(
UpdatePasswordResp
)
{};
// DeletePassword deletes the password.
// DeletePassword deletes the password.
rpc
DeletePassword
(
DeletePasswordReq
)
returns
(
DeletePasswordResp
)
{};
rpc
DeletePassword
(
DeletePasswordReq
)
returns
(
DeletePasswordResp
)
{};
// ListPassword lists all password entries.
rpc
ListPasswords
(
ListPasswordReq
)
returns
(
ListPasswordResp
)
{};
// GetVersion returns version information of the server.
// GetVersion returns version information of the server.
rpc
GetVersion
(
VersionReq
)
returns
(
VersionResp
)
{};
rpc
GetVersion
(
VersionReq
)
returns
(
VersionResp
)
{};
}
}
server/api.go
View file @
ee9738d6
...
@@ -171,3 +171,26 @@ func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.Versi
...
@@ -171,3 +171,26 @@ func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.Versi
Api
:
apiVersion
,
Api
:
apiVersion
,
},
nil
},
nil
}
}
func
(
d
dexAPI
)
ListPasswords
(
ctx
context
.
Context
,
req
*
api
.
ListPasswordReq
)
(
*
api
.
ListPasswordResp
,
error
)
{
passwordList
,
err
:=
d
.
s
.
ListPasswords
()
if
err
!=
nil
{
log
.
Printf
(
"api: failed to list passwords: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"list passwords: %v"
,
err
)
}
var
passwords
[]
*
api
.
Password
for
_
,
password
:=
range
passwordList
{
p
:=
api
.
Password
{
Email
:
password
.
Email
,
Username
:
password
.
Username
,
UserId
:
password
.
UserID
,
}
passwords
=
append
(
passwords
,
&
p
)
}
return
&
api
.
ListPasswordResp
{
Passwords
:
passwords
,
},
nil
}
storage/conformance/conformance.go
View file @
ee9738d6
...
@@ -5,6 +5,7 @@ package conformance
...
@@ -5,6 +5,7 @@ package conformance
import
(
import
(
"reflect"
"reflect"
"sort"
"testing"
"testing"
"time"
"time"
...
@@ -244,6 +245,12 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
...
@@ -244,6 +245,12 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
}
}
}
}
type
byEmail
[]
storage
.
Password
func
(
n
byEmail
)
Len
()
int
{
return
len
(
n
)
}
func
(
n
byEmail
)
Less
(
i
,
j
int
)
bool
{
return
n
[
i
]
.
Email
<
n
[
j
]
.
Email
}
func
(
n
byEmail
)
Swap
(
i
,
j
int
)
{
n
[
i
],
n
[
j
]
=
n
[
j
],
n
[
i
]
}
func
testPasswordCRUD
(
t
*
testing
.
T
,
s
storage
.
Storage
)
{
func
testPasswordCRUD
(
t
*
testing
.
T
,
s
storage
.
Storage
)
{
// Use bcrypt.MinCost to keep the tests short.
// Use bcrypt.MinCost to keep the tests short.
passwordHash
,
err
:=
bcrypt
.
GenerateFromPassword
([]
byte
(
"secret"
),
bcrypt
.
MinCost
)
passwordHash
,
err
:=
bcrypt
.
GenerateFromPassword
([]
byte
(
"secret"
),
bcrypt
.
MinCost
)
...
@@ -294,6 +301,8 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
...
@@ -294,6 +301,8 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
t
.
Errorf
(
"list password: %v"
,
err
)
t
.
Errorf
(
"list password: %v"
,
err
)
return
return
}
}
sort
.
Sort
(
byEmail
(
want
))
sort
.
Sort
(
byEmail
(
passwords
))
if
diff
:=
pretty
.
Compare
(
want
,
passwords
);
diff
!=
""
{
if
diff
:=
pretty
.
Compare
(
want
,
passwords
);
diff
!=
""
{
t
.
Errorf
(
"password list retrieved from storage did not match: %s"
,
diff
)
t
.
Errorf
(
"password list retrieved from storage did not match: %s"
,
diff
)
}
}
...
...
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