diff --git a/Dockerfile b/Dockerfile index 57e6065..7d42f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,14 @@ ENV PROTOCOL=https ENV FQDN=yourdomain.com ENV PORT=7080 +# jwt_token_key returns the jwt token secret +ENV JWT_TOKEN_KEY=INSERT_YOUR_KEY +# jwt_token_expiration returns the jwt token expiration duration. +# Should be time.ParseDuration string. +# Source: https://golang.org/pkg/time/#ParseDuration +# default: 10h +ENV JWT_TOKEN_EXP=10h + ENV POSTGRES_HOST=127.0.0.1 ENV POSTGRES_PORT=5432 ENV POSTGRES_DATABASE=greatape diff --git a/components/core/system_component.go b/components/core/system_component.go index ca78201..c291eeb 100644 --- a/components/core/system_component.go +++ b/components/core/system_component.go @@ -96,11 +96,14 @@ func (component *systemComponent) GenerateHash(value string, salt string) string } func (component *systemComponent) GenerateJwtToken() string { - return jwt.Generate() + return jwt.Generate( + component.configuration.GetServerConfiguration().GetJwtTokenKey(), + component.configuration.GetServerConfiguration().GetJwtTokenExpiration(), + ) } func (component *systemComponent) VerifyJwtToken(token string) error { - _, err := jwt.Verify(token) + _, err := jwt.Verify(token, component.configuration.GetServerConfiguration().GetJwtTokenKey()) return err } diff --git a/config.yaml b/config.yaml index 8f9f5cb..02fecc7 100644 --- a/config.yaml +++ b/config.yaml @@ -6,6 +6,13 @@ server: protocol: https ports: passive: 7080 + # jwt_token_key returns the jwt token secret + jwt_token_key: INSERT_YOUR_KEY + # jwt_token_expiration returns the jwt token expiration duration. + # Should be time.ParseDuration string. + # Source: https://golang.org/pkg/time/#ParseDuration + # default: 10h + jwt_token_expiration: 10h postgres: host: 127.0.0.1 diff --git a/config.yaml.sample b/config.yaml.sample index 8f9f5cb..02fecc7 100644 --- a/config.yaml.sample +++ b/config.yaml.sample @@ -6,6 +6,13 @@ server: protocol: https ports: passive: 7080 + # jwt_token_key returns the jwt token secret + jwt_token_key: INSERT_YOUR_KEY + # jwt_token_expiration returns the jwt token expiration duration. + # Should be time.ParseDuration string. + # Source: https://golang.org/pkg/time/#ParseDuration + # default: 10h + jwt_token_expiration: 10h postgres: host: 127.0.0.1 diff --git a/docker-compose.yaml b/docker-compose.yaml index 89faedb..0950921 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -32,6 +32,13 @@ services: PROTOCOL: https FQDN: yourdomain.com PORT: 7080 + # jwt_token_key returns the jwt token secret + JWT_TOKEN_KEY: INSERT_YOUR_KEY + # jwt_token_expiration returns the jwt token expiration duration. + # Should be time.ParseDuration string. + # Source: https://golang.org/pkg/time/#ParseDuration + # default: 10h + JWT_TOKEN_EXP: 10h POSTGRES_HOST: db POSTGRES_PORT: 5432 POSTGRES_USER: postgres diff --git a/go.mod b/go.mod index c66a2ce..ef04ac0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/robfig/cron v1.2.0 github.com/sendgrid/sendgrid-go v3.12.0+incompatible github.com/valyala/fastjson v1.6.4 - github.com/xeronith/diamante v1.8.4 + github.com/xeronith/diamante v1.8.7 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index dfc4ae0..e84cf45 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLr github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/xeronith/diamante v1.8.4 h1:os5FbDmgNYGSQdxMre0O38LsTsZ0hsFrkQybJthONdc= -github.com/xeronith/diamante v1.8.4/go.mod h1:JxUM5P0q1doheczjjJHZt+mupCklFMwLSO/EgeTSmXg= +github.com/xeronith/diamante v1.8.7 h1:UOBdZwA+DzwPqx23LwNVJTSwAjRd6oT73uIMDOdugkE= +github.com/xeronith/diamante v1.8.7/go.mod h1:JxUM5P0q1doheczjjJHZt+mupCklFMwLSO/EgeTSmXg= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=