• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DataBiosphere / consent / #5848

05 May 2025 03:41PM UTC coverage: 78.738% (-0.03%) from 78.768%
#5848

push

web-flow
DT-1518: Populate AuthUser with full Consent User object (#2488)

97 of 116 new or added lines in 11 files covered. (83.62%)

10091 of 12816 relevant lines covered (78.74%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.33
/src/main/java/org/broadinstitute/consent/http/authentication/DuosUserAuthenticator.java
1
package org.broadinstitute.consent.http.authentication;
2

3
import io.dropwizard.auth.Authenticator;
4
import jakarta.ws.rs.NotFoundException;
5
import jakarta.ws.rs.ServerErrorException;
6
import java.util.Optional;
7
import org.broadinstitute.consent.http.models.AuthUser;
8
import org.broadinstitute.consent.http.models.DuosUser;
9
import org.broadinstitute.consent.http.models.User;
10
import org.broadinstitute.consent.http.util.ConsentLogger;
11

12
public class DuosUserAuthenticator implements Authenticator<String, DuosUser>, ConsentLogger {
13

14
  private final AuthorizationHelper authorizationHelper;
15

16
  public DuosUserAuthenticator(AuthorizationHelper authorizationHelper) {
1✔
17
    this.authorizationHelper = authorizationHelper;
1✔
18
  }
1✔
19

20
  @Override
21
  public Optional<DuosUser> authenticate(String bearer) {
22
    var headers = authorizationHelper.getCache().getIfPresent(bearer);
1✔
23
    if (headers != null) {
1✔
24
      AuthUser authUser = authorizationHelper.buildAuthUserFromHeaders(headers);
1✔
25
      if (authUser.getEmail() != null) {
1✔
26
        authUser.setUserStatusInfo(authorizationHelper.getUserStatusInfo(authUser));
1✔
27
        try {
28
          User duosUser = authorizationHelper.userService.findUserByEmail(authUser.getEmail());
1✔
29
          return Optional.of(new DuosUser(authUser, duosUser));
1✔
NEW
30
        } catch (NotFoundException e) {
×
NEW
31
          logWarn("User not found, authentication incomplete: %s".formatted(authUser.getEmail()));
×
32
        }
33
      }
34
      return Optional.empty();
1✔
35
    }
NEW
36
    logException(new ServerErrorException("Error reading request headers", 500));
×
NEW
37
    return Optional.empty();
×
38
  }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc