revert(oidc): api breaking changes

This commit is contained in:
yusing 2025-04-25 11:10:21 +08:00
parent e107f8d476
commit af8d2c74f6
4 changed files with 9 additions and 8 deletions

View file

@ -96,12 +96,8 @@ func NewHandler(cfg config.ConfigInstance) http.Handler {
}
mux.HandleFunc("GET", "/v1/auth/check", auth.AuthCheckHandler)
mux.HandleFunc("GET", "/v1/auth/login", defaultAuth.LoginHandler)
mux.HandleFunc("GET", "/v1/auth/callback", defaultAuth.LoginHandler)
mux.HandleFunc("GET", "/v1/auth/redirect", defaultAuth.LoginHandler)
mux.HandleFunc("GET", "/v1/auth/callback", defaultAuth.PostAuthCallbackHandler)
mux.HandleFunc("GET,POST", "/v1/auth/logout", defaultAuth.LogoutHandler)
switch authProvider := defaultAuth.(type) {
case *auth.OIDCProvider:
mux.HandleFunc("GET", "/v1/auth/postauth", authProvider.PostAuthCallbackHandler)
}
return mux
}

View file

@ -44,8 +44,8 @@ const (
)
const (
OIDCAuthInitPath = "/auth/init"
OIDCPostAuthPath = "/auth/postauth"
OIDCAuthInitPath = "/"
OIDCPostAuthPath = "/auth/callback"
OIDCLogoutPath = "/auth/logout"
)

View file

@ -5,5 +5,6 @@ import "net/http"
type Provider interface {
CheckToken(r *http.Request) error
LoginHandler(w http.ResponseWriter, r *http.Request)
PostAuthCallbackHandler(w http.ResponseWriter, r *http.Request)
LogoutHandler(w http.ResponseWriter, r *http.Request)
}

View file

@ -123,6 +123,10 @@ func (auth *UserPassAuth) LoginHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
func (auth *UserPassAuth) PostAuthCallbackHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/", http.StatusFound)
}
func (auth *UserPassAuth) LogoutHandler(w http.ResponseWriter, r *http.Request) {
clearTokenCookie(w, r, auth.TokenCookieName())
http.Redirect(w, r, "/", http.StatusFound)