-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAuth2 Implementation #15
base: develop
Are you sure you want to change the base?
Conversation
pom.xml
Outdated
@@ -20,7 +20,7 @@ | |||
|
|||
<groupId>io.cdap.plugin.successfactors</groupId> | |||
<artifactId>successfactors-plugins</artifactId> | |||
<version>1.2.0-SNAPSHOT</version> | |||
<version>1.2.1-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets bump it to v1.3.0-SNAPSHOT
as we are adding new feature support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually this change is committed in PRs, reverted back
pom.xml
Outdated
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.13</version> <!-- Use the latest version available --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make use of properties and remove the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the properties for other dependencies also plus please remove the comments i.e.
<!-- Use the latest version available -->
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
src/main/java/io/cdap/plugin/successfactors/source/transport/SuccessFactorsTransporter.java
Outdated
Show resolved
Hide resolved
src/main/java/io/cdap/plugin/successfactors/source/transport/SuccessFactorsTransporter.java
Outdated
Show resolved
Hide resolved
src/test/java/io/cdap/plugin/successfactors/source/input/SuccessFactorsInputFormatTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/cdap/plugin/successfactors/source/transport/SuccessFactorsUrlContainerTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/cdap/plugin/successfactors/source/transport/SuccessFactorsUrlContainerTest.java
Outdated
Show resolved
Hide resolved
3863117
to
a8b0b98
Compare
docs/SuccessFactors-batchsource.md
Outdated
@@ -19,8 +19,21 @@ annotating metadata, etc. | |||
**Use Connection:** Whether to use a connection. If a connection is used, you do not need to provide the credentials. | |||
**Connection:** Name of the connection to use. Entity Names information will be provided by the connection. | |||
You also can use the macro function ${conn(connection-name)}. | |||
**Authentication Type:** Type of authentication used to submit request. OAuth2, Basic Authentication types are available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite it to: Authentication type used to submit request. Supported types are Basic & OAuth 2.0. Default is Basic Authentication.
pom.xml
Outdated
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.13</version> <!-- Use the latest version available --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the properties for other dependencies also plus please remove the comments i.e.
<!-- Use the latest version available -->
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
public static final String TEST = "TEST"; | ||
private static final String COMMON_ACTION = ResourceConstants.ERR_MISSING_PARAM_OR_MACRO_ACTION.getMsgForKey(); | ||
private static final String SAP_SUCCESSFACTORS_USERNAME = "SAP SuccessFactors Username"; | ||
private static final String SAP_SUCCESSFACTORS_PASSWORD = "SAP SuccessFactors Password"; | ||
private static final String SAP_SUCCESSFACTORS_BASE_URL = "SAP SuccessFactors Base URL"; | ||
private static final Logger LOG = LoggerFactory.getLogger(SuccessFactorsConnectorConfig.class); | ||
|
||
@Name(PROPERTY_AUTH_TYPE) | ||
@Description("Type of authentication used to submit request. \n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: \n
can be removed.
public static final String TEST = "TEST"; | ||
private static final String COMMON_ACTION = ResourceConstants.ERR_MISSING_PARAM_OR_MACRO_ACTION.getMsgForKey(); | ||
private static final String SAP_SUCCESSFACTORS_USERNAME = "SAP SuccessFactors Username"; | ||
private static final String SAP_SUCCESSFACTORS_PASSWORD = "SAP SuccessFactors Password"; | ||
private static final String SAP_SUCCESSFACTORS_BASE_URL = "SAP SuccessFactors Base URL"; | ||
private static final Logger LOG = LoggerFactory.getLogger(SuccessFactorsConnectorConfig.class); | ||
|
||
@Name(PROPERTY_AUTH_TYPE) | ||
@Description("Type of authentication used to submit request. \n" + | ||
"OAuth2, Basic Authentication types are available.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets be consistent with OAuth 2.0
in the descriptions.
} | ||
|
||
if (authType.equals(BASIC_AUTH)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the extra line.
if (SuccessFactorsUtil.isNullOrEmpty(getPassword()) && !containsMacro(PASSWORD)) { | ||
String errMsg = ResourceConstants.ERR_MISSING_PARAM_PREFIX.getMsgForKey(SAP_SUCCESSFACTORS_PASSWORD); | ||
failureCollector.addFailure(errMsg, COMMON_ACTION).withConfigProperty(PASSWORD); | ||
} | ||
|
||
} | ||
if (authType.equals(OAUTH2)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formating..
Request req = buildRequest(endpoint, mediaType); | ||
|
||
Request req = null; | ||
if (config.getAuthType().equals("basicAuth")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the constant declared in the SuccessFactorsConnectorConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These updates are also required in SuccessFactors-connector.md
} | ||
|
||
return assertion; | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid catching generic exceptions.
return accessToken; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just keep 1 new line and remove any extra lines.
}, | ||
{ | ||
"id": "oAuth2", | ||
"label": "OAuth2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth 2.0
}, | ||
{ | ||
"id": "oAuth2", | ||
"label": "OAuth2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth 2.0
37869a0
to
4083f5d
Compare
ed6fb11
to
6989161
Compare
Implement Oauth 2.0 support in SAP Successfactors Batch Source Plugin. SAP SuccessFactors supports OAuth 2.0 to authenticate OData API and SFAPI users. Compared with HTTP Basic Auth, OAuth 2.0 is considered to be more secure in that it doesn't require users to provide their passwords during authentication. With OAuth 2.0, you can also use a third-party identity provider (IDP) for user management and provisioning.