feat(router): Unify Auth in single layer (V2)

In-efficiency in design

* Currently we have many types of auth and auth is evaluated in multiple places, with multiple ways.
* This indeed required multiple approaches and solution needs to be maintained
* More cognitive load
* We can’t authenticate a request in one infra component/layer

Unify Auth in single layer

* Make Authentication header like,
    * authorization: key=value, keyN=valueN
    * Examples:
        * authorization: api-key=<api-key>
        * authorization: publishable-key=<publishable-key>, client-secret=<client-secret>
        * authorization: publishable-key=<publishable-key>, ephemeral-key=<ephemeral-key>
        * authorization: jwt=<jwt-token>
* Lineage also should be added in headers, when we can’t inferable from authorization
    *  `profile_id` should be added in headers not in body
    * If `api-key` not passed or the passed `api-key` has different scope, then `merchant-id` also should be passed.


<think>
PR Context:
- Title: feat(router): [V2] Introduce V2Auth and use it for payment_methods_list_enabled
- Merged: 2025-01-31T08:37:18Z
- Files changed: 30 files
- Commits: 11 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [x] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Added an enum `V2Auth` (name subject to change) to encapsulate different authentication scenarios. Currently only works for Client Authentication using `publishable_key` and `ephemeral_key` in `Authorization` header

### Additional Changes

</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(router): [V2] Introduce V2Auth and use it for payment_methods_list_enabled (#7038)
Co-authored-
Files to modify:


**crates/api_models/src/ephemeral_key.rs**
  Remove:
    - struct: pub::EphemeralKeyCreateRequest
  Add:
    - struct: pub::ClientSecretCreateRequest
    - enum: pub::ResourceId

**crates/api_models/src/events/payment.rs**
  Modify existing code

**crates/api_models/src/payment_methods.rs**
  Modify existing code

**crates/api_models/src/payments.rs**
  Modify existing code

**crates/api_models/src/webhooks.rs**
  Modify existing code

**crates/common_utils/src/events.rs**
  Modify existing code

**crates/common_utils/src/id_type.rs**
  Remove:
    - mod: private::ephemeral_key
  Add:
    - mod: private::client_secret

**crates/common_utils/src/id_type/client_secret.rs**
  Add:
    - function: private::get_api_event_type
    - function: pub::generate_redis_key
    - impl: impl crate::events::ApiEventMetric for ClientSecretId
    - impl: impl ClientSecretId

**crates/common_utils/src/id_type/ephemeral_key.rs**
  Remove:
    - function: private::get_api_event_type
    - function: pub::generate_redis_key
    - impl: impl crate::events::ApiEventMetric for EphemeralKeyId
    - impl: impl EphemeralKeyId

**crates/common_utils/src/id_type/global_id/payment_methods.rs**
  Modify existing code

**crates/diesel_models/src/ephemeral_key.rs**
  Remove:
    - struct: pub::EphemeralKeyTypeNew
    - enum: pub::ResourceType
  Add:
    - function: pub::to_str
    - struct: pub::ClientSecretTypeNew
    - enum: pub::ResourceId
    - impl: impl ResourceId

**crates/openapi/src/openapi_v2.rs**
  Modify existing code

**crates/router/src/core/payment_methods.rs**
  Remove:
    - function: pub::payment_method_intent_confirm

**crates/router/src/core/payment_methods/transformers.rs**
  Add:
    - impl: impl transformers::ForeignFrom<(
        hyperswitch_domain_models::payment_methods::PaymentMethodsSession,
        Secret<String>,
    )> for (session, client_secret)

**crates/router/src/core/payments/helpers.rs**
  Modify existing code

**crates/router/src/core/payments/transformers.rs**
  Modify existing code

**crates/router/src/core/utils.rs**
  Modify existing code

**crates/router/src/db.rs**
  Modify existing code

**crates/router/src/db/ephemeral_key.rs**
  Remove:
    - function: private::get_ephemeral_key
    - function: private::delete_ephemeral_key
    - function: private::create_ephemeral_key
    - function: private::get_ephemeral_key
  Add:
    - function: private::get_ephemeral_key
    - function: private::delete_ephemeral_key
    - function: private::delete_client_secret
    - function: private::create_client_secret
    - function: private::get_client_secret
    - trait: pub::ClientSecretInterface

**crates/router/src/db/kafka_store.rs**
  Remove:
    - function: private::create_ephemeral_key
    - function: private::get_ephemeral_key
  Add:
    - function: private::create_client_secret
    - function: private::get_client_secret

**crates/router/src/lib.rs**
  Modify existing code

**crates/router/src/routes/app.rs**
  Modify existing code

**crates/router/src/routes/customers.rs**
  Modify existing code

**crates/router/src/routes/ephemeral_key.rs**
  Modify existing code

**crates/router/src/routes/payment_methods.rs**
  Remove:
    - function: pub::confirm_payment_method_intent_api

**crates/router/src/services/authentication.rs**
  Remove:
    - function: private::authenticate_and_fetch
    - function: pub::is_ephemeral_or_publishible_auth
    - impl: impl AuthenticateAndFetch<AuthenticationData, A> for EphemeralKeyAuth
  Add:
    - function: pub::get_auth_string_from_header
    - function: private::authenticate_and_fetch
    - function: private::authenticate_and_fetch
    - enum: pub::V2Auth
    - impl: impl AuthenticateAndFetch<AuthenticationData, A> for V2Auth
    - impl: impl AuthenticateAndFetch<AuthenticationData, A> for Vec<V2Auth>

**crates/router/src/types.rs**
  Modify existing code

**crates/router/src/types/api/payments.rs**
  Modify existing code

**crates/router/src/types/storage/ephemeral_key.rs**
  Modify existing code
{"issue_number": 7037, "pr_number": 7038, "commits_count": 1, "files_changed": 30, "response_length": 4938, "file_count": 31, "needs_breakdown": true}