33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package routes
|
|
|
|
import (
|
|
"authentication/handlers"
|
|
"authentication/middleware"
|
|
"database/sql"
|
|
|
|
"github.com/gorilla/mux"
|
|
httpSwagger "github.com/swaggo/http-swagger"
|
|
)
|
|
|
|
func SetupRoutes(router *mux.Router, db *sql.DB) {
|
|
|
|
router.HandleFunc("/health", handlers.HealthHandler).Methods("GET")
|
|
router.HandleFunc("/ready", handlers.ReadyHandler).Methods("GET")
|
|
|
|
authRoutes := router.PathPrefix("/v1/auth").Subrouter()
|
|
authRoutes.HandleFunc("/login", handlers.GoogleLogin).Methods("GET")
|
|
authRoutes.HandleFunc("/forgot-password", handlers.ForgotPassword).Methods("GET")
|
|
authRoutes.HandleFunc("/callback", handlers.GoogleCallback).Methods("GET")
|
|
|
|
csrfProtected := authRoutes.NewRoute().Subrouter()
|
|
csrfProtected.Use(middleware.CSRFMiddleware)
|
|
csrfProtected.HandleFunc("/csrf", handlers.CSRFToken).Methods("GET")
|
|
csrfProtected.HandleFunc("/refresh_token", handlers.HandleTokenRefresh).Methods("POST", "OPTIONS")
|
|
csrfProtected.HandleFunc("/logout", handlers.LogoutHandler).Methods("POST")
|
|
|
|
// authRoutes.HandleFunc("/microsoft/login", handlers.MicrosoftLogin).Methods("GET")
|
|
// authRoutes.HandleFunc("/microsoft/callback", handlers.MicrosotCallback).Methods("GET")
|
|
|
|
router.PathPrefix("/swagger/").Handler(httpSwagger.WrapHandler)
|
|
}
|