Package org.jenkinsci.plugins.cas
Class CasSecurityRealm
java.lang.Object
hudson.model.AbstractDescribableImpl<SecurityRealm>
hudson.security.SecurityRealm
org.jenkinsci.plugins.cas.CasSecurityRealm
- All Implemented Interfaces:
ExtensionPoint
,Describable<SecurityRealm>
CAS Single Sign-On security realm.
- Author:
- Fabien Crespel, J. David Beutel
- 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 TypeFieldDescriptionfinal CasProtocol
final String
static final String
static final String
static final String
final Boolean
final Boolean
final Boolean
final Boolean
Fields inherited from class hudson.security.SecurityRealm
AUTHENTICATED_AUTHORITY, AUTHENTICATED_AUTHORITY2, LIST, NO_AUTHENTICATION
-
Constructor Summary
ConstructorDescriptionCasSecurityRealm
(String casServerUrl, CasProtocol casProtocol, Boolean forceRenewal, Boolean enableSingleSignOut) Deprecated.CasSecurityRealm
(String casServerUrl, CasProtocol casProtocol, Boolean forceRenewal, Boolean enableSingleSignOut, Boolean enableRestApi) Deprecated.CasSecurityRealm
(String casServerUrl, CasProtocol casProtocol, Boolean forceRenewal, Boolean enableSingleSignOut, Boolean enableRestApi, Boolean enableLogoutRedirect) -
Method Summary
Modifier and TypeMethodDescriptionjakarta.servlet.Filter
createFilter
(jakarta.servlet.FilterConfig filterConfig) Build the filter that will validate the service ticket returned by CAS.Build a authentication manager which uses the CAS REST API for username and password based authentication against the REST API.void
doCommenceLogin
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) The login process starts from here, using the CasAuthenticationEntryPoint.void
doFinishLogin
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) The login process finishes here, by firing the authenticated event.void
doLogout
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Handles the logout processing.protected org.springframework.context.ApplicationContext
Create the Spring application context that will hold CAS filters.static String
Get the URL to redirect to in case of authentication failure.static String
Get the callback URL after CAS authentication.static String
Get the root Jenkins URL configured in global settings.static String
getJenkinsUrl
(jakarta.servlet.http.HttpServletRequest req) Get the root Jenkins URL configured in global settings, or construct it from the current HTTP request.Login begins with ourdoCommenceLogin(StaplerRequest2, StaplerResponse2)
method.protected String
getPostLogOutUrl2
(org.kohsuke.stapler.StaplerRequest2 req, org.springframework.security.core.Authentication auth) Logout redirects to CAS before coming back to Jenkins (unless disabled).static String
getServiceUrl
(jakarta.servlet.http.HttpServletRequest req, org.springframework.security.cas.ServiceProperties serviceProperties) Get the full service URL for use with CAS.Methods inherited from class hudson.security.SecurityRealm
all, allowsSignup, canLogOut, commenceSignup, commonFilters, createCliAuthenticator, createFilter, doCaptcha, doLogout, getAuthenticationGatewayUrl, getCaptchaSupport, getCaptchaSupportDescriptors, getDescriptor, getFrom, getGroupIdStrategy, getPostLogOutUrl, getPostLogOutUrl2, getSecurityComponents, getUserIdStrategy, loadGroupByGroupname, loadGroupByGroupname, loadGroupByGroupname2, loadUserByUsername, loadUserByUsername2, setCaptchaSupport, validateCaptcha
-
Field Details
-
DEFAULT_COMMENCE_LOGIN_URL
- See Also:
-
DEFAULT_FINISH_LOGIN_URL
- See Also:
-
DEFAULT_FAILED_LOGIN_URL
- See Also:
-
casServerUrl
-
casProtocol
-
forceRenewal
-
enableSingleSignOut
-
enableRestApi
-
enableLogoutRedirect
-
-
Constructor Details
-
CasSecurityRealm
@Deprecated public CasSecurityRealm(String casServerUrl, CasProtocol casProtocol, Boolean forceRenewal, Boolean enableSingleSignOut) Deprecated. -
CasSecurityRealm
@Deprecated public CasSecurityRealm(String casServerUrl, CasProtocol casProtocol, Boolean forceRenewal, Boolean enableSingleSignOut, Boolean enableRestApi) Deprecated. -
CasSecurityRealm
-
-
Method Details
-
getJenkinsUrl
Get the root Jenkins URL configured in global settings.- Returns:
- Jenkins URL
-
getJenkinsUrl
Get the root Jenkins URL configured in global settings, or construct it from the current HTTP request.- Parameters:
req
- current HTTP request- Returns:
- Jenkins URL
-
getFinishLoginUrl
Get the callback URL after CAS authentication.- Returns:
- finish login URL
-
getFailedLoginUrl
Get the URL to redirect to in case of authentication failure.- Returns:
- failed login URL
-
getServiceUrl
public static String getServiceUrl(jakarta.servlet.http.HttpServletRequest req, org.springframework.security.cas.ServiceProperties serviceProperties) Get the full service URL for use with CAS.- Parameters:
req
- current HTTP requestserviceProperties
- service properties- Returns:
- full service URL
-
getApplicationContext
protected org.springframework.context.ApplicationContext getApplicationContext()Create the Spring application context that will hold CAS filters.- Returns:
- Spring application context
-
getLoginUrl
Login begins with ourdoCommenceLogin(StaplerRequest2, StaplerResponse2)
method.- Overrides:
getLoginUrl
in classSecurityRealm
- Returns:
- Jenkins commenceLogin URL
-
getPostLogOutUrl2
protected String getPostLogOutUrl2(org.kohsuke.stapler.StaplerRequest2 req, org.springframework.security.core.Authentication auth) Logout redirects to CAS before coming back to Jenkins (unless disabled).- Overrides:
getPostLogOutUrl2
in classSecurityRealm
- Returns:
- CAS logout URL
-
createSecurityComponents
Build a authentication manager which uses the CAS REST API for username and password based authentication against the REST API. Browser authentication is handled by the CAS filter chain.- Specified by:
createSecurityComponents
in classSecurityRealm
- Returns:
- SecurityComponents holder for the authentication manager
-
createFilter
public jakarta.servlet.Filter createFilter(jakarta.servlet.FilterConfig filterConfig) Build the filter that will validate the service ticket returned by CAS. This filter will also wrap the original filter chain from Jenkins to preserve support for API token authentication (among other features).- Overrides:
createFilter
in classSecurityRealm
- Returns:
- CAS filter
-
doLogout
public void doLogout(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Handles the logout processing.- Overrides:
doLogout
in classSecurityRealm
- Parameters:
req
- requestrsp
- response- Throws:
IOException
- I/O errorjakarta.servlet.ServletException
- Servlet error
-
doCommenceLogin
public void doCommenceLogin(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException The login process starts from here, using the CasAuthenticationEntryPoint.- Parameters:
req
- requestrsp
- response- Throws:
IOException
- I/O errorjakarta.servlet.ServletException
- Servlet error
-
doFinishLogin
public void doFinishLogin(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) The login process finishes here, by firing the authenticated event.- Parameters:
req
- requestrsp
- response
-