comments
This commit is contained in:
parent
b546640b5c
commit
fde944128c
1 changed files with 15 additions and 0 deletions
|
@ -69,6 +69,17 @@ func main() {
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//you could also just take the access_token and id_token without calling the userinfo endpoint:
|
||||||
|
//
|
||||||
|
//marshalToken := func(w http.ResponseWriter, r *http.Request, tokens *oidc.Tokens, state string, rp rp.RelyingParty) {
|
||||||
|
// data, err := json.Marshal(tokens)
|
||||||
|
// if err != nil {
|
||||||
|
// http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// w.Write(data)
|
||||||
|
//}
|
||||||
|
|
||||||
//register the CodeExchangeHandler at the callbackPath
|
//register the CodeExchangeHandler at the callbackPath
|
||||||
//the CodeExchangeHandler handles the auth response, creates the token request and calls the callback function
|
//the CodeExchangeHandler handles the auth response, creates the token request and calls the callback function
|
||||||
//with the returned tokens from the token endpoint
|
//with the returned tokens from the token endpoint
|
||||||
|
@ -76,6 +87,10 @@ func main() {
|
||||||
//will call the Userinfo endpoint, check the sub and pass the info into the callback function
|
//will call the Userinfo endpoint, check the sub and pass the info into the callback function
|
||||||
http.Handle(callbackPath, rp.CodeExchangeHandler(rp.UserinfoCallback(marshalUserinfo), provider))
|
http.Handle(callbackPath, rp.CodeExchangeHandler(rp.UserinfoCallback(marshalUserinfo), provider))
|
||||||
|
|
||||||
|
//if you would use the callback without calling the userinfo endpoint, simply switch the callback handler for:
|
||||||
|
//
|
||||||
|
//http.Handle(callbackPath, rp.CodeExchangeHandler(marshalToken, provider))
|
||||||
|
|
||||||
lis := fmt.Sprintf("127.0.0.1:%s", port)
|
lis := fmt.Sprintf("127.0.0.1:%s", port)
|
||||||
logrus.Infof("listening on http://%s/", lis)
|
logrus.Infof("listening on http://%s/", lis)
|
||||||
logrus.Fatal(http.ListenAndServe("127.0.0.1:"+port, nil))
|
logrus.Fatal(http.ListenAndServe("127.0.0.1:"+port, nil))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue