Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ To install this plug-in, either download a binary version available from the `re

The JAR file needs to be deployed to each run-time node and the admin node. For simple test deployments where the admin node is a run-time node, the JAR file only needs to be copied to one location.

The following dependent JAR file must be in the same directory, the plugin group directory:

- `scribejava-core-7.1.1.jar <https://repo1.maven.org/maven2/com/github/scribejava/scribejava-core/7.1.1/scribejava-core-7.1.1.jar>`_

After running ``mvn package``, this will be placed into the ``target/libs`` directory and can be copied from there to the plugin group directory.
This plug-in has no third-party runtime dependencies; it only requires the Curity Identity Server SDK, which is provided by the server at runtime. After running ``mvn package``, the plug-in JAR is placed into the ``target/libs`` directory and can be copied from there to the plugin group directory.

For a more detailed explanation of installing plug-ins, refer to the `Curity developer guide <https://developer.curity.io/docs/latest/developer-guide/plugins/index.html#plugin-installation>`_.

Expand Down
19 changes: 0 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,6 @@
<version>1.7.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-core</artifactId>
<version>7.1.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

package io.curity.identityserver.plugin.twitter.authentication;

import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.model.OAuth1AccessToken;
import com.github.scribejava.core.model.OAuth1RequestToken;
import com.github.scribejava.core.oauth.OAuth10aService;
import io.curity.identityserver.plugin.twitter.config.TwitterAuthenticatorPluginConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,34 +26,29 @@
import se.curity.identityserver.sdk.attribute.SubjectAttributes;
import se.curity.identityserver.sdk.authentication.AuthenticationResult;
import se.curity.identityserver.sdk.authentication.AuthenticatorRequestHandler;
import se.curity.identityserver.sdk.errors.ErrorCode;
import se.curity.identityserver.sdk.service.ExceptionFactory;
import se.curity.identityserver.sdk.service.SessionManager;
import se.curity.identityserver.sdk.service.authentication.AuthenticatorInformationProvider;
import se.curity.identityserver.sdk.web.Request;
import se.curity.identityserver.sdk.web.Response;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Objects;
import java.util.Optional;

import static io.curity.identityserver.plugin.twitter.authentication.Constants.OAUTH_TOKEN;
import static io.curity.identityserver.plugin.twitter.authentication.Constants.OAUTH_TOKEN_SECRET;
import static io.curity.identityserver.plugin.twitter.authentication.Constants.SCREEN_NAME;
import static io.curity.identityserver.plugin.twitter.authentication.Constants.USER_ID;
import static io.curity.identityserver.plugin.twitter.authentication.HttpClientUtil.getHttpClient;
import static io.curity.identityserver.plugin.twitter.descriptor.TwitterAuthenticatorPluginDescriptor.CALLBACK;

public final class CallbackRequestHandler
implements AuthenticatorRequestHandler<CallbackGetRequestModel>
{
private static final Logger _logger = LoggerFactory.getLogger(CallbackRequestHandler.class);

private final ExceptionFactory _exceptionFactory;
private final OAuth10aService _service;
private final OAuth1RequestToken _requestToken;
private final TwitterOAuthClient _client;
private final String _requestToken;
private final String _requestTokenSecret;
private final AuthenticatorInformationProvider _authenticatorInformationProvider;

public CallbackRequestHandler(TwitterAuthenticatorPluginConfig _config)
Expand All @@ -66,13 +57,9 @@ public CallbackRequestHandler(TwitterAuthenticatorPluginConfig _config)

_exceptionFactory = _config.getExceptionFactory();
_authenticatorInformationProvider = _config.getAuthenticatorInformationProvider();
_service = new ServiceBuilder(_config.getApiKey())
.apiSecret(_config.getApiSecretKey())
.callback(createRedirectUri())
.httpClient(getHttpClient(_config))
.build(TwitterApi.instance());
_requestToken = new OAuth1RequestToken(_config.getSessionManager().get(OAUTH_TOKEN).getValue().toString(),
sessionManager.get(OAUTH_TOKEN_SECRET).getValue().toString());
_client = new TwitterOAuthClient(_config);
_requestToken = sessionManager.get(OAUTH_TOKEN).getValue().toString();
_requestTokenSecret = sessionManager.get(OAUTH_TOKEN_SECRET).getValue().toString();
}

@Override
Expand All @@ -94,11 +81,11 @@ public Optional<AuthenticationResult> get(CallbackGetRequestModel requestModel,
{
handleError(requestModel); // Side-effect: Throws if error

OAuth1AccessToken accessToken;
TwitterOAuthClient.OAuthToken accessToken;

try
{
accessToken = _service.getAccessToken(_requestToken, requestModel.getOAuthVerifier());
accessToken = _client.getAccessToken(_requestToken, _requestTokenSecret, requestModel.getOAuthVerifier());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -142,21 +129,6 @@ private void handleError(CallbackGetRequestModel requestModel)
}
}

private String createRedirectUri()
{
try
{
URI authUri = _authenticatorInformationProvider.getFullyQualifiedAuthenticationUri();

return new URL(authUri.toURL(), authUri.getPath() + "/" + CALLBACK).toString();
}
catch (MalformedURLException e)
{
throw _exceptionFactory.internalServerException(ErrorCode.INVALID_REDIRECT_URI,
"Could not create redirect URI");
}
}

@Override
public Optional<AuthenticationResult> post(CallbackGetRequestModel requestModel, Response response)
{
Expand Down

This file was deleted.

Loading