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
d7c7d424
Unverified
Commit
d7c7d424
authored
Jul 24, 2019
by
Stephan Renatus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/example-app: check all errors, pass claims as string to renderToken
Signed-off-by:
Stephan Renatus
<
srenatus@chef.io
>
parent
c4e0587d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
main.go
cmd/example-app/main.go
+10
-4
templates.go
cmd/example-app/templates.go
+2
-2
No files found.
cmd/example-app/main.go
View file @
d7c7d424
...
...
@@ -314,7 +314,7 @@ func (a *app) handleCallback(w http.ResponseWriter, r *http.Request) {
idToken
,
err
:=
a
.
verifier
.
Verify
(
r
.
Context
(),
rawIDToken
)
if
err
!=
nil
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"
F
ailed to verify ID token: %v"
,
err
),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
fmt
.
Sprintf
(
"
f
ailed to verify ID token: %v"
,
err
),
http
.
StatusInternalServerError
)
return
}
...
...
@@ -325,10 +325,16 @@ func (a *app) handleCallback(w http.ResponseWriter, r *http.Request) {
}
var
claims
json
.
RawMessage
idToken
.
Claims
(
&
claims
)
if
err
:=
idToken
.
Claims
(
&
claims
);
err
!=
nil
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"error decoding ID token claims: %v"
,
err
),
http
.
StatusInternalServerError
)
return
}
buff
:=
new
(
bytes
.
Buffer
)
json
.
Indent
(
buff
,
[]
byte
(
claims
),
""
,
" "
)
if
err
:=
json
.
Indent
(
buff
,
[]
byte
(
claims
),
""
,
" "
);
err
!=
nil
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"error indenting ID token claims: %v"
,
err
),
http
.
StatusInternalServerError
)
return
}
renderToken
(
w
,
a
.
redirectURI
,
rawIDToken
,
accessToken
,
token
.
RefreshToken
,
buff
.
Bytes
())
renderToken
(
w
,
a
.
redirectURI
,
rawIDToken
,
accessToken
,
token
.
RefreshToken
,
buff
.
String
())
}
cmd/example-app/templates.go
View file @
d7c7d424
...
...
@@ -66,13 +66,13 @@ pre {
</html>
`
))
func
renderToken
(
w
http
.
ResponseWriter
,
redirectURL
,
idToken
,
accessToken
,
refreshToken
string
,
claims
[]
byte
)
{
func
renderToken
(
w
http
.
ResponseWriter
,
redirectURL
,
idToken
,
accessToken
,
refreshToken
,
claims
string
)
{
renderTemplate
(
w
,
tokenTmpl
,
tokenTmplData
{
IDToken
:
idToken
,
AccessToken
:
accessToken
,
RefreshToken
:
refreshToken
,
RedirectURL
:
redirectURL
,
Claims
:
string
(
claims
)
,
Claims
:
claims
,
})
}
...
...
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