feat(auth): add configurable token renew threshold
- Add renew-threshold JWT config option with PT5M default - Default valid-time to PT2H in TokenProperties - Expand comments in the prod config example
This commit is contained in:
2 files changed
+42
-8
No files matched your search
@@ -23,28 +23,58 @@ app:
|
|||||||
path: '/'
|
path: '/'
|
||||||
max-age: P1D
|
max-age: P1D
|
||||||
cors:
|
cors:
|
||||||
allowed-origins: # Cross-origin allowed origins
|
# Cross-origin allowed origins
|
||||||
|
allowed-origins:
|
||||||
- "http://localhost:5173" # Dev server for vite.
|
- "http://localhost:5173" # Dev server for vite.
|
||||||
- "http://localhost:4173" # Preview server for vite.
|
- "http://localhost:4173" # Preview server for vite.
|
||||||
allow-credentials: true # Must be set to `true` since we are using cookie. You can change it only when you have modified how this application executing authentication.
|
|
||||||
|
# Must be set to `true` since we are using cookie. You can change it only when you have
|
||||||
|
# modified how this application executing authentication.
|
||||||
|
allow-credentials: true
|
||||||
|
|
||||||
|
# Whether allow private network addresses.
|
||||||
allow-private-network: false
|
allow-private-network: false
|
||||||
|
|
||||||
|
# Allowed headers.
|
||||||
allowed-headers:
|
allowed-headers:
|
||||||
- "Content-Type"
|
- "Content-Type"
|
||||||
- "Authorization"
|
- "Authorization"
|
||||||
|
|
||||||
|
# Allowed methods.
|
||||||
|
#
|
||||||
|
# Since the usage of HttpMethod from Spring Framework, all methods should be UPPER CASE.
|
||||||
|
# e.g., GET, POST, PUT, PATCH, DELETE, OPTIONS
|
||||||
allowed-methods:
|
allowed-methods:
|
||||||
- GET
|
- GET
|
||||||
- POST
|
- POST
|
||||||
- PUT
|
- PUT
|
||||||
- PATCH
|
- PATCH
|
||||||
- DELETE
|
- DELETE
|
||||||
|
|
||||||
|
# Headers are allowed being displayed on Web pages.
|
||||||
exposed-headers:
|
exposed-headers:
|
||||||
- "Content-Type"
|
- "Content-Type"
|
||||||
- "Authorization"
|
- "Authorization"
|
||||||
|
|
||||||
|
# Cross-origin policy max age.
|
||||||
max-age: PT2H
|
max-age: PT2H
|
||||||
jwt:
|
jwt:
|
||||||
issuer: dfguide.local # Issuer host
|
# Issuer host
|
||||||
secret: qwertyuiopasdfghjklzxcvbnm123456 # JWT singing secret, a 32-byte long or longer string is recommended
|
issuer: dfguide.local
|
||||||
valid-time: PT2H # JWT valid duration
|
|
||||||
|
# Token singing secret, a 32-byte long or longer string is recommended
|
||||||
|
secret: qwertyuiopasdfghjklzxcvbnm123456
|
||||||
|
|
||||||
|
# Token valid duration.
|
||||||
|
#
|
||||||
|
# Default to PT2H (2 hours).
|
||||||
|
valid-time: PT2H
|
||||||
|
|
||||||
|
# Token renew threshold. If valid time of this token is less than this value, then a new token
|
||||||
|
# will be delivered to the user.
|
||||||
|
#
|
||||||
|
# Default to PT5M (5 min).
|
||||||
|
renew-threshold: PT5M
|
||||||
webhook:
|
webhook:
|
||||||
github:
|
github:
|
||||||
secret: 123456
|
secret: 123456
|
||||||
@@ -52,6 +82,8 @@ app:
|
|||||||
|
|
||||||
springdoc:
|
springdoc:
|
||||||
api-docs:
|
api-docs:
|
||||||
enabled: true # Set to `false` if you do not need api docs (recommended in production mode).
|
# Set to `false` if you do not need api docs (recommended in production mode).
|
||||||
|
enabled: true
|
||||||
swagger-ui:
|
swagger-ui:
|
||||||
enabled: true # Set to `false` if you do not need swagger ui (recommended in production mode).
|
# Set to `false` if you do not need swagger ui (recommended in production mode).
|
||||||
|
enabled: true
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.onixbyte.deltaforceguide.properties;
|
package com.onixbyte.deltaforceguide.properties;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ import java.time.Duration;
|
|||||||
public record TokenProperties(
|
public record TokenProperties(
|
||||||
String issuer,
|
String issuer,
|
||||||
String secret,
|
String secret,
|
||||||
Duration validTime
|
@DefaultValue("PT2H") Duration validTime,
|
||||||
|
@DefaultValue("PT5M") Duration renewThreshold
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user