Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
hdacloud
dex
Commits
8b079168
Commit
8b079168
authored
8 years ago
by
Eric Chiang
Browse files
Options
Downloads
Patches
Plain Diff
server: add gRPC service implementation
parent
a8262d07
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/api.go
+64
-0
64 additions, 0 deletions
server/api.go
server/api_test.go
+1
-0
1 addition, 0 deletions
server/api_test.go
server/server.go
+2
-2
2 additions, 2 deletions
server/server.go
with
67 additions
and
2 deletions
server/api.go
0 → 100644
+
64
−
0
View file @
8b079168
package
server
import
(
"errors"
"log"
"golang.org/x/net/context"
"github.com/coreos/dex/api"
"github.com/coreos/dex/storage"
)
// NewAPI returns a server which implements the gRPC API interface.
func
NewAPI
(
s
storage
.
Storage
)
api
.
DexServer
{
return
dexAPI
{
s
:
s
}
}
type
dexAPI
struct
{
s
storage
.
Storage
}
func
(
d
dexAPI
)
CreateClient
(
ctx
context
.
Context
,
req
*
api
.
CreateClientReq
)
(
*
api
.
CreateClientResp
,
error
)
{
if
req
.
Client
==
nil
{
return
nil
,
errors
.
New
(
"no client supplied"
)
}
if
req
.
Client
.
Id
==
""
{
req
.
Client
.
Id
=
storage
.
NewID
()
}
if
req
.
Client
.
Secret
==
""
{
req
.
Client
.
Secret
=
storage
.
NewID
()
+
storage
.
NewID
()
}
c
:=
storage
.
Client
{
ID
:
req
.
Client
.
Id
,
Secret
:
req
.
Client
.
Secret
,
RedirectURIs
:
req
.
Client
.
RedirectUris
,
TrustedPeers
:
req
.
Client
.
TrustedPeers
,
Public
:
req
.
Client
.
Public
,
Name
:
req
.
Client
.
Name
,
LogoURL
:
req
.
Client
.
LogoUrl
,
}
if
err
:=
d
.
s
.
CreateClient
(
c
);
err
!=
nil
{
log
.
Printf
(
"api: failed to create client: %v"
,
err
)
// TODO(ericchiang): Surface "already exists" errors.
return
nil
,
err
}
return
&
api
.
CreateClientResp
{
Client
:
req
.
Client
,
},
nil
}
func
(
d
dexAPI
)
DeleteClient
(
ctx
context
.
Context
,
req
*
api
.
DeleteClientReq
)
(
*
api
.
DeleteClientResp
,
error
)
{
err
:=
d
.
s
.
DeleteClient
(
req
.
Id
)
if
err
!=
nil
{
if
err
==
storage
.
ErrNotFound
{
return
&
api
.
DeleteClientResp
{
NotFound
:
true
},
nil
}
log
.
Printf
(
"api: failed to delete client: %v"
,
err
)
return
nil
,
err
}
return
&
api
.
DeleteClientResp
{},
nil
}
This diff is collapsed.
Click to expand it.
server/api_test.go
0 → 100644
+
1
−
0
View file @
8b079168
package
server
This diff is collapsed.
Click to expand it.
server/server.go
+
2
−
2
View file @
8b079168
...
...
@@ -78,8 +78,8 @@ type Server struct {
idTokensValidFor
time
.
Duration
}
// New constructs a server from the provided config.
func
New
(
c
Config
)
(
*
Server
,
error
)
{
// New
Server
constructs a server from the provided config.
func
New
Server
(
c
Config
)
(
*
Server
,
error
)
{
return
newServer
(
c
,
defaultRotationStrategy
(
value
(
c
.
RotateKeysAfter
,
6
*
time
.
Hour
),
value
(
c
.
IDTokensValidFor
,
24
*
time
.
Hour
),
...
...
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