DVA-C02 - Security (26% of the exam) - Section 2.4

Secure applications and APIs using bearer tokens such as JSON Web Tokens and OAuth, validated through API Gateway authorisers.

Secure APIs by validating JSON Web Tokens and OAuth 2.0 bearer tokens using Amazon API Gateway authorisers - either a Cognito user pool authoriser or a Lambda authoriser for custom token logic. Recognise the structure of Amazon Cognito tokens and how the authoriser caches policy decisions to reduce latency.

JSON Web TokenOAuth 2.0Amazon Cognito tokensAPI Gateway authorisers

Practice question for this objective

Free sampleSecuritymedium

A REST API on Amazon API Gateway must accept requests bearing JSON Web Tokens issued by an Amazon Cognito user pool. The team wants API Gateway to verify each token's signature and expiry and to authorise access by checking OAuth scopes in the token, with no custom code to write or maintain. Which authoriser should the team configure on the API methods?

  • AAn AWS Identity and Access Management authorisation type that signs each request with SigV4 so the caller proves its identity using IAM credentials.
  • BA Cognito user pool authoriser that validates the token against the configured user pool and authorises the method using the token's OAuth scopes. Correct
  • CA request-based Lambda authoriser that reads custom headers and returns an IAM policy, with the function calling the Cognito API to introspect the token on each request.
  • DA token-based Lambda authoriser whose function decodes the JSON Web Token and verifies the signature using a downloaded public key before returning a policy.
Use a Cognito user pool authoriser to validate user pool JSON Web Tokens and authorise by OAuth scope without writing custom code. An API Gateway Cognito user pool authoriser is purpose-built to verify the signature and expiry of identity or access tokens issued by a linked user pool and to authorise methods by comparing the token's OAuth scopes against the scopes configured on each method, so no Lambda code is needed.

Why A is wrong: IAM authorisation validates SigV4 signatures from IAM principals, not bearer JSON Web Tokens from a user pool, so it cannot check token signature, expiry, or OAuth scopes.

Why B is correct: A Cognito user pool authoriser natively verifies the JSON Web Token signature and expiry against the user pool and authorises by matching method scopes, requiring no custom code.

Why C is wrong: A Lambda authoriser could be coded to do this, but it forces the team to write and maintain validation code, which the requirement explicitly rules out.

Why D is wrong: A token Lambda authoriser can validate JSON Web Tokens but still requires the team to author and maintain the verification logic, which conflicts with the no-code requirement.

See more DVA-C02 practice questions, answers explained.

Exam traps in Security

Answers that look right on this material and are not. Each one is a distractor from a different question in the DVA-C02 bank for this domain.

  • An identity pool role mapping rule that writes the subscription tier into the user pool ID token before the token reaches the application client.

    Why it is wrong: Identity pool role mapping selects an IAM role from existing claims and runs after token issuance, so it cannot inject a new claim into the user pool token the way the requirement needs.

  • The ID token, because it carries the user's identity claims and the gateway reads those claims to grant resource access for the call.

    Why it is wrong: The ID token conveys authentication claims about the user for the client, but it does not carry the OAuth scopes the gateway uses for resource authorisation, so it is the wrong token here.

  • Send the token to the Cognito GetUser API on every request, because only that call can confirm the signature and the service should not cache anything between requests.

    Why it is wrong: GetUser returns user attributes for an access token but is a per-request network call that the requirement rules out, and it is not the way a service validates a token signature offline.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.