|
|
@@ -16,9 +16,11 @@ import org.gitlab4j.api.models.ImpersonationToken;
|
|
|
import org.gitlab4j.api.models.ImpersonationToken.Scope;
|
|
|
import org.gitlab4j.api.models.Namespace;
|
|
|
import org.gitlab4j.api.models.User;
|
|
|
+import org.gitlab4j.api.utils.ISO8601;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
import java.time.Instant;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
@@ -138,8 +140,16 @@ public class UserServiceImpl implements UserService {
|
|
|
Scope[] scopes = new Scope[]{Scope.API};
|
|
|
ImpersonationToken token;
|
|
|
log.info(String.format("createToken, userId = %d",userId));
|
|
|
+ Date expiresAt;
|
|
|
+
|
|
|
+ try {
|
|
|
+ expiresAt = ISO8601.toDate("2024-10-01T00:00:00Z");
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
// 最长为一年之后
|
|
|
- token = gitlabApi.getUserApi().createImpersonationToken(userId.toString(), "AES-" + Tools.randomUUID(), new Date(2024, Calendar.NOVEMBER,4), scopes);
|
|
|
+ token = gitlabApi.getUserApi().createImpersonationToken(userId.toString(), "AES-" + Tools.randomUUID(), expiresAt, scopes);
|
|
|
return token.getToken();
|
|
|
}
|
|
|
|