Quick revision
The short answer
I would standardise on OAuth2 and OpenID Connect, with every service acting as a resource server that validates JWT access tokens. A small Dropwizard auth bundle and a Spring Security configuration module implement the same rules (issuer, audience, expiry, clock skew, scope and role mapping), proven by one shared test suite that runs the same tokens against both. Service-to-service tokens and token exchange are defined centrally, and coarse checks can move to a gateway while fine-grained authorisation stays in each service.
What to remember
In this answer, we designed one authentication approach for two stacks. Every service is an OAuth2 resource server that validates JWT access tokens with the same issuer, audience, expiry and clock skew rules. A Dropwizard bundle and a Spring Security module implement those rules, sharing one claim-mapping method, and a conformance suite runs the same tokens against both. Service-to-service tokens and token exchange are central policy, the gateway handles coarse checks, and fine-grained authorisation stays in each service.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would standardise on OAuth2 and OpenID Connect, with every service acting as a resource server that validates JWT access tokens. A small Dropwizard auth bundle and a Spring Security configuration module implement the same rules (issuer, audience, expiry, clock skew, scope and role mapping), proven by one shared test suite that runs the same tokens against both. Service-to-service tokens and token exchange are defined centrally, and coarse checks can move to a gateway while fine-grained authorisation stays in each service.
Why this question is asked
When two stacks implement authentication separately, they drift: one accepts tokens for the wrong audience, another treats roles case-sensitively, and a third allows ten minutes of clock skew. Attackers look for exactly that kind of weakest service. Interviewers ask this design question to see whether we can make two different frameworks behave identically and prove it. In this answer, we will set the common standard, build the Dropwizard and Spring modules, map scopes and roles the same way, test both with the same tokens, and decide what belongs centrally and what stays in the service.
1The Common Standard: Services as Resource Servers
In OAuth2 terms, a resource server is a service that holds data and accepts access tokens. It does not sign anybody in; it only checks the token that comes with each request. OpenID Connect (OIDC) adds a standard way to discover the identity provider's settings, including its issuer name and the JWKS URL with its public keys.
The standard we choose is simple to state: every service, whatever its framework, accepts only JWT access tokens from our identity provider and checks the same five things. The signature must verify with a current key from the JWKS. The issuer (iss) must equal our provider's issuer. The audience (aud) must contain this service's name, so a token minted for the billing service cannot be replayed against payroll. The expiry (exp) and not-before (nbf) times must hold, with at most 60 seconds of clock skew. And the token must carry the scopes or roles the endpoint needs.
2One Rule Set, Two Implementations
The platform team publishes two small modules from one repository. In Spring Boot, most of this is configuration on top of Spring Security's resource server support. In Dropwizard, we write a bundle around a JWT authenticator.
Notice that the clever part, PlatformClaims.authorities, is shared code. Both modules call the same plain Java method to turn token claims into a set of permissions, so the mapping cannot drift. Spring Security's JwtTimestampValidator allows 60 seconds of skew by default, and the Dropwizard bundle is configured to the same 60 seconds, so a token expiring at a boundary is accepted or refused identically.
3Mapping Scopes and Roles the Same Way
Scopes describe what a client application may do, such as orders:read. Roles describe what a person is, such as support-agent. Providers put them in different claims: scopes in scope or scp, roles often in a provider-specific claim such as realm_access.roles. If each service parses these on its own, small differences appear: one splits scopes on spaces, another on commas, one upper-cases roles, another does not.
So the shared mapping defines one internal vocabulary: scope orders:read becomes the permission SCOPE_orders:read, and role support-agent becomes ROLE_support-agent, case preserved. Spring code then writes hasAuthority("SCOPE_orders:read"), and Dropwizard code writes @RolesAllowed("SCOPE_orders:read"), because our Dropwizard Authorizer simply checks membership in the same set.
| Check or claim | Rule | Spring Boot | Dropwizard |
|---|---|---|---|
| Signature | RS256 or ES256, key from JWKS | NimbusJwtDecoder | JwtAuthenticator, cached JWKS |
| iss | equals our issuer | issuer-uri | auth.issuer |
| aud | contains service name | audiences | auth.audience |
| exp, nbf | 60 s clock skew | JwtTimestampValidator | auth.clockSkew |
| scope | -> SCOPE_x | PlatformClaims.authorities | PlatformClaims.authorities |
| roles | -> ROLE_x, case kept | PlatformClaims.authorities | PlatformClaims.authorities |
4Proving It With Shared Tests and Shared Tokens
Agreeing on rules is not enough; we must prove both modules follow them. The platform repository contains a conformance suite: a set of tokens signed with a test key, each with an expected outcome. One is valid, one is expired by 61 seconds, one is expired by 59 seconds, one has the wrong audience, one the wrong issuer, one is signed with an unknown key, one uses alg none, and several carry different scope and role combinations.
A tiny reference service is built in each stack with an endpoint per permission. The suite starts both, sends every token to every endpoint, and compares the status codes with the expected table: 200, 401 or 403. Each module's build runs the suite, and every service template includes a smaller version of it. When someone changes a rule, the test changes in one place and both stacks must pass it.
5What Belongs Centrally and What Stays in the Service
Some policies should not be decided service by service. Service-to-service calls use the client credentials grant, where a service obtains its own token with its own identity. When a service calls another on behalf of a user, it uses token exchange (RFC 8693) to get a new token with the right audience, instead of forwarding the user's token everywhere. The platform defines these flows, which audiences exist, and the lifetimes of tokens.
A gateway or a service mesh can also do coarse checks at the edge: is there a valid token at all, is its audience one of our services, is the client within its rate limit. That stops junk traffic early. But the gateway does not know that alice may read only her own orders. Fine-grained authorisation, which depends on data the service owns, stays in the service. And services keep validating tokens themselves, because traffic inside the network should not be trusted just because it got past the edge.
6Follow-up questions
Why not let the gateway validate tokens and pass a plain user id header to services?
Because any process that can reach the service inside the network could then send that header and become any user. It also hides the scopes and audience from the service, so fine-grained checks become guesswork. Forwarding the original token, or an exchanged token, and validating it again costs well under a millisecond with cached keys, which is a small price for not trusting the network.
How do you roll out the new modules to services that already have custom authentication?
Service by service, with an accept-both period. The new module runs alongside the old authenticator, both decide, and mismatches are logged without changing the answer. When the logs show no unexpected differences for a week, the old path is switched off. Clients are moved to the new tokens in parallel, and the conformance suite is added to each service's build at the same time.
What about Spring Boot services that use method security and Dropwizard services that use @RolesAllowed?
That is fine as long as both read the same authority names. Spring's @PreAuthorize("hasAuthority('SCOPE_orders:read')") and Jersey's @RolesAllowed("SCOPE_orders:read") then express the same rule. The documentation lists each endpoint's required permission, and the conformance tests check a few representative endpoints in every service.
7Conclusion
In this answer, we designed one authentication approach for two stacks. Every service is an OAuth2 resource server that validates JWT access tokens with the same issuer, audience, expiry and clock skew rules. A Dropwizard bundle and a Spring Security module implement those rules, sharing one claim-mapping method, and a conformance suite runs the same tokens against both. Service-to-service tokens and token exchange are central policy, the gateway handles coarse checks, and fine-grained authorisation stays in each service.
Open with
I'd make the identity provider and the token format the standard, not the framework. Every service becomes an OAuth2 resource server that accepts JWT access tokens and checks the same things: signature against the JWKS, issuer, audience containing the service's own name, expiry with 60 seconds of clock skew, and the required scopes or roles.
Then, if they want more
Then the platform team ships two adapters from one repository: a Spring Boot starter that configures Spring Security's resource server support, and a Dropwizard bundle that registers a JWT authenticator, the @Auth binder and RolesAllowedDynamicFeature. Both call the same plain Java method to map claims to permissions, like SCOPE_orders:read and ROLE_support-agent, so the mapping can't drift.
To prove they behave the same, we keep a conformance suite of signed test tokens, valid, expired, wrong audience, unknown key, different scopes, and run it against a reference service in each stack, expecting identical 200, 401 and 403 answers. Service-to-service calls use client credentials, delegation uses token exchange, both defined centrally.
A gateway can do coarse checks at the edge, but fine-grained rules like 'only your own orders' stay in the service, and services still validate tokens themselves.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your Dropwizard and Spring Boot services each implement authentication differently....": https://scrivio-interview-library.netlify.app/java/dropwizard/0f42b6f819/