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
ed89be44
Commit
ed89be44
authored
Apr 08, 2016
by
Stephan Renatus
Committed by
Eric Chiang
Apr 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: make getCreds work for non-admins (#396)
parent
70cb0546
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
user.go
server/user.go
+3
-3
No files found.
server/user.go
View file @
ed89be44
...
@@ -88,7 +88,7 @@ type authedHandle func(w http.ResponseWriter, r *http.Request, ps httprouter.Par
...
@@ -88,7 +88,7 @@ type authedHandle func(w http.ResponseWriter, r *http.Request, ps httprouter.Par
// that of an admin user.
// that of an admin user.
func
(
s
*
UserMgmtServer
)
authAPIHandle
(
handle
authedHandle
,
requiresAdmin
bool
)
httprouter
.
Handle
{
func
(
s
*
UserMgmtServer
)
authAPIHandle
(
handle
authedHandle
,
requiresAdmin
bool
)
httprouter
.
Handle
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
ps
httprouter
.
Params
)
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
ps
httprouter
.
Params
)
{
creds
,
err
:=
s
.
getCreds
(
r
)
creds
,
err
:=
s
.
getCreds
(
r
,
requiresAdmin
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
writeError
(
w
,
err
)
s
.
writeError
(
w
,
err
)
return
return
...
@@ -243,7 +243,7 @@ func (s *UserMgmtServer) writeError(w http.ResponseWriter, err error) {
...
@@ -243,7 +243,7 @@ func (s *UserMgmtServer) writeError(w http.ResponseWriter, err error) {
writeAPIError
(
w
,
http
.
StatusInternalServerError
,
newAPIError
(
errorServerError
,
err
.
Error
()))
writeAPIError
(
w
,
http
.
StatusInternalServerError
,
newAPIError
(
errorServerError
,
err
.
Error
()))
}
}
func
(
s
*
UserMgmtServer
)
getCreds
(
r
*
http
.
Request
)
(
api
.
Creds
,
error
)
{
func
(
s
*
UserMgmtServer
)
getCreds
(
r
*
http
.
Request
,
requiresAdmin
bool
)
(
api
.
Creds
,
error
)
{
token
,
err
:=
oidc
.
ExtractBearerToken
(
r
)
token
,
err
:=
oidc
.
ExtractBearerToken
(
r
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"userMgmtServer: GetCreds err: %q"
,
err
)
log
.
Errorf
(
"userMgmtServer: GetCreds err: %q"
,
err
)
...
@@ -300,7 +300,7 @@ func (s *UserMgmtServer) getCreds(r *http.Request) (api.Creds, error) {
...
@@ -300,7 +300,7 @@ func (s *UserMgmtServer) getCreds(r *http.Request) (api.Creds, error) {
log
.
Errorf
(
"userMgmtServer: GetCreds err: %q"
,
err
)
log
.
Errorf
(
"userMgmtServer: GetCreds err: %q"
,
err
)
return
api
.
Creds
{},
err
return
api
.
Creds
{},
err
}
}
if
!
isAdmin
{
if
requiresAdmin
&&
!
isAdmin
{
return
api
.
Creds
{},
api
.
ErrorForbidden
return
api
.
Creds
{},
api
.
ErrorForbidden
}
}
...
...
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