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 boolean
DEFAULT_ALLOW_CREATING_NEW_USERS_BY_LOGIN
protected static Logger
LOGGER
protected String
myAccessTokenControllerPath
protected AuthenticationContext
myContext
protected String
myDefaultScope
protected OAuthFlow
myOAuthFlow
protected OAuthProvider
myOAuthProvider
protected UniqueRedirectService
myUniqueRedirectService
-
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 void
afterNewUserCreated(SUser createdUser, OAuthConnectionDescriptor connection, String accessToken)
String
describeProperties(Map<String,String> properties)
Returns description of the specified properties map to be shown in UIBaseController
getConnectAccountController()
Map<String,String>
getDefaultProperties()
String
getDescription()
Returns description of the authentication module to show in the UIString
getDisplayName()
Returns name of the authentication module to show in the UIString
getEditPropertiesJspFilePath()
BaseController
getLoginController()
String
getName()
protected String
getRedirectPath(OAuthConnectionDescriptor connection)
protected String
getRedirectUri(OAuthConnectionDescriptor connection)
String
getRestrictingOptions(Map<String,String> properties)
OAuthConnectionDescriptor
getSuitableConnection()
static AuthPropertyKey
getUserIdPropertyKey(OAuthProvider oAuthProvider)
static AuthPropertyKey
getUsernamePropertyKey(OAuthProvider oAuthProvider)
String
getUserRedirect(javax.servlet.http.HttpServletRequest request)
void
init()
protected boolean
isMatchingUniqueRedirectPath(String requestUrl)
boolean
isMultipleInstancesAllowed()
protected boolean
isValidRedirectUrl(String requestUrl, String connectionId)
protected String
performAuthChecks(OAuthFlow.OAuthResult oAuthResult, Map<String,String> properties, OAuthConnectionDescriptor connection)
protected String
prepareBackRedirectErrorMessage(String error, String errorDescr)
HttpAuthenticationResult
processAuthenticationRequest(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 ConnectOAuthAccountController
registerUserProfilePageExtensions()
protected abstract void
rememberToken(javax.servlet.http.HttpServletRequest request, SUser created, OAuthConnectionDescriptor oAuthConnectionDescriptor, OAuthFlow.OAuthResult oAuthResult)
void
setUniqueRedirectService(UniqueRedirectService uniqueRedirectService)
boolean
shouldSkip2FA(javax.servlet.http.HttpServletRequest request, Map<String,String> properties)
Returns whether two-factor authentication should be skipped when this scheme is used.OAuthConnectionDescriptor
tryFindSuitableConnection()
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:HttpAuthenticationScheme
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().- Specified by:
processAuthenticationRequest
in 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:HttpAuthenticationScheme
Returns whether two-factor authentication should be skipped when this scheme is used.- Specified by:
shouldSkip2FA
in 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:
getName
in interfaceAuthModuleType
- Returns:
- unique identificator (case-insensitive)
-
getDisplayName
@NotNull public String getDisplayName()
Description copied from interface:AuthModuleType
Returns name of the authentication module to show in the UI- Specified by:
getDisplayName
in interfaceAuthModuleType
- Returns:
- name of the authentication module to show in the UI
-
getDescription
@NotNull public String getDescription()
Description copied from interface:AuthModuleType
Returns description of the authentication module to show in the UI- Specified by:
getDescription
in interfaceAuthModuleType
- Returns:
- description of the authentication module to show in the UI
-
isMultipleInstancesAllowed
public boolean isMultipleInstancesAllowed()
- Specified by:
isMultipleInstancesAllowed
in interfaceAuthModuleType
- Returns:
- true, if multiple instances of this authentication module are allowed, false otherwise
-
getDefaultProperties
@NotNull public Map<String,String> getDefaultProperties()
- Specified by:
getDefaultProperties
in interfaceAuthModuleType
- Returns:
- default properties for this authentication module
-
describeProperties
@NotNull public String describeProperties(@NotNull Map<String,String> properties)
Description copied from interface:AuthModuleType
Returns description of the specified properties map to be shown in UI- Specified by:
describeProperties
in 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:AuthModuleType
Validates the current login module settings and returns the set of errors if found. Should returnnull
if no errors found.- Specified by:
validate
in 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:
getEditPropertiesJspFilePath
in 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)
-
-