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 classes/interfaces inherited from class hudson.security.SecurityRealm
SecurityRealm.SecurityComponents
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
URL to process the SAML answersstatic final String
static final String
static final int
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
form validation messages.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class hudson.security.SecurityRealm
AUTHENTICATED_AUTHORITY, AUTHENTICATED_AUTHORITY2, LIST, NO_AUTHENTICATION
-
Constructor Summary
ConstructorDescriptionSamlSecurityRealm
(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 TypeMethodDescriptionboolean
org.kohsuke.stapler.HttpResponse
doCommenceLogin
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response, String from, String referer) /securityRealm/commenceLoginorg.kohsuke.stapler.HttpResponse
doFinishLogin
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/finishLoginvoid
doLogout
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) org.kohsuke.stapler.HttpResponse
doMetadata
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) /securityRealm/metadataprotected String
getPostLogOutUrl2
(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.void
setSamlCustomAttribute
(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
-
allowsSignup
public boolean allowsSignup()- Overrides:
allowsSignup
in classSecurityRealm
-
createSecurityComponents
- Specified by:
createSecurityComponents
in classSecurityRealm
-
getLoginUrl
- Overrides:
getLoginUrl
in classSecurityRealm
-
doCommenceLogin
public org.kohsuke.stapler.HttpResponse doCommenceLogin(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response, @QueryParameter String from, @Header("Referer") String referer) /securityRealm/commenceLogin- Parameters:
request
- http request.response
- http response.referer
- referer.from
- http request "from" parameter.- 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:
doLogout
in classSecurityRealm
- Throws:
IOException
jakarta.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:
loadGroupByGroupname2
in 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
-