mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
feature (sso): support for templating in attribute mapping
This commit is contained in:
parent
82e12ca1a6
commit
625e0ed160
2 changed files with 19 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package ctrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/gorilla/mux"
|
||||
. "github.com/mickael-kerjean/filestash/server/common"
|
||||
|
|
@ -9,6 +10,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -312,7 +314,20 @@ func SessionAuthMiddleware(ctx App, res http.ResponseWriter, req *http.Request)
|
|||
}
|
||||
mappingToUse := map[string]string{}
|
||||
for k, v := range globalMapping[refCookie.Value] {
|
||||
mappingToUse[k] = NewStringFromInterface(v)
|
||||
str := NewStringFromInterface(v)
|
||||
if str == "" {
|
||||
continue
|
||||
}
|
||||
tmpl, err := template.New("ctrl::session::auth_middleware").Parse(str)
|
||||
mappingToUse[k] = str
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
var b bytes.Buffer
|
||||
if err = tmpl.Execute(&b, tb); err != nil {
|
||||
continue
|
||||
}
|
||||
mappingToUse[k] = b.String()
|
||||
}
|
||||
mappingToUse["timestamp"] = time.Now().String()
|
||||
return mappingToUse, nil
|
||||
|
|
|
|||
|
|
@ -68,5 +68,7 @@ func (this Admin) Callback(formData map[string]string, idpParams map[string]stri
|
|||
})
|
||||
return nil, ErrAuthenticationFailed
|
||||
}
|
||||
return map[string]string{}, nil
|
||||
return map[string]string{
|
||||
"username": "admin",
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue