Skip to content

Commit

Permalink
🚚 rename env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alban Rahier committed Nov 10, 2022
1 parent 215e31a commit 40bdbf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions controller/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import (
"github.com/haran/biophonie-api/controller/user"
)

// location of the files used for signing and verification
var (
privKeyPath = os.Getenv("KEYS_FOLDER") + "/app.rsa" // openssl genrsa -out app.rsa keysize
pubKeyPath = os.Getenv("KEYS_FOLDER") + "/app.rsa.pub" // openssl rsa -in app.rsa -pubout > app.rsa.pub
const (
privKey = "app.rsa"
pubKey = "app.rsa.pub"
)

func (c *Controller) Authorize(ctx *gin.Context) {
Expand Down Expand Up @@ -53,6 +52,9 @@ func (c *Controller) AuthorizeAdmin(ctx *gin.Context) {

// read the key files before starting http handlers
func (c *Controller) readKeys() {
privKeyPath := os.Getenv("SECRETS_FOLDER") + string(os.PathSeparator) + privKey // openssl genrsa -out app.rsa keysize
pubKeyPath := os.Getenv("SECRETS_FOLDER") + string(os.PathSeparator) + pubKey // openssl rsa -in app.rsa -pubout > app.rsa.pub

signBytes, err := os.ReadFile(privKeyPath)
fatal(err)

Expand Down
4 changes: 2 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/jmoiron/sqlx"
)

const geoJsonFileName = "/geojson.json"
const geoJsonFileName = "geojson.json"

type Controller struct {
Db *sqlx.DB
Expand All @@ -33,7 +33,7 @@ func NewController() *Controller {
if c.publicPath == "" {
log.Fatalf("public path is empty")
}
c.geoJsonPath = c.publicPath + geoJsonFileName
c.geoJsonPath = c.publicPath + string(os.PathSeparator) + geoJsonFileName
c.refreshGeoJson()

return c
Expand Down

0 comments on commit 40bdbf4

Please sign in to comment.