fix audit table definition
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
|||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const nonceSize = 12
|
||||||
|
|
||||||
// We use the json:"-" field tag to prevent showing these details to the user
|
// We use the json:"-" field tag to prevent showing these details to the user
|
||||||
type Secret struct {
|
type Secret struct {
|
||||||
SecretId int `db:"SecretId"`
|
SecretId int `db:"SecretId"`
|
||||||
@@ -34,8 +36,6 @@ type UserSecret struct {
|
|||||||
Permission
|
Permission
|
||||||
}
|
}
|
||||||
|
|
||||||
const nonceSize = 12
|
|
||||||
|
|
||||||
func (s *Secret) SaveSecret() (*Secret, error) {
|
func (s *Secret) SaveSecret() (*Secret, error) {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -56,20 +56,9 @@ func (s *Secret) SaveSecret() (*Secret, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, 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 err error
|
||||||
var secretResults []UserSecret
|
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
|
// Query for group access
|
||||||
queryArgs := []interface{}{}
|
queryArgs := []interface{}{}
|
||||||
query := `
|
query := `
|
||||||
|
@@ -32,7 +32,7 @@ const createRoles string = `
|
|||||||
|
|
||||||
const createUsers string = `
|
const createUsers string = `
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
UserId INTEGER PRIMARY KEY ASC,
|
UserId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
GroupId INTEGER,
|
GroupId INTEGER,
|
||||||
UserName VARCHAR,
|
UserName VARCHAR,
|
||||||
Password VARCHAR,
|
Password VARCHAR,
|
||||||
@@ -44,14 +44,14 @@ const createUsers string = `
|
|||||||
|
|
||||||
const createSafes string = `
|
const createSafes string = `
|
||||||
CREATE TABLE IF NOT EXISTS safes (
|
CREATE TABLE IF NOT EXISTS safes (
|
||||||
SafeId INTEGER PRIMARY KEY ASC,
|
SafeId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
SafeName VARCHAR
|
SafeName VARCHAR
|
||||||
);
|
);
|
||||||
`
|
`
|
||||||
|
|
||||||
const createGroups string = `
|
const createGroups string = `
|
||||||
CREATE TABLE IF NOT EXISTS groups (
|
CREATE TABLE IF NOT EXISTS groups (
|
||||||
GroupId INTEGER PRIMARY KEY ASC,
|
GroupId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
GroupName VARCHAR,
|
GroupName VARCHAR,
|
||||||
LdapGroup BOOLEAN DEFAULT 0,
|
LdapGroup BOOLEAN DEFAULT 0,
|
||||||
LdapDN VARCHAR DEFAULT '',
|
LdapDN VARCHAR DEFAULT '',
|
||||||
@@ -61,7 +61,7 @@ const createGroups string = `
|
|||||||
|
|
||||||
const createPermissions = `
|
const createPermissions = `
|
||||||
CREATE TABLE IF NOT EXISTS permissions (
|
CREATE TABLE IF NOT EXISTS permissions (
|
||||||
PermissionId INTEGER PRIMARY KEY ASC,
|
PermissionId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Description VARCHAR DEFAULT '',
|
Description VARCHAR DEFAULT '',
|
||||||
ReadOnly BOOLEAN DEFAULT 0,
|
ReadOnly BOOLEAN DEFAULT 0,
|
||||||
SafeId INTEGER,
|
SafeId INTEGER,
|
||||||
@@ -73,7 +73,7 @@ const createPermissions = `
|
|||||||
|
|
||||||
const createSecrets string = `
|
const createSecrets string = `
|
||||||
CREATE TABLE IF NOT EXISTS secrets (
|
CREATE TABLE IF NOT EXISTS secrets (
|
||||||
SecretId INTEGER PRIMARY KEY ASC,
|
SecretId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
SafeId INTEGER,
|
SafeId INTEGER,
|
||||||
DeviceName VARCHAR,
|
DeviceName VARCHAR,
|
||||||
DeviceCategory VARCHAR,
|
DeviceCategory VARCHAR,
|
||||||
@@ -91,6 +91,7 @@ const createSchema string = `
|
|||||||
|
|
||||||
const createAudit string = `
|
const createAudit string = `
|
||||||
CREATE TABLE IF NOT EXISTS audit (
|
CREATE TABLE IF NOT EXISTS audit (
|
||||||
|
EventId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
UserName VARCHAR,
|
UserName VARCHAR,
|
||||||
EventText VARCHAR,
|
EventText VARCHAR,
|
||||||
EventTime INTEGER
|
EventTime INTEGER
|
||||||
@@ -272,7 +273,7 @@ func CreateTables() {
|
|||||||
ALTER TABLE users RENAME TO _users_old;
|
ALTER TABLE users RENAME TO _users_old;
|
||||||
CREATE TABLE users
|
CREATE TABLE users
|
||||||
(
|
(
|
||||||
UserId INTEGER PRIMARY KEY ASC,
|
UserId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
GroupId INTEGER,
|
GroupId INTEGER,
|
||||||
UserName VARCHAR,
|
UserName VARCHAR,
|
||||||
Password VARCHAR,
|
Password VARCHAR,
|
||||||
@@ -310,7 +311,7 @@ func CreateTables() {
|
|||||||
ALTER TABLE secrets RENAME TO _secrets_old;
|
ALTER TABLE secrets RENAME TO _secrets_old;
|
||||||
CREATE TABLE secrets
|
CREATE TABLE secrets
|
||||||
(
|
(
|
||||||
SecretId INTEGER PRIMARY KEY ASC,
|
SecretId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
RoleId INTEGER,
|
RoleId INTEGER,
|
||||||
SafeId INTEGER,
|
SafeId INTEGER,
|
||||||
DeviceName VARCHAR,
|
DeviceName VARCHAR,
|
||||||
@@ -361,7 +362,7 @@ func CreateTables() {
|
|||||||
ALTER TABLE permissions RENAME TO _permissions_old;
|
ALTER TABLE permissions RENAME TO _permissions_old;
|
||||||
CREATE TABLE permissions
|
CREATE TABLE permissions
|
||||||
(
|
(
|
||||||
PermissionId INTEGER PRIMARY KEY ASC,
|
PermissionId INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Description VARCHAR DEFAULT '',
|
Description VARCHAR DEFAULT '',
|
||||||
ReadOnly BOOLEAN DEFAULT 0,
|
ReadOnly BOOLEAN DEFAULT 0,
|
||||||
SafeId INTEGER,
|
SafeId INTEGER,
|
||||||
|
Reference in New Issue
Block a user