OpenID authentification (#170)

* openid authentification

* openid middleware

* openId login

* tidied login page

* removed useless email text field
This commit is contained in:
Marco Piovanello
2024-07-23 19:04:05 +02:00
committed by GitHub
parent 38a0cedc9c
commit 92aabc0086
11 changed files with 259 additions and 8 deletions

View File

@@ -0,0 +1,20 @@
package openid
import "net/http"
func Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
token, err := r.Cookie("oid-token")
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if _, err := verifier.Verify(r.Context(), token.Value); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
next.ServeHTTP(w, r)
})
}