Skip to main content

FAPI-RW-ID2-ATTEMPT-AUTHORISATION-CODE-REUSE

NameVerifies the authorisation code expires within a period of time
CategoryINFOSEC
Execution MethodAUTOMATED (FAPI BASELINE)
Description

This test case combines two FAPI tests regarding the reuse of a previous authorisation code. The first test verifies that an authorisation code is not usable after 30 seconds while the second does the same test with a 1 second delay. The 30 second version will result in a failure while the 1 second version will produce a warning.

Preconditions
    Steps
    1. Retrieve Discovery Document and parse required endpoints
    2. Retrieve JWKS Key Set using jwksuri attribute
    3. Validate JWKS keys are valid JSON, contain the required fields and are correctly encoded using unpadded base64url
    4. Verify all JWKS keys contain kids.
    5. Verify all JWKS keys do not contain any private or symmetric keys.
    6. Verify all JWKS keys are of at least 2048 bit in length
    7. Verify JWKS contains at least one key with alg of PS256 or ES256.
    8. Create authorisation request with content of (roughly) similar to:
    9. {
      "aud": "https://localmachine:8103/local-conformance-holder",
      "scope": "openid profile bank:accounts.basic:read bank:accounts.detail:read",
      "claims": {
      "sharingduration": 7776000,
      "id_token": {
      "acr": {
      "value": "urn:cds.au:cdr:2",
      "essential": true
      }
      }
      },
      "iss": "4unxLnjKSMQCTRYU1X1Bed",
      "response_type": "code id_token",
      "redirect_uri": "https://localhost.emobix.co.uk:8443/test/a/wikkitgate/callback",
      "state": "LwI4CZHGDm",
      "exp": 1603332124,
      "nonce": "vVqWbuseiL",
      "client_id": "4unxLnjKSMQCTRYU1X1Bed"
      }
    10. Sign the authorisation request using PS256.
    11. Create a client assertion containing iss, sub, jti , iat, exp and aud
    12. Sign the client assertion using PS256
    13. Dispatch the authorisation request (9) using the client assertion (11) to the pushedauthorizationrequestendpoint specified within the discovery document
    14. Verify that the PAR endpoint returns HTTP Status 201 with a valid requesturi returned
    15. Verify that the content of the request uri meets entropy of at least 128-bits
    16. Initiate a browser initiation to the authorize endpoint specifying:
      • requesturi retrieved in (13)
      • clientid matching the iss of the authorisation request
      • redirecturi matching the authorisation request
      • scope specifying scopes matching the authorisation request
      • responsetype of code idtoken
    17. Proceed through authorisation flow within the browser
    18. Receive redirect request at the redirecturi specified and extract the fragment content and verify the following:
      • state is not present in the url query string (but is present in the fragment)
    19. Verify that the fragment contained in the redirect response contains only:
      • code
      • state
      • id token
    20. Verify that code is of sufficient length and has at least 128-bit entropy
    21. Decrypt idtoken using encryption key for client and verify signature
    22. Validate the idtoken by verifying iss, aud, exp, iat, authtime, acr, sub and nbf claims
    23. Verify nonce within decrypted idtoken matches nonce specified in (8)
    24. Verify acr returned matches the one request (normally urn:cds.au:cdr:2)
    25. Extract shash and chash from ID Token
    26. Verify chash is correctly validated against specified code
    27. Verify shash is correctly validated against specified state
    28. Create a client assertion for submission to the token endpoint
    29. Perform POST /token using generated client assertion from (27), granttype of authorizationcode, code retrieved in (18) and redirecturi specified in (15)
    30. The response should contain a valid set of tokens
    31. Wait 1 second
    32. Attempt to execute (27)-(29) again, if the request succeeds this test case is a warning state. If it fails with an invalidgrant error it is a success.
    33. Wait 30 seconds
    34. Attempt to execute (27)-(29) again, if the request succeeds this test case is a failure state. If it fails with an invalidgrant error it is a success.
    Inputs
    Expected Results
    1. The Holder must not allow authorisation code reuse within a β€œreasonable” period of time designated as 30 seconds
    2. The Holder ma allow authorisation code reuse within 1 second but this is considered a warning