mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 20:23:32 +08:00
improve (middleware): content for description fields
This commit is contained in:
@ -103,6 +103,10 @@
|
|||||||
background: rgba(0,0,0,0.05); border-bottom: 0;
|
background: rgba(0,0,0,0.05); border-bottom: 0;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
|
&[readonly]{
|
||||||
|
background: var(--dark);
|
||||||
|
color: var(--light);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -214,7 +214,16 @@ export class BackendPage extends React.Component {
|
|||||||
<span className="nothing"></span>
|
<span className="nothing"></span>
|
||||||
<div style={{ width: "100%" }}>
|
<div style={{ width: "100%" }}>
|
||||||
{
|
{
|
||||||
struct.description ? (<div className="description">{struct.description}</div>) : null
|
struct.description ? (
|
||||||
|
<div className="description" dangerouslySetInnerHTML={{
|
||||||
|
__html: function() {
|
||||||
|
const regLink = /\[([^\]]*)\]\(([^\)]+)\)/g;
|
||||||
|
return struct.description
|
||||||
|
.replace(regLink, "<a target=\"_blank\" href=\"$2\">$1</a>")
|
||||||
|
.replaceAll("\n", "<br>");
|
||||||
|
}()
|
||||||
|
}}></div>
|
||||||
|
) : null
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -22,10 +22,13 @@ func (this Admin) Setup() Form {
|
|||||||
Value: "admin",
|
Value: "admin",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "hint",
|
Name: "password",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "You will be ask for your Filestash admin password",
|
Value: Config.Get("auth.admin").String(),
|
||||||
|
Description: `This plugin will redirect the user to a page asking for a password. Only the admin password will be considered valid.
|
||||||
|
This plugin exposes {{ .user }} (which is 'admin') and {{ .password }} for the attribute mapping section
|
||||||
|
`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -42,15 +45,18 @@ func (this Admin) EntryPoint(idpParams map[string]string, req *http.Request, res
|
|||||||
MaxAge: -1,
|
MaxAge: -1,
|
||||||
Path: "/",
|
Path: "/",
|
||||||
})
|
})
|
||||||
return fmt.Sprintf("<strong>%s</strong>", c.Value)
|
return fmt.Sprintf(`<p class="flash">%s</p>`, c.Value)
|
||||||
}
|
}
|
||||||
res.Header().Set("Content-Type", "text/html; charset=utf-8")
|
res.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
res.WriteHeader(http.StatusOK)
|
res.WriteHeader(http.StatusOK)
|
||||||
res.Write([]byte(Page(`
|
res.Write([]byte(Page(`
|
||||||
<form action="/api/session/auth/" method="post">
|
<form action="/api/session/auth/" method="post">
|
||||||
<label> ` + getFlash() + `
|
<label>
|
||||||
<input type="password" name="password" value="" placeholder="Admin Password" />
|
<input type="password" name="password" value="" placeholder="Admin Password" />
|
||||||
</label>
|
</label>
|
||||||
|
<button>CONNECT</button>
|
||||||
|
` + getFlash() + `
|
||||||
|
<style>.flash{ color: #f26d6d; font-weight: bold; }</style>
|
||||||
</form>`)))
|
</form>`)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -69,6 +75,7 @@ func (this Admin) Callback(formData map[string]string, idpParams map[string]stri
|
|||||||
return nil, ErrAuthenticationFailed
|
return nil, ErrAuthenticationFailed
|
||||||
}
|
}
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"username": "admin",
|
"user": "admin",
|
||||||
|
"password": formData["password"],
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,10 @@ func (this Htpasswd) Setup() Form {
|
|||||||
{
|
{
|
||||||
Name: "users",
|
Name: "users",
|
||||||
Type: "long_text",
|
Type: "long_text",
|
||||||
Placeholder: "eg:\nbob123:$apr1$FaPCZHMe$jYiw5.9UevKx25pBH4AsT/\nnancy456:$apr1$mrCHcVhc$oNdJeRcWKPk2z8dlzQI0x/",
|
Placeholder: "test:$apr1$nEDlyMK/$4jL0BUAuEifz2VajdjVnE.\ntest:{SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M=",
|
||||||
Default: "",
|
Default: "",
|
||||||
Description: "The list of users that will be granted access using the htpasswd file format. This plugin exposes the following variables which you can use from the attribute mapping: {{ .user }}, {{ .password }}",
|
Description: `The list of users who are granted access using the htpasswd file format.
|
||||||
|
This plugin exposes {{ .user }} and {{ .password }} for the attribute mapping section`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -64,12 +65,11 @@ func (this Htpasswd) EntryPoint(idpParams map[string]string, req *http.Request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this Htpasswd) Callback(formData map[string]string, idpParams map[string]string, res http.ResponseWriter) (map[string]string, error) {
|
func (this Htpasswd) Callback(formData map[string]string, idpParams map[string]string, res http.ResponseWriter) (map[string]string, error) {
|
||||||
lines := strings.Split(idpParams["users"], "\n")
|
if idpParams["users"] == "" {
|
||||||
if len(lines) == 0 {
|
|
||||||
Log.Error("plg_authenticate_htpasswd::callback there is no user configured")
|
Log.Error("plg_authenticate_htpasswd::callback there is no user configured")
|
||||||
return nil, ErrAuthenticationFailed
|
return nil, NewError("You haven't configured any users", 500)
|
||||||
}
|
}
|
||||||
|
lines := strings.Split(idpParams["users"], "\n")
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
pair := strings.SplitN(line, ":", 2)
|
pair := strings.SplitN(line, ":", 2)
|
||||||
if len(pair) != 2 {
|
if len(pair) != 2 {
|
||||||
|
|||||||
@ -20,39 +20,39 @@ func (this Ldap) Setup() Form {
|
|||||||
Value: "ldap",
|
Value: "ldap",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Hostname",
|
Name: "Hostname",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Value: "",
|
ReadOnly: true,
|
||||||
ReadOnly: true,
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Port",
|
Name: "Port",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Value: "",
|
ReadOnly: true,
|
||||||
ReadOnly: true,
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Bind DN",
|
Name: "Bind DN",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Value: "",
|
ReadOnly: true,
|
||||||
ReadOnly: true,
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Bind DN Password",
|
Name: "Bind DN Password",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Value: "",
|
ReadOnly: true,
|
||||||
ReadOnly: true,
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Base DN",
|
Name: "Base DN",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Value: "",
|
ReadOnly: true,
|
||||||
ReadOnly: true,
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
Description: `This plugin is to integrate with your LDAP server. After successfully authenticating to your IDP, the attributes relating to the user will be available in the attribute mapping section either by:
|
||||||
|
1. copying those attributes in any field: {{ .sAMAccountName }} {{ .cn }} {{ .userPrincipalName }} {{ .mail }}, ...
|
||||||
|
2. create custom rules based on some attributes like this: {{ if contains .memberOf "cn=admins" }}adminuser{{ else }}regularuser{{ end }} or {{ if eq .userPrincipalName "root" }}adminuser{{ else }}regularuser{{ end }}
|
||||||
|
|
||||||
|
[Purchase the enterprise edition](https://www.filestash.app/purchase-enterprise-selfhosted.html)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,25 +20,25 @@ func (this OpenID) Setup() Form {
|
|||||||
Value: "openid",
|
Value: "openid",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "OpenID Config URL",
|
Name: "OpenID Config URL",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "",
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Client ID",
|
Name: "Client ID",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "",
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Scope",
|
Name: "Scope",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "",
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
Description: `This plugin is to integrate with your IDP using SSO via OpenID. After having authenticated to your IDP, all the information related to the user will be available in the attribute mapping section like this: {{ .email }} {{ .name }} {{ .sub }}, ...
|
||||||
|
|
||||||
|
[Purchase the enterprise edition](https://www.filestash.app/purchase-enterprise-selfhosted.html)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,12 +21,15 @@ func (this Admin) Setup() Form {
|
|||||||
Value: "passthrough",
|
Value: "passthrough",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "strategy",
|
Name: "strategy",
|
||||||
Type: "select",
|
Type: "select",
|
||||||
Default: "direct",
|
Default: "direct",
|
||||||
Opts: []string{"direct", "password_only", "username_and_password"},
|
Opts: []string{"direct", "password_only", "username_and_password"},
|
||||||
Id: "strategy",
|
Id: "strategy",
|
||||||
Description: "This plugin has 3 base strategy for authentication. The 'username_and_password' strategy will redirect the user to a page asking for a username and password whose value can be used in the attribute mapping section of the selected storage. The 'password_only' strategy will do the same but instead of asking for both a username and password will only ask for a password and the remaining 'direct' strategy will be a transparent redirect where the user won't be ask for any information\n\nThis plugin will enable 2 variable which can be used in the attribute mapping section, namely {{ .user }} and {{ .password }}",
|
Description: `This plugin has 3 base strategies:
|
||||||
|
1. The 'direct' strategy will redirect the user to your storage without asking for anything and use whatever is configured in the attribute mapping section.
|
||||||
|
2. The 'password_only' strategy will redirect the user to a page asking for a password which you can map to a field in the attribute mapping section like this: {{ .password }}
|
||||||
|
3. The 'username_and_password' strategy is similar to the 'password_only' strategy but you will see in the login page both a username and password field which can be used fom the attribute mapping section like this: {{ .user }} {{ .password }}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,18 +20,21 @@ func (this Saml) Setup() Form {
|
|||||||
Value: "saml",
|
Value: "saml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "SP Metadata",
|
Name: "SP Metadata",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "",
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "IDP Metadata",
|
Name: "IDP Metadata",
|
||||||
Type: "text",
|
Type: "text",
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
Value: "",
|
Value: "plugin available in the enterprise release",
|
||||||
Placeholder: "<VISIT https://www.filestash.app/pricing>",
|
Description: `This plugin is to integrate with your IDP using SAML Single Sign-On. After having authenticated to your IDP, all the information about the user sent by your IDP will be available in the attribute mapping section either by:
|
||||||
|
1. copying those attributes in any field: {{ .mail }}, {{ .uid }}, {{ .givenName }}
|
||||||
|
2. create custom rules based on some attributes like this: {{ if eq .role "admin" }}adminuser{{ else }}regularuser{{ end }}
|
||||||
|
|
||||||
|
[Purchase the enterprise edition](https://www.filestash.app/purchase-enterprise-selfhosted.html)`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user