Package org.jenkinsci.plugins.saml
Class SamlSecurityRealm
java.lang.Object
hudson.model.AbstractDescribableImpl<SecurityRealm>
hudson.security.SecurityRealm
org.jenkinsci.plugins.saml.SamlSecurityRealm
- All Implemented Interfaces:
ExtensionPoint,Describable<SecurityRealm>
Authenticates the user via SAML.
This class is the main entry point to the plugin.
Uses Stapler (stapler.kohsuke.org) to bind methods to URLs.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class hudson.security.SecurityRealm
SecurityRealm.SecurityComponentsNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringURL to process the SAML answersstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringform validation messages.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class hudson.security.SecurityRealm
AUTHENTICATED_AUTHORITY, AUTHENTICATED_AUTHORITY2, LIST, NO_AUTHENTICATION -
Constructor Summary
ConstructorsConstructorDescriptionSamlSecurityRealm(IdpMetadataConfiguration idpMetadataConfiguration, String displayNameAttributeName, String groupsAttributeName, Integer maximumAuthenticationLifetime, String usernameAttributeName, String emailAttributeName, String logoutUrl, SamlAdvancedConfiguration advancedConfiguration, SamlEncryptionData encryptionData, String usernameCaseConversion, String binding, List<AttributeEntry> samlCustomAttributes) Jenkins passes these parameters in when you update the settings. -
Method Summary
Modifier and TypeMethodDescriptionbooleanorg.kohsuke.stapler.HttpResponsedoCommenceLogin(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/commenceLoginorg.kohsuke.stapler.HttpResponsedoFinishLogin(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/finishLoginvoiddoLogout(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) org.kohsuke.stapler.HttpResponsedoMetadata(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/metadataprotected StringgetPostLogOutUrl2(org.kohsuke.stapler.StaplerRequest2 req, org.springframework.security.core.Authentication auth) loadGroupByGroupname2(String groupname, boolean fetchMembers) This method is overwritten due to SAML has no way to retrieve the members of a Group and this cause issues on some Authorization plugins.voidsetProperties(List<SamlProperty> properties) voidsetSamlCustomAttribute(List<AttributeEntry> samlCustomAttributes) toString()Methods inherited from class hudson.security.SecurityRealm
all, canLogOut, commenceSignup, commonFilters, createCliAuthenticator, createFilter, createFilter, doCaptcha, doLogout, getAuthenticationGatewayUrl, getCaptchaSupport, getCaptchaSupportDescriptors, getDescriptor, getFrom, getGroupIdStrategy, getPostLogOutUrl, getPostLogOutUrl2, getSecurityComponents, getUserIdStrategy, loadGroupByGroupname, loadGroupByGroupname, loadUserByUsername, loadUserByUsername2, setCaptchaSupport, validateCaptcha
-
Field Details
-
DEFAULT_DISPLAY_NAME_ATTRIBUTE_NAME
- See Also:
-
DEFAULT_GROUPS_ATTRIBUTE_NAME
- See Also:
-
DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME
public static final int DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME- See Also:
-
DEFAULT_USERNAME_CASE_CONVERSION
- See Also:
-
SP_METADATA_FILE_NAME
- See Also:
-
IDP_METADATA_FILE_NAME
- See Also:
-
ERROR_ONLY_SPACES_FIELD_VALUE
form validation messages.- See Also:
-
ERROR_NOT_VALID_NUMBER
- See Also:
-
ERROR_MALFORMED_URL
- See Also:
-
ERROR_IDP_METADATA_EMPTY
- See Also:
-
WARN_RECOMMENDED_TO_SET_THE_GROUPS_ATTRIBUTE
- See Also:
-
WARN_RECOMMENDED_TO_SET_THE_USERNAME_ATTRIBUTE
- See Also:
-
WARN_RECOMMENDED_TO_SET_THE_EMAIL_ATTRIBUTE
- See Also:
-
ERROR_NOT_POSSIBLE_TO_READ_KS_FILE
- See Also:
-
ERROR_CERTIFICATES_COULD_NOT_BE_LOADED
- See Also:
-
ERROR_ALGORITHM_CANNOT_BE_FOUND
- See Also:
-
ERROR_NO_PROVIDER_SUPPORTS_A_KS_SPI_IMPL
- See Also:
-
ERROR_WRONG_INFO_OR_PASSWORD
- See Also:
-
ERROR_INSUFFICIENT_OR_INVALID_INFO
- See Also:
-
CONSUMER_SERVICE_URL_PATH
URL to process the SAML answers- See Also:
-
WARN_THERE_IS_NOT_KEY_STORE
- See Also:
-
ERROR_NOT_KEY_FOUND
- See Also:
-
SUCCESS
- See Also:
-
NOT_POSSIBLE_TO_GET_THE_METADATA
- See Also:
-
CHECK_TROUBLESHOOTING_GUIDE
- See Also:
-
CHECK_MAX_AUTH_LIFETIME
- See Also:
-
WARN_KEYSTORE_NOT_SET
- See Also:
-
WARN_PRIVATE_KEY_ALIAS_NOT_SET
- See Also:
-
WARN_PRIVATE_KEYSTORE_PASS_NOT_SET
- See Also:
-
WARN_PRIVATE_KEY_PASS_NOT_SET
- See Also:
-
-
Constructor Details
-
SamlSecurityRealm
@DataBoundConstructor public SamlSecurityRealm(IdpMetadataConfiguration idpMetadataConfiguration, String displayNameAttributeName, String groupsAttributeName, Integer maximumAuthenticationLifetime, String usernameAttributeName, String emailAttributeName, String logoutUrl, SamlAdvancedConfiguration advancedConfiguration, SamlEncryptionData encryptionData, String usernameCaseConversion, String binding, List<AttributeEntry> samlCustomAttributes) throws IOException Jenkins passes these parameters in when you update the settings. It does this because of the @DataBoundConstructor.- Parameters:
idpMetadataConfiguration- How to obtain the IdP Metadata configuration.displayNameAttributeName- attribute that has the displaynamegroupsAttributeName- attribute that has the groupsmaximumAuthenticationLifetime- maximum time that an identification it is validusernameAttributeName- attribute that has the usernameemailAttributeName- attribute that has the emaillogoutUrl- optional URL to redirect on logoutadvancedConfiguration- advanced configuration settingsencryptionData- encryption configuration settingsusernameCaseConversion- username case sensitive settingsbinding- SAML binding method.samlCustomAttributes- Custom Attributes to read from the SAML Responsse.- Throws:
IOException- if it is not possible to write the IdP metadata file.
-
-
Method Details
-
readResolve
-
getProperties
-
setProperties
@DataBoundSetter public void setProperties(@CheckForNull List<SamlProperty> properties) throws IOException - Throws:
IOException
-
allowsSignup
public boolean allowsSignup()- Overrides:
allowsSignupin classSecurityRealm
-
createSecurityComponents
- Specified by:
createSecurityComponentsin classSecurityRealm
-
getLoginUrl
- Overrides:
getLoginUrlin classSecurityRealm
-
doCommenceLogin
public org.kohsuke.stapler.HttpResponse doCommenceLogin(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/commenceLogin- Parameters:
request- http request.response- http response.- Returns:
- the http response.
-
doFinishLogin
public org.kohsuke.stapler.HttpResponse doFinishLogin(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/finishLogin- Parameters:
request- http request.response- http response.- Returns:
- the http response.
-
doMetadata
public org.kohsuke.stapler.HttpResponse doMetadata(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/metadataURL request service method to expose the SP metadata to the user so that they can configure their IdP.
- Parameters:
request- http request.response- http response.- Returns:
- the http response.
-
getPostLogOutUrl2
protected String getPostLogOutUrl2(org.kohsuke.stapler.StaplerRequest2 req, @NonNull org.springframework.security.core.Authentication auth) -
doLogout
public void doLogout(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Overrides:
doLogoutin classSecurityRealm- Throws:
IOExceptionjakarta.servlet.ServletException
-
loadGroupByGroupname2
public GroupDetails loadGroupByGroupname2(String groupname, boolean fetchMembers) throws org.springframework.security.core.userdetails.UsernameNotFoundException This method is overwritten due to SAML has no way to retrieve the members of a Group and this cause issues on some Authorization plugins. Because of that we have to implement SamlGroupDetails- Overrides:
loadGroupByGroupname2in classSecurityRealm- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
-
getSamlPluginConfig
- Returns:
- plugin configuration parameters.
-
getUsernameAttributeName
-
getDisplayNameAttributeName
-
getGroupsAttributeName
-
getMaximumAuthenticationLifetime
-
getAdvancedConfiguration
-
getBinding
-
getEncryptionData
-
getUsernameCaseConversion
-
getEmailAttributeName
-
getLogoutUrl
-
getIdpMetadataConfiguration
-
getSamlCustomAttributes
-
setSamlCustomAttribute
-
toString
-