kopia lustrzana https://github.com/reiver/greatape
feat(project): ✨ add jwt configuration
rodzic
d31ecc9a1b
commit
98f1188e2f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
go.mod
2
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
|
||||
)
|
||||
|
||||
|
|
4
go.sum
4
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=
|
||||
|
|
Ładowanie…
Reference in New Issue