chore(linting): apply gofumpt & goimports to all .go files (#225)
This commit is contained in:
parent
c4b7ef9160
commit
b5da6ec29b
45 changed files with 539 additions and 479 deletions
|
@ -48,18 +48,18 @@ func main() {
|
|||
logrus.Fatalf("error creating provider %s", err.Error())
|
||||
}
|
||||
|
||||
//generate some state (representing the state of the user in your application,
|
||||
//e.g. the page where he was before sending him to login
|
||||
// generate some state (representing the state of the user in your application,
|
||||
// e.g. the page where he was before sending him to login
|
||||
state := func() string {
|
||||
return uuid.New().String()
|
||||
}
|
||||
|
||||
//register the AuthURLHandler at your preferred path
|
||||
//the AuthURLHandler creates the auth request and redirects the user to the auth server
|
||||
//including state handling with secure cookie and the possibility to use PKCE
|
||||
// register the AuthURLHandler at your preferred path
|
||||
// the AuthURLHandler creates the auth request and redirects the user to the auth server
|
||||
// including state handling with secure cookie and the possibility to use PKCE
|
||||
http.Handle("/login", rp.AuthURLHandler(state, provider))
|
||||
|
||||
//for demonstration purposes the returned userinfo response is written as JSON object onto response
|
||||
// for demonstration purposes the returned userinfo response is written as JSON object onto response
|
||||
marshalUserinfo := func(w http.ResponseWriter, r *http.Request, tokens *oidc.Tokens, state string, rp rp.RelyingParty, info oidc.UserInfo) {
|
||||
data, err := json.Marshal(info)
|
||||
if err != nil {
|
||||
|
@ -69,9 +69,9 @@ func main() {
|
|||
w.Write(data)
|
||||
}
|
||||
|
||||
//you could also just take the access_token and id_token without calling the userinfo endpoint:
|
||||
// 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) {
|
||||
// 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)
|
||||
|
@ -80,16 +80,16 @@ func main() {
|
|||
// w.Write(data)
|
||||
//}
|
||||
|
||||
//register the CodeExchangeHandler at the callbackPath
|
||||
//the CodeExchangeHandler handles the auth response, creates the token request and calls the callback function
|
||||
//with the returned tokens from the token endpoint
|
||||
//in this example the callback function itself is wrapped by the UserinfoCallback which
|
||||
//will call the Userinfo endpoint, check the sub and pass the info into the callback function
|
||||
// register the CodeExchangeHandler at the callbackPath
|
||||
// the CodeExchangeHandler handles the auth response, creates the token request and calls the callback function
|
||||
// with the returned tokens from the token endpoint
|
||||
// in this example the callback function itself is wrapped by the UserinfoCallback which
|
||||
// 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))
|
||||
|
||||
//if you would use the callback without calling the userinfo endpoint, simply switch the callback handler for:
|
||||
// if you would use the callback without calling the userinfo endpoint, simply switch the callback handler for:
|
||||
//
|
||||
//http.Handle(callbackPath, rp.CodeExchangeHandler(marshalToken, provider))
|
||||
// http.Handle(callbackPath, rp.CodeExchangeHandler(marshalToken, provider))
|
||||
|
||||
lis := fmt.Sprintf("127.0.0.1:%s", port)
|
||||
logrus.Infof("listening on http://%s/", lis)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue