fix audit table definition
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-09 21:54:10 +11:00
parent 1b1ac50a61
commit 07ae9cf2ac
2 changed files with 11 additions and 21 deletions

View File

@@ -15,6 +15,8 @@ import (
"github.com/jmoiron/sqlx"
)
const nonceSize = 12
// We use the json:"-" field tag to prevent showing these details to the user
type Secret struct {
SecretId int `db:"SecretId"`
@@ -34,8 +36,6 @@ type UserSecret struct {
Permission
}
const nonceSize = 12
func (s *Secret) SaveSecret() (*Secret, error) {
var err error
@@ -56,20 +56,9 @@ func (s *Secret) SaveSecret() (*Secret, error) {
}
func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
// Query based on group
// SELECT users.UserId, users.GroupId, permissions.ReadOnly, permissions.SafeId, safes.SafeName, secrets.* FROM users INNER JOIN groups ON users.GroupId = groups.GroupId INNER JOIN permissions ON groups.GroupId = permissions.GroupId INNER JOIN safes on permissions.SafeId = safes.SafeId INNER JOIN secrets on secrets.SafeId = safes.SafeId WHERE users.UserId = 2
var err error
var secretResults []UserSecret
/*
// Make sure at least one parameter was specified
if s.DeviceName == "" && s.DeviceCategory == "" && s.UserName == "" {
err = errors.New("no search parameters specified")
log.Println(err)
return secretResults, err
}
*/
// Query for group access
queryArgs := []interface{}{}
query := `

View File

@@ -32,7 +32,7 @@ const createRoles string = `
const createUsers string = `
CREATE TABLE IF NOT EXISTS users (
UserId INTEGER PRIMARY KEY ASC,
UserId INTEGER PRIMARY KEY AUTOINCREMENT,
GroupId INTEGER,
UserName VARCHAR,
Password VARCHAR,
@@ -44,14 +44,14 @@ const createUsers string = `
const createSafes string = `
CREATE TABLE IF NOT EXISTS safes (
SafeId INTEGER PRIMARY KEY ASC,
SafeId INTEGER PRIMARY KEY AUTOINCREMENT,
SafeName VARCHAR
);
`
const createGroups string = `
CREATE TABLE IF NOT EXISTS groups (
GroupId INTEGER PRIMARY KEY ASC,
GroupId INTEGER PRIMARY KEY AUTOINCREMENT,
GroupName VARCHAR,
LdapGroup BOOLEAN DEFAULT 0,
LdapDN VARCHAR DEFAULT '',
@@ -61,7 +61,7 @@ const createGroups string = `
const createPermissions = `
CREATE TABLE IF NOT EXISTS permissions (
PermissionId INTEGER PRIMARY KEY ASC,
PermissionId INTEGER PRIMARY KEY AUTOINCREMENT,
Description VARCHAR DEFAULT '',
ReadOnly BOOLEAN DEFAULT 0,
SafeId INTEGER,
@@ -73,7 +73,7 @@ const createPermissions = `
const createSecrets string = `
CREATE TABLE IF NOT EXISTS secrets (
SecretId INTEGER PRIMARY KEY ASC,
SecretId INTEGER PRIMARY KEY AUTOINCREMENT,
SafeId INTEGER,
DeviceName VARCHAR,
DeviceCategory VARCHAR,
@@ -91,6 +91,7 @@ const createSchema string = `
const createAudit string = `
CREATE TABLE IF NOT EXISTS audit (
EventId INTEGER PRIMARY KEY AUTOINCREMENT,
UserName VARCHAR,
EventText VARCHAR,
EventTime INTEGER
@@ -272,7 +273,7 @@ func CreateTables() {
ALTER TABLE users RENAME TO _users_old;
CREATE TABLE users
(
UserId INTEGER PRIMARY KEY ASC,
UserId INTEGER PRIMARY KEY AUTOINCREMENT,
GroupId INTEGER,
UserName VARCHAR,
Password VARCHAR,
@@ -310,7 +311,7 @@ func CreateTables() {
ALTER TABLE secrets RENAME TO _secrets_old;
CREATE TABLE secrets
(
SecretId INTEGER PRIMARY KEY ASC,
SecretId INTEGER PRIMARY KEY AUTOINCREMENT,
RoleId INTEGER,
SafeId INTEGER,
DeviceName VARCHAR,
@@ -361,7 +362,7 @@ func CreateTables() {
ALTER TABLE permissions RENAME TO _permissions_old;
CREATE TABLE permissions
(
PermissionId INTEGER PRIMARY KEY ASC,
PermissionId INTEGER PRIMARY KEY AUTOINCREMENT,
Description VARCHAR DEFAULT '',
ReadOnly BOOLEAN DEFAULT 0,
SafeId INTEGER,