openactive-test-suite

< Return to Summary File Generated: Fri Oct 01 2021 08:16:42 GMT+0000 (Coordinated Universal Time)

booking-partner-authentication » authorization-code-flow

Booking Flow:

Opportunity Type:

Feature: Authentication / Booking Partner Authentication 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/booking-partner-authentication/implemented/authorization-code-flow-test.js

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


Open ID Connect Authentication

Credentials

The test suite is using the credentials below for this test:

These credentials were retrieved using Dynamic Client Registration by the Broker Microservice upon startup, using the following configuration within bookingPartners.primary.authentication:

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"
}

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=5d4df2f8-98d8-4888-a34c-cac7a7a9c491&scope=openid%20openactive-openbooking%20offline_access%20openactive-identity&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcb&code_challenge=7FFI3GnTmQ-BAFNJi7M6-JwUciNvrzPdCvaUEJE-tw0&code_challenge_method=S256"
}

Screenshot: Login page

"https://localhost:5003/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3D5d4df2f8-98d8-4888-a34c-cac7a7a9c491%26scope%3Dopenid%2520openactive-openbooking%2520offline_access%2520openactive-identity%26response_type%3Dcode%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fcb%26code_challenge%3D7FFI3GnTmQ-BAFNJi7M6-JwUciNvrzPdCvaUEJE-tw0%26code_challenge_method%3DS256"

Screenshot: Login page

Screenshot: Authorization page

"https://localhost:5003/consent?returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3D5d4df2f8-98d8-4888-a34c-cac7a7a9c491%26scope%3Dopenid%2520openactive-openbooking%2520offline_access%2520openactive-identity%26response_type%3Dcode%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fcb%26code_challenge%3D7FFI3GnTmQ-BAFNJi7M6-JwUciNvrzPdCvaUEJE-tw0%26code_challenge_method%3DS256"

Screenshot: Authorization page

Callback URL

"/cb?code=ACFC792544FEBF5E3DB543000565E06043B77D551A86504E256D15E801E41135&scope=openid%20openactive-openbooking%20offline_access%20openactive-identity&session_state=OWNAZj-QzgAVxgi6ElNQxnJAkPaUY4tRZML_akfrFD4.7540DC778A1751AA80BAD56F06DED3FB"

Authorization Code Flow - 2 Request

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

"grant_type=authorization_code&code=ACFC792544FEBF5E3DB543000565E06043B77D551A86504E256D15E801E41135&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcb&code_verifier=gerwlroS4uULIruKs8jN8ZeQQ7fJC22Gld6You31Y2Y"

Response status code: 200.

{
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IkIwNEY3QjkxREUzQjk0NzhDNjE4MzNGQjI0QUE1Q0RCIiwidHlwIjoiSldUIn0.eyJuYmYiOjE2MzMwNzYyMDYsImV4cCI6MTYzMzA3NjUwNiwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMyIsImF1ZCI6IjVkNGRmMmY4LTk4ZDgtNDg4OC1hMzRjLWNhYzdhN2E5YzQ5MSIsImlhdCI6MTYzMzA3NjIwNiwiYXRfaGFzaCI6IlYzMnNkVUxuSHNaTTFWakwyZElvNGciLCJzaWQiOiJDQjQ2NjUxMUUyRTcwMkVEOUZDRkE1ODM5MUUwMDBGNyIsInN1YiI6IjEwMCIsImF1dGhfdGltZSI6MTYzMzA3NjIwNCwiaWRwIjoibG9jYWwiLCJodHRwczovL29wZW5hY3RpdmUuaW8vc2VsbGVyTmFtZSI6IkFjbWUgRml0bmVzcyBMdGQiLCJodHRwczovL29wZW5hY3RpdmUuaW8vc2VsbGVySWQiOiJodHRwczovL2xvY2FsaG9zdDo1MDAxL2FwaS9pZGVudGlmaWVycy9zZWxsZXJzLzEiLCJodHRwczovL29wZW5hY3RpdmUuaW8vc2VsbGVyVXJsIjoiaHR0cHM6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GMjcyMTM3M0E0RjdEOUYyRjM1Iiwic2lkIjoiQ0I0NjY1MTFFMkU3MDJFRDlGQ0ZBNTgzOTFFMDAwRjciLCJpYXQiOjE2MzMwNzYyMDYsInNjb3BlIjpbIm9wZW5pZCIsIm9wZW5hY3RpdmUtb3BlbmJvb2tpbmciLCJvcGVuYWN0aXZlLWlkZW50aXR5Iiwib2ZmbGluZV9hY2Nlc3MiXSwiYW1yIjpbInB3ZCJdfQ.PSaA1W0XGy4qazfSKM2GMU2K0JbVs0Ty9-uxS0IiQ_LnbfrA4avIyaUU8BPuaJAVwBy6Wme0Bu8s2M8k2Cnwd-TXVkx_iG2MQJ2F4ud10tmli5TpopbomiqRefmTCeEi5aGSUpYVDuajpcbmoSVDpPxPlWvx-9n-82IftnfoHHA5hCNOq7Fe1S3_vDO867cPU_ZvmCNs6_oxPF9faELfaUETDBgTPiKlEw_abFus0rYnhCnaPiHUzW2zFNvTuNvZlLfLOVXq9gZ7uK6ZTLlWiEa8RUnUS0GmYIh5FX2_ny854JYpz-Jm-uquyi7BaM0V_hJsiuodpPn--SDcHtibBw",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "A0B271F72377891FC3D3839C75233A7FD2DC709AE659894187DD446FB1CAE867",
  "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": 1633076206,
  "exp": 1633076506,
  "iss": "https://localhost:5003",
  "aud": "5d4df2f8-98d8-4888-a34c-cac7a7a9c491",
  "iat": 1633076206,
  "at_hash": "V32sdULnHsZM1VjL2dIo4g",
  "sid": "CB466511E2E702ED9FCFA58391E000F7",
  "sub": "100",
  "auth_time": 1633076204,
  "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=A0B271F72377891FC3D3839C75233A7FD2DC709AE659894187DD446FB1CAE867"

Response status code: 200.

{
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IkIwNEY3QjkxREUzQjk0NzhDNjE4MzNGQjI0QUE1Q0RCIiwidHlwIjoiSldUIn0.eyJuYmYiOjE2MzMwNzYyMDYsImV4cCI6MTYzMzA3NjUwNiwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMyIsImF1ZCI6IjVkNGRmMmY4LTk4ZDgtNDg4OC1hMzRjLWNhYzdhN2E5YzQ5MSIsImlhdCI6MTYzMzA3NjIwNiwiYXRfaGFzaCI6IlRmZ2VJbDV3bkVCTGgwQW1PUVhNdlEiLCJzdWIiOiIxMDAiLCJhdXRoX3RpbWUiOjE2MzMwNzYyMDQsImlkcCI6ImxvY2FsIiwiaHR0cHM6Ly9vcGVuYWN0aXZlLmlvL3NlbGxlck5hbWUiOiJBY21lIEZpdG5lc3MgT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aW1lIjoxNjMzMDc2MjA0LCJpZHAiOiJsb2NhbCIsImh0dHBzOi8vb3BlbmFjdGl2ZS5pby9zZWxsZXJJZCI6Imh0dHBzOi8vbG9jYWxob3N0OjUwMDEvYXBpL2lkZW50aWZpZXJzL3NlbGxlcnMvMSIsImp0aSI6IkIxMkIyQTRDRDQzNzc2OTBDNEQ2NTE1MkY2QkE5NzA4IiwiaWF0IjoxNjMzMDc2MjA2LCJzY29wZSI6WyJvcGVuaWQiLCJvcGVuYWN0aXZlLW9wZW5ib29raW5nIiwib3BlbmFjdGl2ZS1pZGVudGl0eSIsIm9mZmxpbmVfYWNjZXNzIl0sImFtciI6WyJwd2QiXX0.X4d_ILH4bgTHPLSTXJgvYjZUqzhIM5QWbpcY7tnp1WUZLUCiWjVVcvWllFRjRv30OQosWnApt3qyFXcQIzHsCb1Y2ly-tT6m5MDMMBTvWl-1KkJn-n-Q72r4pSjzQKbjCGYjWSqEcGtatwf9Pmp89x7egtc4jp8anI45iPktX29lkoVNLTUITzOCcZJtTPrUsWKZ42c-HvPYtI6UQI2aVhyFg8R3LsYyv76pdjdX-uOuLnbUlOW8yteAYZyNl4ST8ne7lMC5fyCKIGjm0BF02Ah9T29xsu4nb3U8zyuPc9epTKaqMhTuJ2j7zHN-DUGZL8wXSILndgsnExehawS4VQ",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "0E155F260FB38555A0B699842C2D3623ED97D7077CA6E97831DC767B7F7199B4",
  "scope": "openid openactive-openbooking openactive-identity offline_access"
}

Specs