|
60 | 60 | import jenkins.security.apitoken.ApiTokenStats; |
61 | 61 | import jenkins.security.apitoken.ApiTokenStore; |
62 | 62 | import jenkins.security.apitoken.TokenUuidAndPlainValue; |
63 | | -import jenkins.util.SystemProperties; |
64 | 63 | import net.jcip.annotations.Immutable; |
65 | 64 | import net.sf.json.JSONArray; |
66 | 65 | import net.sf.json.JSONObject; |
|
87 | 86 | public class ApiTokenProperty extends UserProperty { |
88 | 87 | private static final Logger LOGGER = Logger.getLogger(ApiTokenProperty.class.getName()); |
89 | 88 |
|
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 | | - |
113 | 89 | private volatile Secret apiToken; |
114 | 90 | private ApiTokenStore tokenStore; |
115 | 91 |
|
@@ -152,7 +128,7 @@ protected void setUser(User u) { |
152 | 128 | /** |
153 | 129 | * Gets the API token. |
154 | 130 | * 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. |
156 | 132 | * |
157 | 133 | * @return API Token. Never null, but may be {@link Messages#ApiTokenProperty_ChangeToken_TokenIsHidden()} |
158 | 134 | * if the user has no appropriate permissions. |
@@ -213,7 +189,7 @@ public boolean matchesPassword(String token) { |
213 | 189 | */ |
214 | 190 | private boolean hasPermissionToSeeToken() { |
215 | 191 | // Administrators can do whatever they want |
216 | | - return canCurrentUserControlObject(SHOW_LEGACY_TOKEN_TO_ADMINS, user); |
| 192 | + return canCurrentUserControlObject(true, user); |
217 | 193 | } |
218 | 194 |
|
219 | 195 | private static boolean canCurrentUserControlObject(boolean trustAdmins, User propertyOwner) { |
@@ -563,7 +539,7 @@ public boolean mustDisplayLegacyApiToken(User propertyOwner) { |
563 | 539 | // for Jelly view |
564 | 540 | @Restricted(NoExternalUse.class) |
565 | 541 | public boolean hasCurrentUserRightToGenerateNewToken(User propertyOwner) { |
566 | | - return canCurrentUserControlObject(ADMIN_CAN_GENERATE_NEW_TOKENS, propertyOwner); |
| 542 | + return canCurrentUserControlObject(true, propertyOwner); |
567 | 543 | } |
568 | 544 |
|
569 | 545 | /** |
|
0 commit comments