Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-45387] Fix validation error displaying in setup wizard's "cr…
…eate first admin" form (#3116) * [JENKINS-45387] Improve setup wizard account creation in security realm This commit adds an additional account creation method to the security realm, that allows to create a new user account (as the system) and is intended to be used by the setup wizard. The main difference to the existing method is that the new method does not force the Stapler to send a response, but instead throws an exception if invalid data is submitted. This allows to call this from the setup wizard, and send the response there. (This is necessary because the setup wizard method has a response return type and there is no way to access the response already send in the realm) Further, it splits the private createAccount() method for clarity as well as to allow code reuse from the new method. * [JENKINS-45387] Fix SetupWizard sending responses twice on create admin This commit fixes an issue where the SetupWizard class would send two responses (indirectly) when invalid form data was provided for creating the first admin account. * [Fix JENKINS-45387] Setup wizard not displaying first account errors This commit fixes the setup wizard not displaying HTML error responses upon first account creation. Previously, it just froze (buttons were not re-enabled) and didn't display responses. (Probably caused by XSS policies on the iframe) * [JENKINS-45387] Add some @restricted annotations As per #3116 (comment) #3116 (comment)
- Loading branch information
1 parent
145c606
commit 12031d7
Showing
5 changed files
with
182 additions
and
87 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
core/src/main/java/hudson/security/AccountCreationFailedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2017 Jenkins contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package hudson.security; | ||
|
||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
/** | ||
* Thrown if an account creation was attempted but failed due to invalid data being entered into a form. | ||
* | ||
* @author Philipp Nowak | ||
*/ | ||
@Restricted(NoExternalUse.class) | ||
public class AccountCreationFailedException extends Exception { | ||
public AccountCreationFailedException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters