mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
feat(java): add jwt token lifetime from config
This commit is contained in:
@ -47,6 +47,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -543,6 +544,7 @@ public final class DocumentManager {
|
||||
for (String key : payloadClaims.keySet()) { // run through all the keys from the payload
|
||||
jwt.addClaim(key, payloadClaims.get(key)); // and write each claim to the jwt
|
||||
}
|
||||
jwt.setExpiration(ZonedDateTime.now().plusMinutes(getTokenExpiration()));
|
||||
return JWT.getEncoder().encode(jwt, signer); // sign and encode the JWT to a JSON string representation
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
@ -579,6 +581,11 @@ public final class DocumentManager {
|
||||
return ConfigManager.getProperty("files.docservice.secret");
|
||||
}
|
||||
|
||||
// get token expiration time in minutes from the config parameters
|
||||
public static Integer getTokenExpiration() {
|
||||
return Integer.parseInt(ConfigManager.getProperty("files.docservice.token-expiration"));
|
||||
}
|
||||
|
||||
// get config request jwt
|
||||
public static String getTokenUseForRequest() {
|
||||
return ConfigManager.getProperty("files.docservice.token-use-for-request");
|
||||
|
||||
@ -19,5 +19,6 @@ files.docservice.languages=en:English|sq-AL:Albanian (Albania)|ar:Arabic|hy:Arme
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
files.docservice.token-use-for-request=TRUE
|
||||
files.docservice.token-expiration=5
|
||||
|
||||
files.docservice.verify-peer-off=TRUE
|
||||
|
||||
Reference in New Issue
Block a user