This commit is contained in:
@@ -29,7 +29,7 @@ type Secret struct {
|
||||
type UserSecret struct {
|
||||
User
|
||||
Secret
|
||||
Group
|
||||
//Group
|
||||
Permission
|
||||
}
|
||||
|
||||
@@ -101,8 +101,9 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
|
||||
|
||||
// Query for group access
|
||||
queryArgs := []interface{}{}
|
||||
query := `SELECT users.*, permissions.ReadOnly,
|
||||
secrets.SecretId, secrets.SafeId, secrets.DeviceName, secrets.DeviceCategory, secrets.UserName, secrets.Secret
|
||||
query := `
|
||||
SELECT users.UserId, permissions.ReadOnly,
|
||||
secrets.SecretId, secrets.SafeId, secrets.DeviceName, secrets.DeviceCategory, secrets.UserName
|
||||
FROM users
|
||||
INNER JOIN groups ON users.GroupId = groups.GroupId
|
||||
INNER JOIN permissions ON groups.GroupId = permissions.GroupId
|
||||
@@ -125,11 +126,12 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
|
||||
query += " AND secrets.UserName LIKE ? "
|
||||
queryArgs = append(queryArgs, s.UserName)
|
||||
}
|
||||
/*
|
||||
|
||||
// Query for user access
|
||||
query += `
|
||||
UNION
|
||||
SELECT users.UserId, users.GroupId, permissions.ReadOnly, safes.SafeName, secrets.*
|
||||
SELECT users.UserId, permissions.ReadOnly,
|
||||
secrets.SecretId, secrets.SafeId, secrets.DeviceName, secrets.DeviceCategory, secrets.UserName
|
||||
FROM users
|
||||
INNER JOIN permissions ON users.UserId = permissions.UserId
|
||||
INNER JOIN safes on permissions.SafeId = safes.SafeId
|
||||
@@ -152,7 +154,6 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
|
||||
query += " AND secrets.UserName LIKE ? "
|
||||
queryArgs = append(queryArgs, s.UserName)
|
||||
}
|
||||
*/
|
||||
|
||||
// Execute the query
|
||||
log.Printf("SecretsGetAllowedForGroup query string : '%s'\nArguments:%+v\n", query, queryArgs)
|
||||
@@ -174,18 +175,6 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
|
||||
debugPrint := printStructContents(&r, 0)
|
||||
log.Println(debugPrint)
|
||||
|
||||
/*
|
||||
// Decrypt the secret
|
||||
_, err = r.DecryptSecret()
|
||||
if err != nil {
|
||||
//log.Printf("GetSecret unable to decrypt stored secret '%v' : '%s'\n", r.Secret, err)
|
||||
log.Printf("SecretsGetAllowedForGroup unable to decrypt stored secret : '%s'\n", err)
|
||||
return secretResults, err
|
||||
} else {
|
||||
secretResults = append(secretResults, r)
|
||||
}
|
||||
*/
|
||||
|
||||
// Don't decrypt the secrets in the results of this query
|
||||
secretResults = append(secretResults, r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user