Require auth middleware only on GET requests
This commit is contained in:
parent
26eebf47d5
commit
d6814b516a
@ -6,13 +6,16 @@ import (
|
|||||||
|
|
||||||
ia "github.com/owncast/owncast/auth/indieauth"
|
ia "github.com/owncast/owncast/auth/indieauth"
|
||||||
"github.com/owncast/owncast/controllers"
|
"github.com/owncast/owncast/controllers"
|
||||||
|
"github.com/owncast/owncast/router/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleAuthEndpoint will handle the IndieAuth auth endpoint.
|
// HandleAuthEndpoint will handle the IndieAuth auth endpoint.
|
||||||
func HandleAuthEndpoint(w http.ResponseWriter, r *http.Request) {
|
func HandleAuthEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodGet {
|
if r.Method == http.MethodGet {
|
||||||
// Require the GET request for IndieAuth to be behind admin login.
|
// Require the GET request for IndieAuth to be behind admin login.
|
||||||
handleAuthEndpointGet(w, r)
|
f := middleware.RequireAdminAuth(handleAuthEndpointGet)
|
||||||
|
f(w, r)
|
||||||
|
return
|
||||||
} else if r.Method == http.MethodPost {
|
} else if r.Method == http.MethodPost {
|
||||||
handleAuthEndpointPost(w, r)
|
handleAuthEndpointPost(w, r)
|
||||||
} else {
|
} else {
|
||||||
|
@ -356,7 +356,7 @@ func Start() error {
|
|||||||
// Start auth flow
|
// Start auth flow
|
||||||
http.HandleFunc("/api/auth/indieauth", middleware.RequireUserAccessToken(indieauth.StartAuthFlow))
|
http.HandleFunc("/api/auth/indieauth", middleware.RequireUserAccessToken(indieauth.StartAuthFlow))
|
||||||
http.HandleFunc("/api/auth/indieauth/callback", indieauth.HandleRedirect)
|
http.HandleFunc("/api/auth/indieauth/callback", indieauth.HandleRedirect)
|
||||||
http.HandleFunc("/api/auth/provider/indieauth", middleware.RequireAdminAuth(indieauth.HandleAuthEndpoint))
|
http.HandleFunc("/api/auth/provider/indieauth", indieauth.HandleAuthEndpoint)
|
||||||
|
|
||||||
http.HandleFunc("/api/auth/fediverse", middleware.RequireUserAccessToken(fediverseauth.RegisterFediverseOTPRequest))
|
http.HandleFunc("/api/auth/fediverse", middleware.RequireUserAccessToken(fediverseauth.RegisterFediverseOTPRequest))
|
||||||
http.HandleFunc("/api/auth/fediverse/verify", fediverseauth.VerifyFediverseOTPRequest)
|
http.HandleFunc("/api/auth/fediverse/verify", fediverseauth.VerifyFediverseOTPRequest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user