test loading secret key
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-12-27 17:29:02 +11:00
parent ca316e7086
commit 9203e09d2d
5 changed files with 39 additions and 3 deletions

View File

@@ -23,6 +23,8 @@ import (
var sha1ver string // sha1 revision used to build the program
var buildTime string // when the executable was built
var keyString string
func main() {
// Load data from environment file
@@ -47,9 +49,15 @@ func main() {
log.SetOutput(logfileWriter)
log.Printf("SMT starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
// Set secrets key from .env file
keyString = os.Getenv("SECRETS_KEY")
// Initiate connection to sqlite and make sure our schema is up to date
models.ConnectDatabase()
// let the models package know our secrets key
models.LoadSecretKey(keyString)
// Create context that listens for the interrupt signal from the OS.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
@@ -136,6 +144,7 @@ func main() {
// Register our routes
public := router.Group("/api")
public.POST("/login", controllers.Login)
public.POST("/unlock", controllers.Unlock)
// API calls that only an administrator can make
adminOnly := router.Group("/api/admin")