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
9926a0dc
Commit
9926a0dc
authored
Aug 08, 2018
by
Cosmin Cojocar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend the API with a function which updates the client configuration
parent
57b10313
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
api.pb.go
api/api.pb.go
+0
-0
api.proto
api/api.proto
+17
-0
api.go
server/api.go
+32
-0
No files found.
api/api.pb.go
View file @
9926a0dc
This diff is collapsed.
Click to expand it.
api/api.proto
View file @
9926a0dc
...
...
@@ -36,6 +36,21 @@ message DeleteClientResp {
bool
not_found
=
1
;
}
// UpdateClientReq is a request to update an exisitng client.
message
UpdateClientReq
{
string
id
=
1
;
repeated
string
redirect_uris
=
2
;
repeated
string
trusted_peers
=
3
;
bool
public
=
4
;
string
name
=
5
;
string
logo_url
=
6
;
}
// UpdateClientResp returns the reponse form updating a client.
message
UpdateClientResp
{
bool
not_found
=
1
;
}
// TODO(ericchiang): expand this.
// Password is an email for password mapping managed by the storage.
...
...
@@ -138,6 +153,8 @@ message RevokeRefreshResp {
service
Dex
{
// CreateClient creates a client.
rpc
CreateClient
(
CreateClientReq
)
returns
(
CreateClientResp
)
{};
// UpdateClient updates an exisitng client
rpc
UpdateClient
(
UpdateClientReq
)
returns
(
UpdateClientResp
)
{};
// DeleteClient deletes the provided client.
rpc
DeleteClient
(
DeleteClientReq
)
returns
(
DeleteClientResp
)
{};
// CreatePassword creates a password.
...
...
server/api.go
View file @
9926a0dc
...
...
@@ -80,6 +80,38 @@ func (d dexAPI) CreateClient(ctx context.Context, req *api.CreateClientReq) (*ap
},
nil
}
func
(
d
dexAPI
)
UpdateClient
(
ctx
context
.
Context
,
req
*
api
.
UpdateClientReq
)
(
*
api
.
UpdateClientResp
,
error
)
{
if
req
.
Id
==
""
{
return
nil
,
errors
.
New
(
"update client: no client ID supplied"
)
}
err
:=
d
.
s
.
UpdateClient
(
req
.
Id
,
func
(
old
storage
.
Client
)
(
storage
.
Client
,
error
)
{
if
req
.
RedirectUris
!=
nil
&&
len
(
req
.
RedirectUris
)
>
0
{
old
.
RedirectURIs
=
req
.
RedirectUris
}
if
req
.
TrustedPeers
!=
nil
&&
len
(
req
.
TrustedPeers
)
>
0
{
old
.
TrustedPeers
=
req
.
TrustedPeers
}
old
.
Public
=
req
.
Public
if
req
.
Name
!=
""
{
old
.
Name
=
req
.
Name
}
if
req
.
LogoUrl
!=
""
{
old
.
LogoURL
=
req
.
LogoUrl
}
return
old
,
nil
})
if
err
!=
nil
{
if
err
==
storage
.
ErrNotFound
{
return
&
api
.
UpdateClientResp
{
NotFound
:
true
},
nil
}
d
.
logger
.
Errorf
(
"api: failed to update the client: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"update client: %v"
,
err
)
}
return
&
api
.
UpdateClientResp
{},
nil
}
func
(
d
dexAPI
)
DeleteClient
(
ctx
context
.
Context
,
req
*
api
.
DeleteClientReq
)
(
*
api
.
DeleteClientResp
,
error
)
{
err
:=
d
.
s
.
DeleteClient
(
req
.
Id
)
if
err
!=
nil
{
...
...
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