Skip to content

Commit 2274866

Browse files
authored
Merge pull request #1339 from amvanbaren/pat-prefix
Prefix personal access token
2 parents 124bee3 + f3b1e26 commit 2274866

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/src/main/java/org/eclipse/openvsx/UserService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.eclipse.openvsx.storage.StorageUtilService;
3333
import org.eclipse.openvsx.util.*;
3434
import org.springframework.beans.factory.annotation.Autowired;
35+
import org.springframework.beans.factory.annotation.Value;
3536
import org.springframework.cache.annotation.CacheEvict;
3637
import org.springframework.security.core.context.SecurityContextHolder;
3738
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
@@ -58,6 +59,9 @@ public class UserService {
5859
private final ClientRegistrationRepository clientRegistrationRepository;
5960
private final OAuth2AttributesConfig attributesConfig;
6061

62+
@Value("${ovsx.token-prefix:}")
63+
String tokenPrefix;
64+
6165
public UserService(
6266
EntityManager entityManager,
6367
RepositoryService repositories,
@@ -101,7 +105,7 @@ public PersonalAccessToken useAccessToken(String tokenValue) {
101105
public String generateTokenValue() {
102106
String value;
103107
do {
104-
value = UUID.randomUUID().toString();
108+
value = tokenPrefix + UUID.randomUUID();
105109
} while (repositories.hasAccessToken(value));
106110
return value;
107111
}

0 commit comments

Comments
 (0)