[java-idp-plugin-duo] branch master updated: JDUO-11 - Changes to support Duo SDK 1.0.3-SNAPSHOT
Phil Smart
philip.smart at jisc.ac.uk
Tue Aug 4 16:33:00 UTC 2020
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch master
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=010eca6669c16ad0f5004120ed9caff83d672e62
The following commit(s) were added to refs/heads/master by this push:
new 010eca6 JDUO-11 - Changes to support Duo SDK 1.0.3-SNAPSHOT
010eca6 is described below
commit 010eca6669c16ad0f5004120ed9caff83d672e62
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Aug 4 17:32:47 2020 +0100
JDUO-11 - Changes to support Duo SDK 1.0.3-SNAPSHOT
https://issues.shibboleth.net/jira/browse/JDUO-11
---
.../net/shbboleth/idp/plugin/authn/duo/DuoOIDCClient.java | 6 ++++--
.../idp/plugin/authn/duo/impl/ExchangeCodeForDuoToken.java | 11 ++++++++---
.../idp/plugin/authn/mock/MockDuoOIDCClient_FAIL.java | 3 ++-
.../idp/plugin/authn/mock/MockDuoOIDCClient_OK.java | 3 ++-
.../idp/plugin/authn/mock/MockDuoOIDCClient_UNKNOWN.java | 3 ++-
.../idp/plugin/authn/duo/sdk/impl/DuoSDKClientAdaptor.java | 5 +++--
pom.xml | 2 +-
7 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/DuoOIDCClient.java b/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/DuoOIDCClient.java
index 0733fb8..be384ab 100644
--- a/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/DuoOIDCClient.java
+++ b/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/DuoOIDCClient.java
@@ -46,7 +46,7 @@ public interface DuoOIDCClient {
*
* @throws DuoClientException if there is an error creating the authentication URL.
*/
- @Nonnull String createAuthUrl(String username, String state) throws DuoClientException;
+ @Nonnull String createAuthUrl(@Nonnull final String username, @Nonnull final String state) throws DuoClientException;
/**
* Verifies the code returned by Duo and exchanges it for a token which contains information pertaining to
@@ -55,11 +55,13 @@ public interface DuoOIDCClient {
* @param code An authentication identifier which is exchanged (per OAuth2.0 spec) with Duo for a token.
* the token can be used to determine if authentication was successful as well as obtain meta-data
* about the authentication.
+ * @param username The user to be authenticated by Duo.
*
* @return the token
*
* @throws DuoClientException if there is an error exchaining the auth_code for a token result.
*/
- @Nonnull DuoAuthToken exchangeAuthorizationCodeFor2FAResult(String code) throws DuoClientException;
+ @Nonnull DuoAuthToken exchangeAuthorizationCodeFor2FAResult(@Nonnull final String code,
+ @Nonnull final String username) throws DuoClientException;
}
diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/ExchangeCodeForDuoToken.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/ExchangeCodeForDuoToken.java
index 5834efc..627f9c6 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/ExchangeCodeForDuoToken.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/ExchangeCodeForDuoToken.java
@@ -61,17 +61,22 @@ public class ExchangeCodeForDuoToken extends AbstractDuoAuthenticationAction{
return;
}
- final String code = duoContext.getAuthorizationCode();
-
+ final String code = duoContext.getAuthorizationCode();
if (code == null) {
log.error("{} Duo 2FA authorization code is not available in the response",getLogPrefix());
//FIXME: maybe our own exception and switch in the flow here.
ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.AUTHN_EXCEPTION);
return;
}
+ final String username = duoContext.getUsername();
+ if (username == null) {
+ log.error("{} Username is not available in the Duo context",getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.AUTHN_EXCEPTION);
+ return;
+ }
try {
- final DuoAuthToken token = client.exchangeAuthorizationCodeFor2FAResult(code);
+ final DuoAuthToken token = client.exchangeAuthorizationCodeFor2FAResult(code,username);
log.info("{} Duo 2FA token received for subject '{}'",getLogPrefix(),token.getSub());
duoContext.setAuthToken(token);
//success
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_FAIL.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_FAIL.java
index 36fd7e7..43bc840 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_FAIL.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_FAIL.java
@@ -68,7 +68,8 @@ public class MockDuoOIDCClient_FAIL implements DuoOIDCClient{
}
@Override
- public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code) throws DuoClientException {
+ public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code,
+ final String username) throws DuoClientException {
return DuoAuthToken.builder()
.withIss("https://api.duosecurity.com/oauth/v1/token")
.withSub(SUB)
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_OK.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_OK.java
index 57bbbd3..ac65ddd 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_OK.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_OK.java
@@ -65,7 +65,8 @@ public class MockDuoOIDCClient_OK implements DuoOIDCClient{
}
@Override
- public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code) throws DuoClientException {
+ public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code,
+ final String username) throws DuoClientException {
return DuoAuthToken.builder()
.withIss("https://api.duosecurity.com/oauth/v1/token")
.withSub(SUB)
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_UNKNOWN.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_UNKNOWN.java
index fc10a6d..445a68a 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_UNKNOWN.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/mock/MockDuoOIDCClient_UNKNOWN.java
@@ -65,7 +65,8 @@ public class MockDuoOIDCClient_UNKNOWN implements DuoOIDCClient{
}
@Override
- public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code) throws DuoClientException {
+ public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(final String code,
+ final String username) throws DuoClientException {
return DuoAuthToken.builder()
.withIss("https://api.duosecurity.com/oauth/v1/token")
.withSub(SUB)
diff --git a/idp-duo-native-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientAdaptor.java b/idp-duo-native-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientAdaptor.java
index 7184b18..7b02d8d 100644
--- a/idp-duo-native-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientAdaptor.java
+++ b/idp-duo-native-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/sdk/impl/DuoSDKClientAdaptor.java
@@ -110,10 +110,11 @@ final class DuoSDKClientAdaptor implements DuoOIDCClient{
}
@Override
- @Nonnull public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(@Nonnull final String code)
+ @Nonnull public DuoAuthToken exchangeAuthorizationCodeFor2FAResult(@Nonnull final String code,
+ @Nonnull final String username)
throws DuoClientException {
try {
- final Token token = client.exchangeAuthorizationCodeFor2FAResult(code);
+ final Token token = client.exchangeAuthorizationCodeFor2FAResult(code,username);
if (token == null) {
throw new DuoClientException("Duo token was null");
}
diff --git a/pom.xml b/pom.xml
index 5b24d81..98e0fce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<properties>
<idp.groupId>net.shibboleth.idp</idp.groupId>
<idp.version>4.1.0-SNAPSHOT</idp.version>
- <duo.client.version>1.0-SNAPSHOT</duo.client.version>
+ <duo.client.version>1.0.3-SNAPSHOT</duo.client.version>
<checkstyle.configLocation>${project.basedir}/checkstyle.xml</checkstyle.configLocation>
</properties>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list