Skip to content

Commit 7c657df

Browse files
committed
Retire SHOW_LEGACY_TOKEN_TO_ADMINS system property in ApiTokenProperty
1 parent fab959f commit 7c657df

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

core/src/main/java/jenkins/security/ApiTokenProperty.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import jenkins.security.apitoken.ApiTokenStats;
6161
import jenkins.security.apitoken.ApiTokenStore;
6262
import jenkins.security.apitoken.TokenUuidAndPlainValue;
63-
import jenkins.util.SystemProperties;
6463
import net.jcip.annotations.Immutable;
6564
import net.sf.json.JSONArray;
6665
import net.sf.json.JSONObject;
@@ -87,29 +86,6 @@
8786
public class ApiTokenProperty extends UserProperty {
8887
private static final Logger LOGGER = Logger.getLogger(ApiTokenProperty.class.getName());
8988

90-
/**
91-
* If enabled, the users with {@link Jenkins#ADMINISTER} permissions can view legacy tokens for
92-
* other users.<p>
93-
* Disabled by default due to the security reasons.<p>
94-
* If enabled, it restores the original Jenkins behavior (SECURITY-200).
95-
*
96-
* @since 1.638
97-
*/
98-
private static /* not final */ boolean SHOW_LEGACY_TOKEN_TO_ADMINS =
99-
SystemProperties.getBoolean(ApiTokenProperty.class.getName() + ".showTokenToAdmins");
100-
101-
/**
102-
* If enabled, the users with {@link Jenkins#ADMINISTER} permissions can generate new tokens for
103-
* other users. Normally a user can only generate tokens for himself.<p>
104-
* Take care that only the creator of a token will have the plain value as it's only stored as an hash in the system.<p>
105-
* Disabled by default due to the security reasons.
106-
* It's the version of {@link #SHOW_LEGACY_TOKEN_TO_ADMINS} for the new API Token system (SECURITY-200).
107-
*
108-
* @since 2.129
109-
*/
110-
private static /* not final */ boolean ADMIN_CAN_GENERATE_NEW_TOKENS =
111-
SystemProperties.getBoolean(ApiTokenProperty.class.getName() + ".adminCanGenerateNewTokens");
112-
11389
private volatile Secret apiToken;
11490
private ApiTokenStore tokenStore;
11591

@@ -152,7 +128,7 @@ protected void setUser(User u) {
152128
/**
153129
* Gets the API token.
154130
* The method performs security checks since 1.638. Only the current user and SYSTEM may see it.
155-
* Users with {@link Jenkins#ADMINISTER} may be allowed to do it using {@link #SHOW_LEGACY_TOKEN_TO_ADMINS}.
131+
* Users with {@link Jenkins#ADMINISTER} permissions may also be allowed to see it.
156132
*
157133
* @return API Token. Never null, but may be {@link Messages#ApiTokenProperty_ChangeToken_TokenIsHidden()}
158134
* if the user has no appropriate permissions.
@@ -213,7 +189,7 @@ public boolean matchesPassword(String token) {
213189
*/
214190
private boolean hasPermissionToSeeToken() {
215191
// Administrators can do whatever they want
216-
return canCurrentUserControlObject(SHOW_LEGACY_TOKEN_TO_ADMINS, user);
192+
return canCurrentUserControlObject(true, user);
217193
}
218194

219195
private static boolean canCurrentUserControlObject(boolean trustAdmins, User propertyOwner) {
@@ -563,7 +539,7 @@ public boolean mustDisplayLegacyApiToken(User propertyOwner) {
563539
// for Jelly view
564540
@Restricted(NoExternalUse.class)
565541
public boolean hasCurrentUserRightToGenerateNewToken(User propertyOwner) {
566-
return canCurrentUserControlObject(ADMIN_CAN_GENERATE_NEW_TOKENS, propertyOwner);
542+
return canCurrentUserControlObject(true, propertyOwner);
567543
}
568544

569545
/**

0 commit comments

Comments
 (0)