Problem:
Currently, the Gateway Calls KeyValidationService in the Key Manager to
validate the token and the subscription details.
Hence, there is a runtime dependency on the Key Manager node.
And the KM has a database dependency. In case if the database server is not
available then there is a chance to fail the key validation.

Solution:
Load subscription details to the memory in advance so as to remove runtime
dependency on the Key Manager.


As a first step introducing a set of REST APIs to fetch
subscription-related information.

Please find the identified REST APIs below.
These APIs will fetch only the required data for subscription validation.

/apis:
  get:
    summary: Get all apis
    description: |
      This will provide access to apis in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of APIs in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/API'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/applications:
  get:
    summary: Get all applications
    description: |
      This will provide access to applications in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of applications in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/Application'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/subscriptions:
  get:
    summary: Get all subscriptions
    description: |
       This will provide access to subscriptions in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of subscriptions in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/Subscription'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/application-key-mappings:
  get:
    summary: Get all application key mappings
    description: |
      This will provide access to application vs key mappings in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of application key mappings in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/ApplicationKeyMapping'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/subscription-policies:
  get:
    summary: Get all subscription throttling policies
    description: |
      This will provide access to subscription level throttling
policies in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of subscription policies in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/SubscriptionPolicy'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/application-policies:
  get:
    summary: Get all application throttling policies
    description: |
      This will provide access to application level throttling
policies in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of application policies in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/ApplicationPolicy'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/api-policies:
  get:
    summary: Get all api throttling policies
    description: |
      This will provide access to api level throttling policies in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of api policies in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/ApiPolicyConditionGroup'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'
/api-policy-condition-groups:
  get:
    summary: Get all application throttling policies
    description: |
      This will provide access to application level throttling
policies in database.
    tags:
    - Subscription Validation
    responses:
      200:
        description: An array of application policies in the database
        schema:
          type: array
          items:
            $ref: '#/definitions/ApiPolicyConditionGroup'
      default:
        description: Unexpected error
        schema:
          $ref: '#/definitions/Error'


definitions:


#-----------------------------------------------------
# The API resource
#-----------------------------------------------------
API:
  properties:
    apiId:
      type: integer
    provider:
      type: string
      description: API Provider name.
    name:
      type: string
      description: Name of the API
    version:
      type: string
      description: Version of the API.
    context:
      type: boolean
      description: Context of the API.
    policy:
      type: string
      description: API level throttling policy.

#-----------------------------------------------------
# The Application resource
#-----------------------------------------------------
Application:
  properties:
    id:
      type: integer
    name:
      type: string
    subId:
      type: integer
    policy:
      type: string
      description: Application level throtting policy.
    tokenType:
      type: string
      description: type of the token.
      example: JWT

#-----------------------------------------------------
# The Subscription resource
#-----------------------------------------------------
Subscription:
  properties:
    policyId:
      type: integer
    apiId:
      type: integer
    appId:
      type: integer
    subscriptionState:
      type: string

#-----------------------------------------------------
# The Subscriber resource
#-----------------------------------------------------
Subscriber:
  properties:
    userId:
      type: integer
    subscriberId:
      type: integer

#-----------------------------------------------------
# The Application Key Mapping resource
#-----------------------------------------------------
ApplicationKeyMapping:
  properties:
      applicationId:
        type: integer
      consumerKey:
        type: string
      keyType:
        type: string

#-----------------------------------------------------
# The Throttle Policy resource
#-----------------------------------------------------
Policy:
  properties:
    id:
      type: integer
    tenantId:
      type: integer
    name:
      type: string
    quotaType:
      type: string

#-----------------------------------------------------
# The Subscription Level Policy resource
#-----------------------------------------------------
SubscriptionPolicy:
  properties:
    allOf:
      $ref: '#/definitions/Policy'
    rateLimitCount:
      type: integer
    rateLimitTimeUnit:
      type: string
    stopOnQuotaReach:
      type: boolean

#-----------------------------------------------------
# The Application Level Policy resource
#-----------------------------------------------------
ApplicationPolicy:
  properties:
    allOf:
      $ref: '#/definitions/Policy'

#-----------------------------------------------------
# The API Level Policy resource
#-----------------------------------------------------
ApiPolicy:
  properties:
    allOf:
      $ref: '#/definitions/Policy'
    conditionGroups:
      type: array
      items:
        $ref: '#/definitions/ApiPolicyConditionGroup'

#-----------------------------------------------------
# The API Policy Condition  Group resource
#-----------------------------------------------------
ApiPolicyConditionGroup:
  properties:
    policyId:
      type: integer
    quotaType:
      type: string
    conditionGroupId:
      type: integer
    condition:
      type: array
      items:
        $ref: '#/definitions/Condition'

#-----------------------------------------------------
# The Throttle Policy Condition resource
#-----------------------------------------------------
Condition:
  properties:
    conditionType:
      type: string
    name:
      type: string
    value:
      type: string
    isInverted:
      type: boolean


Thanks & Regards,
Ishara Cooray
Associate Technical Lead
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to