Package com.irurueta.authserver.authorization.api.web.ott


package com.irurueta.authserver.authorization.api.web.ott
One-time token authentication: e-mail and SMS codes and magic links as a primary sign-in method and as a second factor, the per-channel factors, the rate limits, the providers and filters, and the phone management API and account page. The development-only SMS inbox lives here too.
  • Class
    Description
    Development only (dev profile): opens the SMS inbox page to everybody in the login chain, so an end-to-end test can read the codes the logging sender recorded without signing in.
    Development only (dev profile): renders the SMS messages the logging sender recorded instead of sending them, so a developer or an end-to-end test can read the code of a sign-in or of a phone enrolment.
    The verification code of a phone number is wrong, has expired or there is no verification in progress.
    The user name a magic link token is stored with.
    Reads what is posted to POST /login/ott: the token field holds either the token of a magic link (a UUID, which OttLinkAuthenticationProvider consumes) or the numeric code of an e-mail or SMS, which is tied to the identifier and the binding id the session of the browser holds.
    Sends the browser back after a failed submission to POST /login/ott: a wrong numeric code goes to the page where it is typed (/login/ott?error), so the user can try again, and a magic link that is not valid goes to the sign-in page (/login?error).
    Forgets the pending token of the session once it was used, then lets the delegate resume the request the sign-in interrupted.
    Adds the one-time token methods to the login/UI chain through http.oneTimeTokenLogin(...): the request of a token (POST /ott/generate), the submission of a magic link token or a numeric code (POST /login/ott) and, as a second factor, the submission of a code (POST /login/second-factor/ott).
    Hands the session authentication strategy of the chain to the second-factor filter.
    Scheduled entry point that deletes what one-time tokens leave behind once it expired: the numeric codes, the pending phone verifications, the SMS cost ledger entries past their retention and Spring's expired link tokens.
    Signs a user in with a numeric one-time code, delivered by e-mail or SMS, through VerifyOneTimeCodeUseCase.
    Request to sign in with a numeric one-time code: the code the user typed, the identifier it was requested for and the binding id of the session that requested it.
    Wires the one-time token methods into the login/UI chain.
    Delivers the one-time tokens the use cases asked for, once the transaction that stored them has committed (TransactionPhase.AFTER_COMMIT; an event published outside a transaction is delivered at once) and off the request thread (@Async, on Spring Boot's applicationTaskExecutor).
    Translates the failures of the phone endpoints to RFC 9457 problem details, answered as application/problem+json.
    Registers the one-time token methods as authentication factors.
    Resolves the request of POST /ott/generate to the token Spring's filter asks the token service for.
    What a request to POST /ott/generate asks for, read from its form fields: through which channel, a numeric code or a magic link, and for a sign-in or as a second factor.
    Delivers the token Spring's filter just generated, and answers every request the same way.
    Confirms a magic link: consumes the token Spring's JdbcOneTimeTokenService stored and signs the user in with it.
    Builds the magic link of a token.
    Contributes the one-time token sign-in to the login page: a form that asks for the identifier and whether to receive a code or a magic link by e-mail, or a code by SMS, and posts it to POST /ott/generate.
    Serves the two pages of the one-time token flow, as the contract apis/auth-server/web-pages/ auth-server-pages-v1.yaml describes them through the generated OneTimeTokenPageApi: the page where the code is entered (or that says to check the inbox when a magic link was requested) and the page a magic link opens, whose button posts the token.
    The authentication providers of the one-time token methods, held together.
    Rate limiter of the one-time token endpoints, on the pattern of the account endpoints' limiter: Bucket4j token buckets in Caffeine caches (FixedWindowBuckets).
    A client address or an identifier requested or submitted more one-time tokens than its window allows.
    Applies OttRateLimiter to the one-time token endpoints, which are Spring Security filters (so no controller advice sees their failures): POST /ott/generate counts as a token request and POST /login/ott and POST /login/second-factor/ott as submissions, each per client address and per identifier.
    Configuration of the rate limiting of the one-time token endpoints (authserver.ott.rate-limit.*): the requests for a token (POST /ott/generate, the phone enrolment) and the submissions of a token or a code (POST /login/ott, POST /login/second-factor/ott, the phone verification).
    Verifies a numeric one-time code, delivered by e-mail or SMS, as the second factor of the signed-in user through VerifyOneTimeCodeUseCase, which counts the failures against the second-factor lockout, locks after too many, clears the counter on success and records the security events: a locked second factor is rejected even for a correct code.
    Decides through which channels a one-time code or link may be the second factor of a signed-in user.
    Processes the post of the one-time code form of the second factor (POST /login/second-factor/ott), in the way TotpAuthenticationFilter processes the TOTP forms.
    Contributes the one-time token second factor to the second-factor page: the buttons that send a code or a magic link by e-mail and a code by SMS to the signed-in user, each posting to POST /ott/generate with the second-factor purpose.
    Request to verify a one-time code as a second factor: the authentication the user already holds (the primary factor), the code the user typed and the binding id of the session that requested it.
    The one-time token a browser has asked for and not used yet, kept in its session: for whom, through which channel, of which kind and for what purpose, and the binding id the numeric code was stored with.
    Shows, enrols, verifies and removes the phone number of the authenticated account, the number the SMS codes go to.
    Maps the results of the phone use cases onto the DTOs generated from the contract.
    The account has no verified phone number.
    Keeps the phone page and its form posts behind the multi-factor policy, as the passkeys page is: a session that only presented the password of an account that still has to complete its second factor is sent to the second-factor page instead of being able to change the phone that receives the codes.
    Serves the phone account page and the session-protected form posts it uses, as the contract apis/auth-server/web-pages/auth-server-pages-v1.yaml describes them through the generated PhonePageApi.
    The step-up rule of StepUpGuard for a browser session instead of a bearer token: while the account has a confirmed second factor, a sensitive change (removing the phone) needs a session that shows a multi-factor sign-in made within authserver.mfa.step-up-max-age; an account without a second factor cannot step up, so it is not asked to.
    Rules about the session a one-time token is used as a second factor in: it must already hold a primary factor, and the second factor must not be the very channel that signed the user in (an e-mail code after an e-mail sign-in would prove the same mailbox twice).