improve (middleware): content for description fields

This commit is contained in:
Mickael Kerjean
2022-11-10 00:16:08 +11:00
parent 7b4e3eba79
commit c828b22f7a
8 changed files with 94 additions and 68 deletions

View File

@ -103,6 +103,10 @@
background: rgba(0,0,0,0.05); border-bottom: 0;
border-radius: 3px;
padding-left: 5px;
&[readonly]{
background: var(--dark);
color: var(--light);
}
}
}
}

View File

@ -214,7 +214,16 @@ export class BackendPage extends React.Component {
<span className="nothing"></span>
<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>

View File

@ -22,10 +22,13 @@ func (this Admin) Setup() Form {
Value: "admin",
},
{
Name: "hint",
Name: "password",
Type: "text",
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,
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.WriteHeader(http.StatusOK)
res.Write([]byte(Page(`
<form action="/api/session/auth/" method="post">
<label> ` + getFlash() + `
<label>
<input type="password" name="password" value="" placeholder="Admin Password" />
</label>
<button>CONNECT</button>
` + getFlash() + `
<style>.flash{ color: #f26d6d; font-weight: bold; }</style>
</form>`)))
return nil
}
@ -69,6 +75,7 @@ func (this Admin) Callback(formData map[string]string, idpParams map[string]stri
return nil, ErrAuthenticationFailed
}
return map[string]string{
"username": "admin",
"user": "admin",
"password": formData["password"],
}, nil
}

View File

@ -25,9 +25,10 @@ func (this Htpasswd) Setup() Form {
{
Name: "users",
Type: "long_text",
Placeholder: "eg:\nbob123:$apr1$FaPCZHMe$jYiw5.9UevKx25pBH4AsT/\nnancy456:$apr1$mrCHcVhc$oNdJeRcWKPk2z8dlzQI0x/",
Placeholder: "test:$apr1$nEDlyMK/$4jL0BUAuEifz2VajdjVnE.\ntest:{SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M=",
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) {
lines := strings.Split(idpParams["users"], "\n")
if len(lines) == 0 {
if idpParams["users"] == "" {
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 {
pair := strings.SplitN(line, ":", 2)
if len(pair) != 2 {

View File

@ -20,39 +20,39 @@ func (this Ldap) Setup() Form {
Value: "ldap",
},
{
Name: "Hostname",
Type: "text",
Value: "",
ReadOnly: true,
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Hostname",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Port",
Type: "text",
Value: "",
ReadOnly: true,
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Port",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Bind DN",
Type: "text",
Value: "",
ReadOnly: true,
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Bind DN",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Bind DN Password",
Type: "text",
Value: "",
ReadOnly: true,
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Bind DN Password",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Base DN",
Type: "text",
Value: "",
ReadOnly: true,
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Base DN",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
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:
&nbsp;&nbsp;1. copying those attributes in any field: {{ .sAMAccountName }} {{ .cn }} {{ .userPrincipalName }} {{ .mail }}, ...
&nbsp;&nbsp;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)`,
},
},
}

View File

@ -20,25 +20,25 @@ func (this OpenID) Setup() Form {
Value: "openid",
},
{
Name: "OpenID Config URL",
Type: "text",
ReadOnly: true,
Value: "",
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "OpenID Config URL",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Client ID",
Type: "text",
ReadOnly: true,
Value: "",
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Client ID",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "Scope",
Type: "text",
ReadOnly: true,
Value: "",
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "Scope",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
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)`,
},
},
}

View File

@ -21,12 +21,15 @@ func (this Admin) Setup() Form {
Value: "passthrough",
},
{
Name: "strategy",
Type: "select",
Default: "direct",
Opts: []string{"direct", "password_only", "username_and_password"},
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 }}",
Name: "strategy",
Type: "select",
Default: "direct",
Opts: []string{"direct", "password_only", "username_and_password"},
Id: "strategy",
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 }}`,
},
},
}

View File

@ -20,18 +20,21 @@ func (this Saml) Setup() Form {
Value: "saml",
},
{
Name: "SP Metadata",
Type: "text",
ReadOnly: true,
Value: "",
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "SP Metadata",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
},
{
Name: "IDP Metadata",
Type: "text",
ReadOnly: true,
Value: "",
Placeholder: "<VISIT https://www.filestash.app/pricing>",
Name: "IDP Metadata",
Type: "text",
ReadOnly: true,
Value: "plugin available in the enterprise release",
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:
&nbsp;&nbsp;1. copying those attributes in any field: {{ .mail }}, {{ .uid }}, {{ .givenName }}
&nbsp;&nbsp;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)`,
},
},
}