2023-08-04 13:34:18 +02:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"strconv"
|
2025-01-04 13:43:18 +01:00
|
|
|
"strings"
|
2023-08-04 13:34:18 +02:00
|
|
|
"time"
|
2025-01-04 13:43:18 +01:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
"github.com/go-pkgz/routegroup"
|
2025-02-28 08:29:40 +01:00
|
|
|
|
2025-01-04 13:43:18 +01:00
|
|
|
"github.com/h44z/wg-portal/internal/app"
|
2025-03-09 21:16:42 +01:00
|
|
|
"github.com/h44z/wg-portal/internal/app/api/core/request"
|
|
|
|
"github.com/h44z/wg-portal/internal/app/api/core/respond"
|
2025-01-04 13:43:18 +01:00
|
|
|
"github.com/h44z/wg-portal/internal/app/api/v0/model"
|
|
|
|
"github.com/h44z/wg-portal/internal/domain"
|
2023-08-04 13:34:18 +02:00
|
|
|
)
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
type Session interface {
|
|
|
|
// SetData sets the session data for the given context.
|
|
|
|
SetData(ctx context.Context, val SessionData)
|
|
|
|
// GetData returns the session data for the given context. If no data is found, the default session data is returned.
|
|
|
|
GetData(ctx context.Context) SessionData
|
|
|
|
// DestroyData destroys the session data for the given context.
|
|
|
|
DestroyData(ctx context.Context)
|
|
|
|
}
|
|
|
|
|
|
|
|
type Validator interface {
|
|
|
|
Struct(s interface{}) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthEndpoint struct {
|
2023-08-04 13:34:18 +02:00
|
|
|
app *app.App
|
2025-03-09 21:16:42 +01:00
|
|
|
authenticator Authenticator
|
|
|
|
session Session
|
|
|
|
validate Validator
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
func NewAuthEndpoint(app *app.App, authenticator Authenticator, session Session, validator Validator) AuthEndpoint {
|
|
|
|
return AuthEndpoint{
|
|
|
|
app: app,
|
|
|
|
authenticator: authenticator,
|
|
|
|
session: session,
|
|
|
|
validate: validator,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e AuthEndpoint) GetName() string {
|
2023-08-04 13:34:18 +02:00
|
|
|
return "AuthEndpoint"
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) RegisterRoutes(g *routegroup.Bundle) {
|
|
|
|
apiGroup := g.Mount("/auth")
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
apiGroup.HandleFunc("GET /providers", e.handleExternalLoginProvidersGet())
|
|
|
|
apiGroup.HandleFunc("GET /session", e.handleSessionInfoGet())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
apiGroup.HandleFunc("GET /login/{provider}/init", e.handleOauthInitiateGet())
|
|
|
|
apiGroup.HandleFunc("GET /login/{provider}/callback", e.handleOauthCallbackGet())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
apiGroup.HandleFunc("POST /login", e.handleLoginPost())
|
|
|
|
apiGroup.With(e.authenticator.LoggedIn()).HandleFunc("POST /logout", e.handleLogoutPost())
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleExternalLoginProvidersGet returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleExternalLoginProvidersGet
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Get all available external login providers.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.LoginProviderInfo
|
|
|
|
// @Router /auth/providers [get]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleExternalLoginProvidersGet() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
providers := e.app.Authenticator.GetExternalLoginProviders(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, model.NewLoginProviderInfos(providers))
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleSessionInfoGet returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleSessionInfoGet
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Get information about the currently logged-in user.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.SessionInfo
|
|
|
|
// @Failure 500 {object} model.Error
|
|
|
|
// @Router /auth/session [get]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleSessionInfoGet() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
var loggedInUid *string
|
|
|
|
var firstname *string
|
|
|
|
var lastname *string
|
|
|
|
var email *string
|
|
|
|
|
|
|
|
if currentSession.LoggedIn {
|
2024-01-31 21:14:36 +01:00
|
|
|
uid := currentSession.UserIdentifier
|
2023-08-04 13:34:18 +02:00
|
|
|
f := currentSession.Firstname
|
|
|
|
l := currentSession.Lastname
|
|
|
|
e := currentSession.Email
|
|
|
|
loggedInUid = &uid
|
|
|
|
firstname = &f
|
|
|
|
lastname = &l
|
|
|
|
email = &e
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, model.SessionInfo{
|
2023-08-04 13:34:18 +02:00
|
|
|
LoggedIn: currentSession.LoggedIn,
|
|
|
|
IsAdmin: currentSession.IsAdmin,
|
|
|
|
UserIdentifier: loggedInUid,
|
|
|
|
UserFirstname: firstname,
|
|
|
|
UserLastname: lastname,
|
|
|
|
UserEmail: email,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleOauthInitiateGet returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleOauthInitiateGet
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Initiate the OAuth login flow.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.LoginProviderInfo
|
|
|
|
// @Router /auth/{provider}/init [get]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleOauthInitiateGet() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
autoRedirect, _ := strconv.ParseBool(request.QueryDefault(r, "redirect", "false"))
|
|
|
|
returnTo := request.Query(r, "return")
|
|
|
|
provider := request.Path(r, "provider")
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
var returnUrl *url.URL
|
|
|
|
var returnParams string
|
|
|
|
redirectToReturn := func() {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.Redirect(w, r, http.StatusFound, returnUrl.String()+"?"+returnParams)
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if returnTo != "" {
|
2025-01-04 13:43:18 +01:00
|
|
|
if !e.isValidReturnUrl(returnTo) {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusBadRequest,
|
|
|
|
model.Error{Code: http.StatusBadRequest, Message: "invalid return URL"})
|
2025-01-04 13:43:18 +01:00
|
|
|
return
|
|
|
|
}
|
2023-08-04 13:34:18 +02:00
|
|
|
if u, err := url.Parse(returnTo); err == nil {
|
|
|
|
returnUrl = u
|
|
|
|
}
|
|
|
|
queryParams := returnUrl.Query()
|
|
|
|
queryParams.Set("wgLoginState", "err") // by default, we set the state to error
|
|
|
|
returnUrl.RawQuery = "" // remove potential query params
|
|
|
|
returnParams = queryParams.Encode()
|
|
|
|
}
|
|
|
|
|
|
|
|
if currentSession.LoggedIn {
|
2025-01-05 10:06:34 +01:00
|
|
|
if autoRedirect && e.isValidReturnUrl(returnTo) {
|
2023-08-04 13:34:18 +02:00
|
|
|
queryParams := returnUrl.Query()
|
|
|
|
queryParams.Set("wgLoginState", "success")
|
|
|
|
returnParams = queryParams.Encode()
|
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusBadRequest,
|
|
|
|
model.Error{Code: http.StatusBadRequest, Message: "already logged in"})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
authCodeUrl, state, nonce, err := e.app.Authenticator.OauthLoginStep1(context.Background(), provider)
|
2023-08-04 13:34:18 +02:00
|
|
|
if err != nil {
|
2025-01-04 13:43:18 +01:00
|
|
|
if autoRedirect && e.isValidReturnUrl(returnTo) {
|
2023-08-04 13:34:18 +02:00
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusInternalServerError,
|
2025-01-04 13:43:18 +01:00
|
|
|
model.Error{Code: http.StatusInternalServerError, Message: err.Error()})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
authSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
authSession.OauthState = state
|
|
|
|
authSession.OauthNonce = nonce
|
|
|
|
authSession.OauthProvider = provider
|
|
|
|
authSession.OauthReturnTo = returnTo
|
2025-03-09 21:16:42 +01:00
|
|
|
e.session.SetData(r.Context(), authSession)
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
if autoRedirect {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.Redirect(w, r, http.StatusFound, authCodeUrl)
|
2023-08-04 13:34:18 +02:00
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, model.OauthInitiationResponse{
|
2023-08-04 13:34:18 +02:00
|
|
|
RedirectUrl: authCodeUrl,
|
|
|
|
State: state,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleOauthCallbackGet returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleOauthCallbackGet
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Handle the OAuth callback.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.LoginProviderInfo
|
|
|
|
// @Router /auth/{provider}/callback [get]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleOauthCallbackGet() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
var returnUrl *url.URL
|
|
|
|
var returnParams string
|
|
|
|
redirectToReturn := func() {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.Redirect(w, r, http.StatusFound, returnUrl.String()+"?"+returnParams)
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if currentSession.OauthReturnTo != "" {
|
|
|
|
if u, err := url.Parse(currentSession.OauthReturnTo); err == nil {
|
|
|
|
returnUrl = u
|
|
|
|
}
|
|
|
|
queryParams := returnUrl.Query()
|
|
|
|
queryParams.Set("wgLoginState", "err") // by default, we set the state to error
|
|
|
|
returnUrl.RawQuery = "" // remove potential query params
|
|
|
|
returnParams = queryParams.Encode()
|
|
|
|
}
|
|
|
|
|
|
|
|
if currentSession.LoggedIn {
|
2025-01-04 13:43:18 +01:00
|
|
|
if returnUrl != nil && e.isValidReturnUrl(returnUrl.String()) {
|
2023-08-04 13:34:18 +02:00
|
|
|
queryParams := returnUrl.Query()
|
|
|
|
queryParams.Set("wgLoginState", "success")
|
|
|
|
returnParams = queryParams.Encode()
|
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusBadRequest, model.Error{Message: "already logged in"})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
provider := request.Path(r, "provider")
|
|
|
|
oauthCode := request.Query(r, "code")
|
|
|
|
oauthState := request.Query(r, "state")
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
if provider != currentSession.OauthProvider {
|
2025-01-04 13:43:18 +01:00
|
|
|
if returnUrl != nil && e.isValidReturnUrl(returnUrl.String()) {
|
2023-08-04 13:34:18 +02:00
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusBadRequest,
|
2025-01-04 13:43:18 +01:00
|
|
|
model.Error{Code: http.StatusBadRequest, Message: "invalid oauth provider"})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if oauthState != currentSession.OauthState {
|
2025-01-04 13:43:18 +01:00
|
|
|
if returnUrl != nil && e.isValidReturnUrl(returnUrl.String()) {
|
2023-08-04 13:34:18 +02:00
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusBadRequest,
|
|
|
|
model.Error{Code: http.StatusBadRequest, Message: "invalid oauth state"})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
loginCtx, cancel := context.WithTimeout(context.Background(), 1000*time.Second)
|
|
|
|
user, err := e.app.Authenticator.OauthLoginStep2(loginCtx, provider, currentSession.OauthNonce, oauthCode)
|
|
|
|
cancel()
|
|
|
|
if err != nil {
|
2025-01-05 10:06:34 +01:00
|
|
|
if returnUrl != nil && e.isValidReturnUrl(returnUrl.String()) {
|
2023-08-04 13:34:18 +02:00
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusUnauthorized,
|
|
|
|
model.Error{Code: http.StatusUnauthorized, Message: err.Error()})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
e.setAuthenticatedUser(r, user)
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-01-05 10:06:34 +01:00
|
|
|
if returnUrl != nil && e.isValidReturnUrl(returnUrl.String()) {
|
2023-08-04 13:34:18 +02:00
|
|
|
queryParams := returnUrl.Query()
|
|
|
|
queryParams.Set("wgLoginState", "success")
|
|
|
|
returnParams = queryParams.Encode()
|
|
|
|
redirectToReturn()
|
|
|
|
} else {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, user)
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) setAuthenticatedUser(r *http.Request, user *domain.User) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
currentSession.LoggedIn = true
|
|
|
|
currentSession.IsAdmin = user.IsAdmin
|
|
|
|
currentSession.UserIdentifier = string(user.Identifier)
|
|
|
|
currentSession.Firstname = user.Firstname
|
|
|
|
currentSession.Lastname = user.Lastname
|
|
|
|
currentSession.Email = user.Email
|
|
|
|
|
|
|
|
currentSession.OauthState = ""
|
|
|
|
currentSession.OauthNonce = ""
|
|
|
|
currentSession.OauthProvider = ""
|
|
|
|
currentSession.OauthReturnTo = ""
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
e.session.SetData(r.Context(), currentSession)
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleLoginPost returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleLoginPost
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Get all available external login providers.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.LoginProviderInfo
|
|
|
|
// @Router /auth/login [post]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleLoginPost() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
if currentSession.LoggedIn {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, model.Error{Code: http.StatusOK, Message: "already logged in"})
|
2023-08-04 13:34:18 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var loginData struct {
|
|
|
|
Username string `json:"username" binding:"required,min=2"`
|
|
|
|
Password string `json:"password" binding:"required,min=4"`
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
if err := request.BodyJson(r, &loginData); err != nil {
|
|
|
|
respond.JSON(w, http.StatusBadRequest, model.Error{Code: http.StatusBadRequest, Message: err.Error()})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := e.validate.Struct(loginData); err != nil {
|
|
|
|
respond.JSON(w, http.StatusBadRequest, model.Error{Code: http.StatusBadRequest, Message: err.Error()})
|
2023-08-04 13:34:18 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
user, err := e.app.Authenticator.PlainLogin(context.Background(), loginData.Username, loginData.Password)
|
2023-08-04 13:34:18 +02:00
|
|
|
if err != nil {
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusUnauthorized,
|
|
|
|
model.Error{Code: http.StatusUnauthorized, Message: "login failed"})
|
2023-08-04 13:34:18 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
e.setAuthenticatedUser(r, user)
|
2023-08-04 13:34:18 +02:00
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, user)
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
// handleLogoutPost returns a gorm Handler function.
|
2023-08-04 13:34:18 +02:00
|
|
|
//
|
|
|
|
// @ID auth_handleLogoutGet
|
|
|
|
// @Tags Authentication
|
|
|
|
// @Summary Get all available external login providers.
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} []model.LoginProviderInfo
|
|
|
|
// @Router /auth/logout [get]
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) handleLogoutPost() http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
currentSession := e.session.GetData(r.Context())
|
2023-08-04 13:34:18 +02:00
|
|
|
|
|
|
|
if !currentSession.LoggedIn { // Not logged in
|
2025-03-09 21:16:42 +01:00
|
|
|
respond.JSON(w, http.StatusOK, model.Error{Code: http.StatusOK, Message: "not logged in"})
|
2023-08-04 13:34:18 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-03-09 21:16:42 +01:00
|
|
|
e.session.DestroyData(r.Context())
|
|
|
|
respond.JSON(w, http.StatusOK, model.Error{Code: http.StatusOK, Message: "logout ok"})
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
2025-01-04 13:43:18 +01:00
|
|
|
|
|
|
|
// isValidReturnUrl checks if the given return URL matches the configured external URL of the application.
|
2025-03-09 21:16:42 +01:00
|
|
|
func (e AuthEndpoint) isValidReturnUrl(returnUrl string) bool {
|
2025-01-04 13:43:18 +01:00
|
|
|
if !strings.HasPrefix(returnUrl, e.app.Config.Web.ExternalUrl) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|