Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/secret #91

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.schema
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SSH_KEY_NAME=
DIGITAL_OCEAN_TOKEN=
SESSION_SECRET=
DOCKER_USERNAME=
POSTGRES_USERNAME=
POSTGRES_PASSWORD=
Expand Down
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Vagrant.configure("2") do |config|
server.vm.provision "shell", inline: 'echo "export GRAFANA_PASSWORD=' + "'" + ENV["GRAFANA_PASSWORD"] + "'" + '" >> ~/.bash_profile'
server.vm.provision "shell", inline: 'echo "export ELASTIC_USERNAME=' + "'" + ENV["ELASTIC_USERNAME"] + "'" + '" >> ~/.bash_profile'
server.vm.provision "shell", inline: 'echo "export ELASTIC_PASSWORD=' + "'" + ENV["ELASTIC_PASSWORD"] + "'" + '" >> ~/.bash_profile'
server.vm.provision "shell", inline: 'echo "export SESSION_SECRET=' + "'" + ENV["SESSION_SECRET"] + "'" + '" >> ~/.bash_profile'
server.vm.provision "shell", inline: <<-SHELL
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
cd /vagrant
Expand Down
3 changes: 1 addition & 2 deletions globals/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"gorm.io/gorm"
)

var Secret = []byte("secret")
var Secret = []byte(os.Getenv("SESSION_SECRET"))

const ENV_KEY = "GO_ENV"

Expand Down Expand Up @@ -55,7 +55,6 @@ func GetDatabasePath() gorm.Dialector {
connectionString := fmt.Sprintf("postgresql://%s:%s@postgres/db",
os.Getenv("POSTGRES_USERNAME"),
os.Getenv("POSTGRES_PASSWORD"))
fmt.Println(connectionString)
return postgres.Open(connectionString)
}
return sqlite.Open("itu-minitwit.db")
Expand Down
1 change: 1 addition & 0 deletions routes/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func SetupRouter() *gin.Engine {
"gravatarUrl": helpers.GravatarUrl,
})
router.LoadHTMLGlob(filepath.Join(globals.Root, "templates/*.html"))

router.Use(sessions.Sessions("session", cookie.NewStore(globals.Secret)))
router.Use(middleware.MeasueRequestTimeMiddleware)

Expand Down