goweb-oidc/internal/route/logout.go

28 lines
571 B
Go
Raw Normal View History

2020-05-20 10:43:12 +02:00
package route
import (
"net/http"
oidc "forge.cadoles.com/wpetit/goweb-oidc"
"github.com/pkg/errors"
"gitlab.com/wpetit/goweb/middleware/container"
"gitlab.com/wpetit/goweb/service/session"
)
func handleLogout(w http.ResponseWriter, r *http.Request) {
ctn := container.Must(r.Context())
sess, err := session.Must(ctn).Get(w, r)
if err != nil {
panic(errors.Wrap(err, "could not retrieve session"))
}
if err := sess.Delete(w, r); err != nil {
panic(errors.Wrap(err, "could not delete session"))
}
client := oidc.Must(ctn)
2020-05-20 13:06:04 +02:00
client.Logout(w, r, "")
2020-05-20 10:43:12 +02:00
}