Git Product home page Git Product logo

duo_universal_java's Introduction

Duo Universal Prompt Java Client

Build Status Issues Forks Stars License

This library allows a web developer to quickly add Duo's interactive, self-service, two-factor authentication to any Java web login form.

See our developer documentation at http://www.duosecurity.com/docs/duoweb for guidance on integrating Duo 2FA into your web application.

What's here:

  • duo-universal-sdk - The Duo SDK for interacting with the Duo Universal Prompt
  • duo-example - An example web application with Duo integrated

Usage

This library requires Java 8 or later (tested through Java 16) and uses Maven to build the JAR files.

Run mvn package to generate a JAR with dependencies, suitable for inclusion in a web application.

The Duo Universal Client for Java is available from Duo Security on Maven. Include the following in your dependency definitions:

<!-- https://mvnrepository.com/artifact/com.duosecurity/duo-universal-sdk -->
<dependency>
    <groupId>com.duosecurity</groupId>
    <artifactId>duo-universal-sdk</artifactId>
    <version>1.1.3</version>
</dependency>

See https://mvnrepository.com/artifact/com.duosecurity/duo-universal-sdk/1.1.3 for more details.

TLS 1.2 and 1.3 Support

Duo_universal_java uses the Java cryptography libraries for TLS operations. Both TLS 1.2 and 1.3 are supported by Java 8 and later versions.

Demo

Build

From the root directory run:

mvn clean install

Run

In order to run this project, ensure the values in application.properties are filled out with the values from the Duo Admin Panel (clientId, clientSecret, api.host, and redirect.uri)

From the root of the duo-example project run the following to start the server: mvn spring-boot:run

Navigate to http://localhost:8080 to see a mock user login form. Enter a Duo username and any password to initiate Duo 2FA.

Testing

From the root directory run:

mvn test

Linting

From the root directory run:

mvn checkstyle:check

Support

Please report any bugs, feature requests, or issues to us directly at [email protected].

Thank you for using Duo!

http://www.duosecurity.com/

duo_universal_java's People

Contributors

aaronatduo avatar eosmith avatar jeffreyparker avatar levbernstein avatar yizshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duo_universal_java's Issues

fasterxml.jackson-core 2.3.2 dependency

Hi, im having this issue when trying to call duoClient.exchangeAuthorizationCodeFor2FAResult
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readerFor(Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/ObjectReader;

Googling i found that the readerFor method was introduced in version 2.6 of fasterxml

Is there a way to update the fasterxml dependency or am i going in the wrong way?
Thnx

duo-example Success Shows Login Screen

Just tried duo-example and it looks like it works but then it just shows me the login screen like this:

image

From glancing at the code it looks like it's supposed to dump token data.

Am I doing something wrong or what?

Upgrade OkHttp dependency to 4.3+

The current version of duo_universal_java (1.1.3) is using OkHttp 3.14.9 under the hood. This version of OkHttp has a known issue with Tomcat applications where its internal thread pool cannot be shut down cleanly because it does not provide an API to signal OkHttp to shut them down. This was supposedly fixed in version 4.3.

We have been mandated to Duo as our corporate MFA solution, which we have successfully implemented and deployed to production. However, we are now seeing evidence of the OkHttp thread pool issue in our server logs:

03-Aug-2023 06:38:26.643 WARNING [Thread-290707] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [XXXXXXX] appears to have started a thread named [OkHttp ConnectionPool] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 [email protected]/java.lang.Object.wait(Native Method)
 [email protected]/java.lang.Object.wait(Object.java:462)
 okhttp3.internal.connection.RealConnectionPool.lambda$new$0(RealConnectionPool.java:62)
 okhttp3.internal.connection.RealConnectionPool$$Lambda$1771/0x00000008002bd440.run(Unknown Source)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [email protected]/java.lang.Thread.run(Thread.java:829)

This isn't causing any critical issues for our apps, but it is a nuisance when we need to shutdown or restart an app.

Please investigate updating the OkHttp dependency to 4.3 or later to resolve this issue.

Reasons for use_duo_code_attribute

Why does the client now default to use_duo_code_attribute=true and hence the authorisation code parameter becomes duo_code over the previous OAuth2.0 standard code name?

Dependency version conflict

In v1.1.3 the okhttp3 logging-interceptor changed to v4.9.1 which depends on okhttp v4.9.1. However, retrofit v2.9.0 is still at okhttp v3.14.9. It seems to all work, but maybe the logging-interceptor should be held back a version?

Http Proxy support?

Hello,

how can I get support for http proxy?
I did not find another way than having code changes in the sdk modul to get OkHttp to use proxy.

Thank you

Benjamin

Please help fix, unknown bad request

Hello, I'm facing trouble of Bad Request while exchanging the authorization code to token one.
I have reproduced this problem by changing time on my local machine.

Could be something wrong in time while signing of token ?

thanks

Your prompt reply would be appreciated

Possible NPE in exchangeAuthorizationCodeFor2FAResult

Line 338 of the Client class e.g.

String idToken = response.getId_token();

Causes an NPE if (in the unlikely event) the auth code is invalid or not present. The Token endpoint correctly returns an HTTP 400, so I think the logic just needs to check the response is actually present and correct before trying to access the id_token.

duo.redirect.uri =?

Hi ,
Wat value should i give duo.redirect.uri =? here as i am not able to find this field value

Remove dependency on Lombok

Detailed Description

Ideally this SDK would be as lightweight (i.e. dependency-free) as possible. The Lombok dependency does make the data structures a little cleaner but might not be worth it overall

Use Case

Remove dependencies that are not absolutely critical to the SDK operation.

Workarounds

N/A

Possible Problems

If we hand-create the getters and setters that Lombok was generating for us, we need to either
A) make sure we name them exactly the same
or, if we change the names
B) update the callers as well AND remember that people may be making calls from their own code - thus this could be a backwards-incompatible change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.