mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
feature (session): enable plugin to handle auth response
This commit is contained in:
parent
a605988d5c
commit
3bf3c71d8c
2 changed files with 9 additions and 6 deletions
|
|
@ -314,7 +314,7 @@ func SessionAuthMiddleware(ctx *App, res http.ResponseWriter, req *http.Request)
|
|||
http.StatusSeeOther,
|
||||
)
|
||||
return
|
||||
} else if err != nil {
|
||||
} else if err != nil && strings.HasPrefix(res.Header().Get("Content-Type"), "text/html") == false {
|
||||
Log.Error("session::authMiddleware 'callback error - %s'", err.Error())
|
||||
http.Redirect(
|
||||
res, req,
|
||||
|
|
@ -322,7 +322,10 @@ func SessionAuthMiddleware(ctx *App, res http.ResponseWriter, req *http.Request)
|
|||
http.StatusSeeOther,
|
||||
)
|
||||
return
|
||||
} else if err != nil { // response handled directly within a plugin
|
||||
return
|
||||
}
|
||||
|
||||
templateBind["machine_id"] = GenerateMachineID()
|
||||
for _, value := range os.Environ() {
|
||||
pair := strings.SplitN(value, "=", 2)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
Hooks.Register.AuthenticationMiddleware("passthrough", Admin{})
|
||||
Hooks.Register.AuthenticationMiddleware("passthrough", Passthrough{})
|
||||
}
|
||||
|
||||
type Admin struct{}
|
||||
type Passthrough struct{}
|
||||
|
||||
func (this Admin) Setup() Form {
|
||||
func (this Passthrough) Setup() Form {
|
||||
return Form{
|
||||
Elmnts: []FormElement{
|
||||
{
|
||||
|
|
@ -36,7 +36,7 @@ func (this Admin) Setup() Form {
|
|||
}
|
||||
}
|
||||
|
||||
func (this Admin) EntryPoint(idpParams map[string]string, req *http.Request, res http.ResponseWriter) error {
|
||||
func (this Passthrough) EntryPoint(idpParams map[string]string, req *http.Request, res http.ResponseWriter) error {
|
||||
res.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
getParams := "?label=" + html.EscapeString(req.URL.Query().Get("label")) + "&state=" + html.EscapeString(req.URL.Query().Get("state"))
|
||||
switch idpParams["strategy"] {
|
||||
|
|
@ -76,7 +76,7 @@ func (this Admin) EntryPoint(idpParams map[string]string, req *http.Request, res
|
|||
return nil
|
||||
}
|
||||
|
||||
func (this Admin) Callback(formData map[string]string, idpParams map[string]string, res http.ResponseWriter) (map[string]string, error) {
|
||||
func (this Passthrough) Callback(formData map[string]string, idpParams map[string]string, res http.ResponseWriter) (map[string]string, error) {
|
||||
return map[string]string{
|
||||
"user": formData["user"],
|
||||
"password": formData["password"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue