update conf var names
This commit is contained in:
parent
7927fe6483
commit
3f03090762
17
.env.dist
17
.env.dist
|
@ -1,11 +1,16 @@
|
|||
## Server
|
||||
web_adress=":3001"
|
||||
jwt_web_adress=":3001"
|
||||
|
||||
## Postgres
|
||||
db_user="jwtserver"
|
||||
db_pass="jwtserver"
|
||||
db_name="jwtserver"
|
||||
db_host="localhost"
|
||||
jwt_db_user="jwtserver"
|
||||
jwt_db_pass="jwtserver"
|
||||
jwt_db_name="jwtserver"
|
||||
jwt_db_host="localhost"
|
||||
|
||||
## JWT
|
||||
token_password="NotSoSecretJwtSecretPassword"
|
||||
jwt_subject="factory"
|
||||
jwt_audience="risotto"
|
||||
jwt_access_token_password="NotSoSecretJwtAccessSecretPassword"
|
||||
jwt_refresh_token_password="NotSoSecretJwtRefreshSecretPassword"
|
||||
jwt_access_expiration=30 ## in seconds
|
||||
jwt_refresh_expiration=2 ## in minutes
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
if e != nil {
|
||||
fmt.Print(e)
|
||||
}
|
||||
confWebadress = os.Getenv("web_adress")
|
||||
confWebadress = os.Getenv("jwt_web_adress")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -34,16 +34,16 @@ func init() {
|
|||
fmt.Print(e)
|
||||
}
|
||||
var err error
|
||||
accessExpires, err = strconv.Atoi(os.Getenv("access_expiration"))
|
||||
accessExpires, err = strconv.Atoi(os.Getenv("jwt_access_expiration"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
refreshExpiration, err = strconv.Atoi(os.Getenv("access_expiration"))
|
||||
refreshExpiration, err = strconv.Atoi(os.Getenv("jwt_access_expiration"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
audience = os.Getenv("audience")
|
||||
subject = os.Getenv("subject")
|
||||
audience = os.Getenv("jwt_audience")
|
||||
subject = os.Getenv("jwt_subject")
|
||||
}
|
||||
|
||||
// TokenDetails struct
|
||||
|
@ -151,7 +151,7 @@ func (account *Account) GenerateTokenPair() (*TokenDetails, error) {
|
|||
},
|
||||
}
|
||||
token := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), tk)
|
||||
tokenString, err := token.SignedString([]byte(os.Getenv("access_token_password")))
|
||||
tokenString, err := token.SignedString([]byte(os.Getenv("jwt_access_token_password")))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func (account *Account) GenerateTokenPair() (*TokenDetails, error) {
|
|||
},
|
||||
}
|
||||
refreshtoken := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), reftk)
|
||||
refreshtokenString, err := refreshtoken.SignedString([]byte(os.Getenv("refresh_token_password")))
|
||||
refreshtokenString, err := refreshtoken.SignedString([]byte(os.Getenv("jwt_refresh_token_password")))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ func init() {
|
|||
fmt.Print(e)
|
||||
}
|
||||
|
||||
username := os.Getenv("db_user")
|
||||
password := os.Getenv("db_pass")
|
||||
dbName := os.Getenv("db_name")
|
||||
dbHost := os.Getenv("db_host")
|
||||
username := os.Getenv("jwt_db_user")
|
||||
password := os.Getenv("jwt_db_pass")
|
||||
dbName := os.Getenv("jwt_db_name")
|
||||
dbHost := os.Getenv("jwt_db_host")
|
||||
|
||||
dbUri := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=disable password=%s", dbHost, username, dbName, password) //Build connection string
|
||||
fmt.Println(dbUri)
|
||||
dbURI := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=disable password=%s", dbHost, username, dbName, password) //Build connection string
|
||||
fmt.Println(dbURI)
|
||||
|
||||
conn, err := gorm.Open("postgres", dbUri)
|
||||
conn, err := gorm.Open("postgres", dbURI)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func init() {
|
|||
db.Debug().AutoMigrate(&Account{}) //Database migration
|
||||
}
|
||||
|
||||
//returns a handle to the DB object
|
||||
//GetDB returns a handle to the DB object
|
||||
func GetDB() *gorm.DB {
|
||||
return db
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue