aboutsummaryrefslogtreecommitdiff
path: root/auth_ldap.go
diff options
context:
space:
mode:
authorQuentin <quentin@deuxfleurs.fr>2021-11-20 09:53:05 +0100
committerQuentin <quentin@deuxfleurs.fr>2021-11-20 09:53:05 +0100
commit4448577ec154e1f175be3f6668de0aa2d6bfff9e (patch)
tree840e9979d06d1f2117629821b1935d7f9d65fe2b /auth_ldap.go
parent514731cf4b5dd97dc871b9fd84c4d9938900ef79 (diff)
downloadbagage-4448577ec154e1f175be3f6668de0aa2d6bfff9e.tar.gz
bagage-4448577ec154e1f175be3f6668de0aa2d6bfff9e.zip
Path + format
Diffstat (limited to 'auth_ldap.go')
-rw-r--r--auth_ldap.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/auth_ldap.go b/auth_ldap.go
index 26d3565..f5c7ada 100644
--- a/auth_ldap.go
+++ b/auth_ldap.go
@@ -21,7 +21,7 @@ func (l LdapPreAuth) WithCreds(username, password string) http.Handler {
var e *LdapWrongPasswordError
access_key, secret_key, err := LdapGetS3(l.WithConfig, username, password)
-
+
if err == nil {
l.OnCreds.WithCreds(access_key, secret_key).ServeHTTP(w, r)
} else if errors.As(err, &e) {
@@ -44,16 +44,18 @@ type ldapConnector struct {
type LdapError struct {
Username string
- Err error
+ Err error
}
-func (e *LdapError) Error() string { return "ldap error for "+e.Username+": "+e.Err.Error() }
-type LdapWrongPasswordError struct { LdapError }
+
+func (e *LdapError) Error() string { return "ldap error for " + e.Username + ": " + e.Err.Error() }
+
+type LdapWrongPasswordError struct{ LdapError }
func LdapGetS3(c *Config, username, password string) (access_key, secret_key string, werr error) {
// 1. Connect to the server
conn, err := ldapConnect(c)
if err != nil {
- werr = &LdapError { username, err }
+ werr = &LdapError{username, err}
return
}
defer conn.Close()
@@ -62,14 +64,14 @@ func LdapGetS3(c *Config, username, password string) (access_key, secret_key str
// @FIXME we should better check the error, it could also be due to an LDAP error
err = conn.auth(username, password)
if err != nil {
- werr = &LdapWrongPasswordError { LdapError { username, err } }
+ werr = &LdapWrongPasswordError{LdapError{username, err}}
return
}
// 3. Fetch user's profile
profile, err := conn.profile()
if err != nil {
- werr = &LdapError { username, err }
+ werr = &LdapError{username, err}
return
}
@@ -78,7 +80,7 @@ func LdapGetS3(c *Config, username, password string) (access_key, secret_key str
secret_key = profile.GetAttributeValue("garage_s3_secret_key")
if access_key == "" || secret_key == "" {
err = errors.New(fmt.Sprintf("Either access key or secret key is missing in LDAP for %s", conn.userDn))
- werr = &LdapError { username, err }
+ werr = &LdapError{username, err}
return
}