Class BaseOAuthAuthentication
- java.lang.Object
-
- jetbrains.buildServer.serverSide.oauth.BaseOAuthAuthentication
-
- All Implemented Interfaces:
HttpAuthenticationScheme,AuthModuleType
- Direct Known Subclasses:
AzureDevOpsAuthentication,BitBucketAuthentication,GitHubAuthentication.BaseGitHubAuthentication,GitLabAuthentication.BaseGitLabAuthentication,GoogleAuthentication,SpaceAuthentication
public abstract class BaseOAuthAuthentication extends Object implements HttpAuthenticationScheme
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ALLOW_CREATING_NEW_USERS_BY_LOGINprotected static LoggerLOGGERprotected StringmyAccessTokenControllerPathprotected AuthenticationContextmyContextprotected StringmyDefaultScopeprotected OAuthFlowmyOAuthFlowprotected OAuthProvidermyOAuthProviderprotected UniqueRedirectServicemyUniqueRedirectService
-
Constructor Summary
Constructors Constructor Description BaseOAuthAuthentication(AuthenticationContext context, OAuthProvider oAuthProvider, OAuthFlow oAuthFlow, String defaultScope, String loginJsp, String editAuthModuleJsp, String loginControllerPath, String accessTokenControllerPath, AvatarProvider avatarProvider, UserAvatarsManager userAvatarsManager)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidafterNewUserCreated(SUser createdUser, OAuthConnectionDescriptor connection, String accessToken)StringdescribeProperties(Map<String,String> properties)Returns description of the specified properties map to be shown in UIBaseControllergetConnectAccountController()Map<String,String>getDefaultProperties()StringgetDescription()Returns description of the authentication module to show in the UIStringgetDisplayName()Returns name of the authentication module to show in the UIStringgetEditPropertiesJspFilePath()BaseControllergetLoginController()StringgetName()protected StringgetRedirectPath(OAuthConnectionDescriptor connection)protected StringgetRedirectUri(OAuthConnectionDescriptor connection)StringgetRestrictingOptions(Map<String,String> properties)OAuthConnectionDescriptorgetSuitableConnection()static AuthPropertyKeygetUserIdPropertyKey(OAuthProvider oAuthProvider)static AuthPropertyKeygetUsernamePropertyKey(OAuthProvider oAuthProvider)StringgetUserRedirect(javax.servlet.http.HttpServletRequest request)voidinit()protected booleanisMatchingUniqueRedirectPath(String requestUrl)booleanisMultipleInstancesAllowed()protected booleanisValidRedirectUrl(String requestUrl, String connectionId)protected StringperformAuthChecks(OAuthFlow.OAuthResult oAuthResult, Map<String,String> properties, OAuthConnectionDescriptor connection)protected StringprepareBackRedirectErrorMessage(String error, String errorDescr)HttpAuthenticationResultprocessAuthenticationRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String,String> properties)Processes authentication request.
If the request does not correspond to this scheme, method must return HttpAuthenticationResult.notApplicable().
If response object is changed inside the method, method must return HttpAuthenticationResult.unauthenticated().protected ConnectOAuthAccountControllerregisterUserProfilePageExtensions()protected abstract voidrememberToken(javax.servlet.http.HttpServletRequest request, SUser created, OAuthConnectionDescriptor oAuthConnectionDescriptor, OAuthFlow.OAuthResult oAuthResult)voidsetUniqueRedirectService(UniqueRedirectService uniqueRedirectService)booleanshouldSkip2FA(javax.servlet.http.HttpServletRequest request, Map<String,String> properties)Returns whether two-factor authentication should be skipped when this scheme is used.OAuthConnectionDescriptortryFindSuitableConnection()Collection<String>validate(Map<String,String> properties)Validates the current login module settings and returns the set of errors if found.
-
-
-
Field Detail
-
LOGGER
@NotNull protected static final Logger LOGGER
-
DEFAULT_ALLOW_CREATING_NEW_USERS_BY_LOGIN
public static final boolean DEFAULT_ALLOW_CREATING_NEW_USERS_BY_LOGIN
- See Also:
- Constant Field Values
-
myContext
@NotNull protected final AuthenticationContext myContext
-
myOAuthFlow
@NotNull protected final OAuthFlow myOAuthFlow
-
myOAuthProvider
@NotNull protected final OAuthProvider myOAuthProvider
-
myDefaultScope
@Nullable protected final String myDefaultScope
-
myAccessTokenControllerPath
@NotNull protected final String myAccessTokenControllerPath
-
myUniqueRedirectService
@Nullable protected UniqueRedirectService myUniqueRedirectService
-
-
Constructor Detail
-
BaseOAuthAuthentication
public BaseOAuthAuthentication(@NotNull AuthenticationContext context, @NotNull OAuthProvider oAuthProvider, @NotNull OAuthFlow oAuthFlow, @Nullable String defaultScope, @NotNull String loginJsp, @NotNull String editAuthModuleJsp, @NotNull String loginControllerPath, @NotNull String accessTokenControllerPath, @NotNull AvatarProvider avatarProvider, @NotNull UserAvatarsManager userAvatarsManager)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
getUserRedirect
@NotNull public String getUserRedirect(javax.servlet.http.HttpServletRequest request)
-
processAuthenticationRequest
@NotNull public HttpAuthenticationResult processAuthenticationRequest(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull Map<String,String> properties) throws IOException
Description copied from interface:HttpAuthenticationSchemeProcesses authentication request.
If the request does not correspond to this scheme, method must return HttpAuthenticationResult.notApplicable().
If response object is changed inside the method, method must return HttpAuthenticationResult.unauthenticated().- Specified by:
processAuthenticationRequestin interfaceHttpAuthenticationScheme- Parameters:
request- requestresponse- responseproperties- properties from config file- Returns:
- result of processing, see above
- Throws:
IOException- if some I/O error occurred
-
isMatchingUniqueRedirectPath
protected boolean isMatchingUniqueRedirectPath(@NotNull String requestUrl)
-
isValidRedirectUrl
protected boolean isValidRedirectUrl(@NotNull String requestUrl, @Nullable String connectionId)
-
shouldSkip2FA
public boolean shouldSkip2FA(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull Map<String,String> properties)Description copied from interface:HttpAuthenticationSchemeReturns whether two-factor authentication should be skipped when this scheme is used.- Specified by:
shouldSkip2FAin interfaceHttpAuthenticationScheme- Parameters:
request- requestproperties- properties from config file- Returns:
- true if two-factor authentication should be skipped, false otherwise
-
afterNewUserCreated
protected void afterNewUserCreated(@NotNull SUser createdUser, @NotNull OAuthConnectionDescriptor connection, @NotNull String accessToken)
-
prepareBackRedirectErrorMessage
@NotNull protected String prepareBackRedirectErrorMessage(@NotNull String error, @Nullable String errorDescr)
-
performAuthChecks
@Nullable protected String performAuthChecks(OAuthFlow.OAuthResult oAuthResult, Map<String,String> properties, OAuthConnectionDescriptor connection) throws IOException
- Throws:
IOException
-
rememberToken
protected abstract void rememberToken(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull SUser created, @NotNull OAuthConnectionDescriptor oAuthConnectionDescriptor, @NotNull OAuthFlow.OAuthResult oAuthResult)
-
getRedirectPath
@Nullable protected String getRedirectPath(@NotNull OAuthConnectionDescriptor connection)
-
getRedirectUri
@NotNull protected String getRedirectUri(OAuthConnectionDescriptor connection)
-
getName
@NotNull public String getName()
- Specified by:
getNamein interfaceAuthModuleType- Returns:
- unique identificator (case-insensitive)
-
getDisplayName
@NotNull public String getDisplayName()
Description copied from interface:AuthModuleTypeReturns name of the authentication module to show in the UI- Specified by:
getDisplayNamein interfaceAuthModuleType- Returns:
- name of the authentication module to show in the UI
-
getDescription
@NotNull public String getDescription()
Description copied from interface:AuthModuleTypeReturns description of the authentication module to show in the UI- Specified by:
getDescriptionin interfaceAuthModuleType- Returns:
- description of the authentication module to show in the UI
-
isMultipleInstancesAllowed
public boolean isMultipleInstancesAllowed()
- Specified by:
isMultipleInstancesAllowedin interfaceAuthModuleType- Returns:
- true, if multiple instances of this authentication module are allowed, false otherwise
-
getDefaultProperties
@NotNull public Map<String,String> getDefaultProperties()
- Specified by:
getDefaultPropertiesin interfaceAuthModuleType- Returns:
- default properties for this authentication module
-
describeProperties
@NotNull public String describeProperties(@NotNull Map<String,String> properties)
Description copied from interface:AuthModuleTypeReturns description of the specified properties map to be shown in UI- Specified by:
describePropertiesin interfaceAuthModuleType- Parameters:
properties- properties- Returns:
- description of the specified properties map
-
validate
@Nullable public Collection<String> validate(@NotNull Map<String,String> properties)
Description copied from interface:AuthModuleTypeValidates the current login module settings and returns the set of errors if found. Should returnnullif no errors found.- Specified by:
validatein interfaceAuthModuleType- Parameters:
properties- properties- Returns:
- the collection of errors.
-
getRestrictingOptions
@Nullable public String getRestrictingOptions(@NotNull Map<String,String> properties)
-
getEditPropertiesJspFilePath
@Nullable public String getEditPropertiesJspFilePath()
- Specified by:
getEditPropertiesJspFilePathin interfaceAuthModuleType- Returns:
- path to JSP file to edit properties of this authentication module or null if authentication module has no properties
-
tryFindSuitableConnection
@Nullable public OAuthConnectionDescriptor tryFindSuitableConnection()
-
getSuitableConnection
@NotNull public OAuthConnectionDescriptor getSuitableConnection()
-
registerUserProfilePageExtensions
protected ConnectOAuthAccountController registerUserProfilePageExtensions()
-
getUserIdPropertyKey
@NotNull public static AuthPropertyKey getUserIdPropertyKey(@NotNull OAuthProvider oAuthProvider)
-
getUsernamePropertyKey
@NotNull public static AuthPropertyKey getUsernamePropertyKey(@NotNull OAuthProvider oAuthProvider)
-
getConnectAccountController
@NotNull public BaseController getConnectAccountController()
-
getLoginController
@NotNull public BaseController getLoginController()
-
setUniqueRedirectService
@Autowired(required=false) public void setUniqueRedirectService(@NotNull UniqueRedirectService uniqueRedirectService)
-
-