Package org.jenkinsci.plugins.oic
Class OicSecurityRealm
java.lang.Object
hudson.model.AbstractDescribableImpl<SecurityRealm>
hudson.security.SecurityRealm
org.jenkinsci.plugins.oic.OicSecurityRealm
- All Implemented Interfaces:
ExtensionPoint,Describable<SecurityRealm>,Serializable
Login with OpenID Connect / OAuth 2
- Author:
- Michael Bischoff, Steve Arch
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumNested classes/interfaces inherited from class hudson.security.SecurityRealm
SecurityRealm.SecurityComponentsNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
Fields inherited from class hudson.security.SecurityRealm
AUTHENTICATED_AUTHORITY, AUTHENTICATED_AUTHORITY2, LIST, NO_AUTHENTICATION -
Constructor Summary
ConstructorsConstructorDescriptionOicSecurityRealm(String clientId, Secret clientSecret, OicServerConfiguration serverConfiguration, Boolean disableSslVerification) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.google.api.client.auth.oauth2.AuthorizationCodeFlowBuild authorization code flowprotected booleancheckEscapeHatch(String username, String password) protected static io.burt.jmespath.Expression<Object>compileJMESPath(String str, String logComment) javax.servlet.FiltercreateFilter(javax.servlet.FilterConfig filterConfig) org.kohsuke.stapler.HttpResponsedoCommenceLogin(String from, String referer) Handles the the securityRealm/commenceLogin resource and sends the user off to the IdPorg.kohsuke.stapler.HttpResponsedoFinishLogin(org.kohsuke.stapler.StaplerRequest request) This is where the user comes back to at the end of the OpenID redirect ping-pong.voiddoLogout(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) getPostLogOutUrl2(org.kohsuke.stapler.StaplerRequest req, org.springframework.security.core.Authentication auth) protected StringgetStringField(Object object, io.burt.jmespath.Expression<Object> fieldExpr) protected StringValidate post-login redirect URL For security reasons, the login must not redirect outside Jenkins realm.booleanhandleTokenExpiration(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) Handles Token Expiration.booleanbooleanbooleanbooleanbooleanisExpired(OicCredentials credentials) booleanbooleanbooleanbooleanbooleanbooleanprotected ObjectvoidsetAllowedTokenExpirationClockSkewSeconds(Long allowedTokenExpirationClockSkewSeconds) voidsetAllowTokenAccessWithoutOicSession(boolean allowTokenAccessWithoutOicSession) voidsetDisableTokenVerification(boolean disableTokenVerification) voidsetEmailFieldName(String emailFieldName) voidsetEscapeHatchEnabled(boolean escapeHatchEnabled) voidsetEscapeHatchGroup(String escapeHatchGroup) voidsetEscapeHatchSecret(Secret escapeHatchSecret) voidsetEscapeHatchUsername(String escapeHatchUsername) voidsetFullNameFieldName(String fullNameFieldName) voidsetGroupsFieldName(String groupsFieldName) voidsetLogoutFromOpenidProvider(boolean logoutFromOpenidProvider) voidsetNonceDisabled(boolean nonceDisabled) voidsetPkceEnabled(boolean pkceEnabled) voidsetPostLogoutRedirectUrl(String postLogoutRedirectUrl) voidsetRootURLFromRequest(boolean rootURLFromRequest) voidsetSendScopesInTokenRequest(boolean sendScopesInTokenRequest) voidsetTokenExpirationCheckDisabled(boolean tokenExpirationCheckDisabled) voidsetTokenFieldToCheckKey(String tokenFieldToCheckKey) voidsetTokenFieldToCheckValue(String tokenFieldToCheckValue) voidsetUserNameField(String userNameField) Methods inherited from class hudson.security.SecurityRealm
all, allowsSignup, canLogOut, commenceSignup, commonFilters, createCliAuthenticator, doCaptcha, getCaptchaSupport, getCaptchaSupportDescriptors, getDescriptor, getFrom, getGroupIdStrategy, getPostLogOutUrl, getSecurityComponents, getUserIdStrategy, loadGroupByGroupname, loadGroupByGroupname, loadGroupByGroupname2, loadUserByUsername, loadUserByUsername2, setCaptchaSupport, validateCaptcha
-
Constructor Details
-
OicSecurityRealm
@DataBoundConstructor public OicSecurityRealm(String clientId, Secret clientSecret, OicServerConfiguration serverConfiguration, Boolean disableSslVerification) throws IOException - Throws:
IOException
-
-
Method Details
-
readResolve
- Throws:
ObjectStreamException
-
getClientId
-
getClientSecret
-
getServerConfiguration
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public OicServerConfiguration getServerConfiguration() -
getUserNameField
-
getTokenFieldToCheckKey
-
getTokenFieldToCheckValue
-
getFullNameFieldName
-
getEmailFieldName
-
getGroupsFieldName
-
isDisableSslVerification
public boolean isDisableSslVerification() -
isLogoutFromOpenidProvider
public boolean isLogoutFromOpenidProvider() -
getPostLogoutRedirectUrl
-
isEscapeHatchEnabled
public boolean isEscapeHatchEnabled() -
getEscapeHatchUsername
-
getEscapeHatchSecret
-
getEscapeHatchGroup
-
isRootURLFromRequest
public boolean isRootURLFromRequest() -
isSendScopesInTokenRequest
public boolean isSendScopesInTokenRequest() -
isPkceEnabled
public boolean isPkceEnabled() -
isDisableTokenVerification
public boolean isDisableTokenVerification() -
isNonceDisabled
public boolean isNonceDisabled() -
isTokenExpirationCheckDisabled
public boolean isTokenExpirationCheckDisabled() -
isAllowTokenAccessWithoutOicSession
public boolean isAllowTokenAccessWithoutOicSession() -
getAllowedTokenExpirationClockSkewSeconds
-
setUserNameField
-
setTokenFieldToCheckKey
-
setTokenFieldToCheckValue
-
setFullNameFieldName
-
setEmailFieldName
-
compileJMESPath
-
setGroupsFieldName
-
setLogoutFromOpenidProvider
@DataBoundSetter public void setLogoutFromOpenidProvider(boolean logoutFromOpenidProvider) -
setPostLogoutRedirectUrl
-
setEscapeHatchEnabled
@DataBoundSetter public void setEscapeHatchEnabled(boolean escapeHatchEnabled) -
setEscapeHatchUsername
-
setEscapeHatchSecret
-
checkEscapeHatch
-
setEscapeHatchGroup
-
setRootURLFromRequest
@DataBoundSetter public void setRootURLFromRequest(boolean rootURLFromRequest) -
setSendScopesInTokenRequest
@DataBoundSetter public void setSendScopesInTokenRequest(boolean sendScopesInTokenRequest) -
setPkceEnabled
@DataBoundSetter public void setPkceEnabled(boolean pkceEnabled) -
setDisableTokenVerification
@DataBoundSetter public void setDisableTokenVerification(boolean disableTokenVerification) -
setNonceDisabled
@DataBoundSetter public void setNonceDisabled(boolean nonceDisabled) -
setTokenExpirationCheckDisabled
@DataBoundSetter public void setTokenExpirationCheckDisabled(boolean tokenExpirationCheckDisabled) -
setAllowTokenAccessWithoutOicSession
@DataBoundSetter public void setAllowTokenAccessWithoutOicSession(boolean allowTokenAccessWithoutOicSession) -
setAllowedTokenExpirationClockSkewSeconds
@DataBoundSetter public void setAllowedTokenExpirationClockSkewSeconds(Long allowedTokenExpirationClockSkewSeconds) -
getLoginUrl
- Overrides:
getLoginUrlin classSecurityRealm
-
getAuthenticationGatewayUrl
- Overrides:
getAuthenticationGatewayUrlin classSecurityRealm
-
createFilter
public javax.servlet.Filter createFilter(javax.servlet.FilterConfig filterConfig) - Overrides:
createFilterin classSecurityRealm
-
createSecurityComponents
- Specified by:
createSecurityComponentsin classSecurityRealm
-
buildAuthorizationCodeFlow
protected com.google.api.client.auth.oauth2.AuthorizationCodeFlow buildAuthorizationCodeFlow()Build authorization code flow -
getValidRedirectUrl
Validate post-login redirect URL For security reasons, the login must not redirect outside Jenkins realm. For useablility reason, the logout page should redirect to root url. -
doCommenceLogin
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doCommenceLogin(@QueryParameter String from, @Header("Referer") String referer) Handles the the securityRealm/commenceLogin resource and sends the user off to the IdP- Parameters:
from- the relative URL to the page that the user has just come fromreferer- the HTTP referer header (where to redirect the user back to after login has finished)- Returns:
- an
HttpResponseobject
-
getStringField
-
doLogout
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public void doLogout(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException - Overrides:
doLogoutin classSecurityRealm- Throws:
IOExceptionjavax.servlet.ServletException
-
getPostLogOutUrl2
public String getPostLogOutUrl2(org.kohsuke.stapler.StaplerRequest req, org.springframework.security.core.Authentication auth) - Overrides:
getPostLogOutUrl2in classSecurityRealm
-
doFinishLogin
public org.kohsuke.stapler.HttpResponse doFinishLogin(org.kohsuke.stapler.StaplerRequest request) throws IOException This is where the user comes back to at the end of the OpenID redirect ping-pong.- Parameters:
request- The user's request- Returns:
- an HttpResponse
- Throws:
IOException
-
handleTokenExpiration
public boolean handleTokenExpiration(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) throws IOException, javax.servlet.ServletException Handles Token Expiration.- Throws:
IOException- a low level exceptionjavax.servlet.ServletException
-
isExpired
-