我正在尝试使用crewjam库将 saml 与开源应用程序集成在一起。
使用 samltest.id 进行身份验证测试后,我想被重定向到主页。
我尝试了几种方法,但效果不佳,我使用的是 gorilla/mux 路由器:
func login(w http.ResponseWriter, r *http.Request) {
s := samlsp.SessionFromContext(r.Context())
if s == nil {
return
}
sa, ok := s.(samlsp.SessionWithAttributes)
if !ok {
return
}
fmt.Fprintf(w, "Token contents, %+v!", sa.GetAttributes())
w.Header().Add("Location", "http://localhost:8080/")
w.WriteHeader(http.StatusFound)
}
我也测试过:
http.Redirect(w, r, "http://localhost:8080/", http.StatusFound)
有人能帮助我吗?
呼唤远方
莫回无
相关分类