< Return to Summary | File Generated: Tue Apr 16 2024 12:00:12 GMT+0000 (Coordinated Universal Time)

dynamic-client-registration >> authorization-code-flow

Booking Flow:

Opportunity Type:

Feature: Authentication / Dynamic Client Registration for Multiple Seller Systems (Implemented)

Test: Authorization Code Flow

The Authorization Code Flow allows Sellers to authenticate with Booking Partners

Running only this test

npm start -- --runInBand test/features/authentication/dynamic-client-registration/implemented/authorization-code-flow-test.js

Is this test failing?

The OpenActive Reference Implementation test result for this test can be used as a reference to help with debugging.


✅ 8 passed with 0 failures, 0 warnings and 0 suggestions


✅ Open ID Connect Authentication

Credentials

The test suite is using Dynamic Client Registration to retrieve credentials as part of this test, using the following configuration within bookingPartnersForSpecificTests.dynamicPrimary.authentication:

Hence the client_id and client_secret can be found within the Dynamic Client Registration response below.

Discovery Request

GET https://localhost:5003/.well-known/openid-configuration


Response status code: 200.

{
  "issuer": "https://localhost:5003",
  "jwks_uri": "https://localhost:5003/.well-known/openid-configuration/jwks",
  "authorization_endpoint": "https://localhost:5003/connect/authorize",
  "token_endpoint": "https://localhost:5003/connect/token",
  "userinfo_endpoint": "https://localhost:5003/connect/userinfo",
  "end_session_endpoint": "https://localhost:5003/connect/endsession",
  "check_session_iframe": "https://localhost:5003/connect/checksession",
  "revocation_endpoint": "https://localhost:5003/connect/revocation",
  "introspection_endpoint": "https://localhost:5003/connect/introspect",
  "device_authorization_endpoint": "https://localhost:5003/connect/deviceauthorization",
  "frontchannel_logout_supported": true,
  "frontchannel_logout_session_supported": true,
  "backchannel_logout_supported": true,
  "backchannel_logout_session_supported": true,
  "scopes_supported": [
    "openid",
    "openactive-identity",
    "openactive-openbooking",
    "openactive-ordersfeed",
    "offline_access"
  ],
  "claims_supported": [
    "sub",
    "https://openactive.io/sellerId",
    "https://openactive.io/sellerName",
    "https://openactive.io/sellerUrl",
    "https://openactive.io/sellerLogo",
    "https://openactive.io/bookingServiceName",
    "https://openactive.io/bookingServiceUrl",
    "name",
    "https://openactive.io/clientId"
  ],
  "grant_types_supported": [
    "authorization_code",
    "client_credentials",
    "refresh_token",
    "implicit",
    "urn:ietf:params:oauth:grant-type:device_code"
  ],
  "response_types_supported": [
    "code",
    "token",
    "id_token",
    "id_token token",
    "code id_token",
    "code token",
    "code id_token token"
  ],
  "response_modes_supported": [
    "form_post",
    "query",
    "fragment"
  ],
  "token_endpoint_auth_methods_supported": [
    "client_secret_basic",
    "client_secret_post"
  ],
  "id_token_signing_alg_values_supported": [
    "RS256"
  ],
  "subject_types_supported": [
    "public"
  ],
  "code_challenge_methods_supported": [
    "plain",
    "S256"
  ],
  "request_parameter_supported": true,
  "registration_endpoint": "https://localhost:5003/connect/register"
}

Dynamic Client Registration Request

POST https://localhost:5003/connect/register

{
  "redirect_uris": [
    "http://localhost:3000/cb"
  ],
  "grant_types": [
    "authorization_code",
    "refresh_token",
    "client_credentials"
  ],
  "client_name": "OpenActive Test Suite Client",
  "client_uri": "https://github.com/openactive/openactive-test-suite",
  "logo_uri": "https://via.placeholder.com/512x256.png?text=Logo",
  "scope": "openid profile openactive-openbooking openactive-ordersfeed oauth-dymamic-client-update openactive-identity"
}

Response status code: 201.

{
  "client_id": "faec361c-a4d7-4c21-8084-b8a9230327b0",
  "client_secret": "gpFMcbryizr49FaOGy36tQKb2l03D4YtS0oisi3vBX4",
  "client_name": "OpenActive Test Suite Client",
  "client_uri": "https://github.com/openactive/openactive-test-suite",
  "initiate_login_uri": null,
  "logo_uri": "https://via.placeholder.com/512x256.png?text=Logo",
  "grant_types": [
    "authorization_code",
    "refresh_token",
    "client_credentials"
  ],
  "redirect_uris": [
    "http://localhost:3000/cb"
  ],
  "scope": "openid profile openactive-openbooking openactive-ordersfeed oauth-dymamic-client-update openactive-identity"
}

Authorization Code Flow - 1 Request

POST http://localhost:3000/browser-automation-for-auth

{
  "headless": true,
  "offlineAccess": true,
  "username": "test1",
  "password": "test1",
  "authorizationUrl": "https://localhost:5003/connect/authorize?client_id=faec361c-a4d7-4c21-8084-b8a9230327b0&scope=openid%20openactive-openbooking%20offline_access%20openactive-identity&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcb&code_challenge=IamkLojJvw-AqrBxknXZOn_sT5bGcKbT1chLXb3dmqA&code_challenge_method=S256"
}

Screenshot: Login page

"https://localhost:5003/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dfaec361c-a4d7-4c21-8084-b8a9230327b0%26scope%3Dopenid%2520openactive-openbooking%2520offline_access%2520openactive-identity%26response_type%3Dcode%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fcb%26code_challenge%3DIamkLojJvw-AqrBxknXZOn_sT5bGcKbT1chLXb3dmqA%26code_challenge_method%3DS256"

Screenshot: Login page

Screenshot: Authorization page

"https://localhost:5003/consent?returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dfaec361c-a4d7-4c21-8084-b8a9230327b0%26scope%3Dopenid%2520openactive-openbooking%2520offline_access%2520openactive-identity%26response_type%3Dcode%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fcb%26code_challenge%3DIamkLojJvw-AqrBxknXZOn_sT5bGcKbT1chLXb3dmqA%26code_challenge_method%3DS256"

Screenshot: Authorization page

Callback URL

"/cb?code=214525BBAD6114C21EAD8B471CE811DE606DFC8B93382754523E50D2B7DA26E4&scope=openid%20openactive-openbooking%20offline_access%20openactive-identity&session_state=i97IGxUNypRqiWOdvawQQBPqS7GRXJ3C3SXaa5w8PUk.875FD92F8785B1CA9091F06D22FC1ED1"

Authorization Code Flow - 2 Request

POST https://localhost:5003/connect/token

"grant_type=authorization_code&code=214525BBAD6114C21EAD8B471CE811DE606DFC8B93382754523E50D2B7DA26E4&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcb&code_verifier=lY1ccwUngEtQ9qmJGU1CtQIWQfMcGHUPmZSDr0ReQew"

Response status code: 200.

{
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IkIwNEY3QjkxREUzQ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dcx1-i7E6oXPSS7EpcfEA4iY-BcWFNgxZCvAbOGRHnP2SlJhYUSTBwI2r9rtWq2YQkpcL6EqXcRQlPfR7_-uhNUPo71fW1Crz-mNetgAPDsVjGgfdkrys0XxTUWh8EYOTQ",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "5998471AC576DC36011F5D57416151D8D3D364D3674720648ECAF605C21B8B6D",
  "scope": "openid openactive-openbooking offline_access openactive-identity"
}

Authorization Code Flow - 3 Request

GET https://localhost:5003/.well-known/openid-configuration/jwks


Response status code: 200.

{
  "keys": [
    {
      "kty": "RSA",
      "use": "sig",
      "kid": "B04F7B91DE3B9478C61833FB24AA5CDB",
      "e": "AQAB",
      "n": "yZO68vCGrvfBQ5R1z0DVCRAADOWeF3aLlhOaz1Je1SnmohmmlO-1F1hkRM_4MJtR5aECMxMz-MUW1nBCPmUrH0h_rrdCdDdlk8vTHki0ixK-gO73W2ZscOCZ6L2fZ2Oqz0_I840cnSCv55zpiOk9oGJL9TEsLAWYAIyQheaqZO3BkqImuBFmaLVTckvaZeONjHDQa01rxEjRQByir6oYSZPJy54XuRQJaPuCVNeOW8r0R9rKUQf9nl7tnVvhCsU3q1-UPrs8ZW_kaYXuYQJJMk392jX6XNm6czehIYM-O8Z5eGFdR3WW7IAWYEmqTCxrCRuuKU-EEcKOwksx8gBPgQ",
      "alg": "RS256"
    }
  ]
}

Authorization Code Flow - Claims Result

id_token claims:

{
  "nbf": 1713268814,
  "exp": 1713269114,
  "iss": "https://localhost:5003",
  "aud": "faec361c-a4d7-4c21-8084-b8a9230327b0",
  "iat": 1713268814,
  "at_hash": "yJ7YBow0G0J4Muf-mJ9hnA",
  "sid": "A289B2881A24155EEE4D9A4E40F4C549",
  "sub": "100",
  "auth_time": 1713268813,
  "idp": "local",
  "https://openactive.io/sellerName": "Acme Fitness Ltd",
  "https://openactive.io/sellerId": "https://localhost:5001/api/identifiers/sellers/1",
  "https://openactive.io/sellerUrl": "https://www.example.com",
  "https://openactive.io/sellerLogo": "https://placekitten.com/640/360",
  "amr": [
    "pwd"
  ]
}

Refresh Token Request

POST https://localhost:5003/connect/token

"grant_type=refresh_token&refresh_token=5998471AC576DC36011F5D57416151D8D3D364D3674720648ECAF605C21B8B6D"

Response status code: 200.

{
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IkIwNEY3QjkxREUzQjk0NzhDNjE4MzNGQjI0QUE1Q0RCIiwidHlwIjoiSldUIn0.eyJuYmYiOjE3MTMyNjg4MTQsImV4cCI6MTcxMzI2OTExNCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMyIsImF1ZCI6ImZhZWMzNjFjLWE0ZDctNGMyMS04MDg0LWI4YTkyMzAzMjdiMCIsImlhdCI6MTcxMzI2ODgxNCwiYXRfaGFzaCI6IjN6LUtWY3JoaGNiRDYtQzdrYVI1clEiLCJzdWIiOiIxMDAiLCJhdXRoX3RpbWUiOjE3MTMyNjg4MTMsImlkcCI6ImxvY2FsIiwiaHR0cHM6Ly9vcGVuYWN0aXZlLmlvL3NlbGxlck5hbWUiOiJBY21lIEZpdG5lc3MgTHRkIiwiaHR0cHM6Ly9vcGVuYWN0aXZlLmlvL3NlbGxlcklkIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9hcGkvaWRlbnRpZmllcnMvc2VsbGVycy8xIiwiaHR0cHM6Ly9vcGVuYWN0aXZlLmlvL3NlbGxlclVybCI6Imh0dHBzOi8vd3d3LmV4YW1wbGUuY29tIiwiaHR0cHM6Ly9vcGVuYWN0aXZlLmlvL3NlbGxlckxvZ28iOiJodHRwczovL3BsYWNla2l0dGVuLmNvbS82NDAvMzYwIiwiYW1yIjpbInB3ZCJdfQ.VxZa3olDoClw73owDz27MOLfswitl94XQa0RytblvlZA30ZTuHGVjO4cBXEDOQRNIAXziNBlcBAC-846ZKg4vxQwHClSNfIawq6MszZ1ziJgBbYdHy782JQn6uxx6QOrxpxWwyZx2OhGpFasGC4L_unli4e-3OSd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uorwgT6xCxP2fwrp3X1a61_ss3Jujw6ugui3ogoGNrVzwwP88nHil0kGVXPYT7ZpaPr4FWOt2OspsooKK9oCI23uORk3jH8X09uWDqnw_FpqbQSdFBfEJMtqABc1DpSjjSaCTdr0cM5J4vDdNiSST6JG6BesaA8jQU4TizMayPUMGiOqh46C4QXiJK4D7sdMIrnqH8HDeKzeQ0Xyl-SQiinOJs9uz-X6p5q06hMQ",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "5E15DD05E725BBFA08730A8B909AB848107AAF9E071A86C92826D78C0B971168",
  "scope": "openid openactive-openbooking openactive-identity offline_access"
}

Specs