Protect API with JWT Keycloak

Hi,

I’m exposing an API to our partner and I want to protect it through Tyk API Gateway. My API must be used only by applications and not end users.
We are currently using release 4.3.
I have several questions:

12cd70001948f0c origin=10.0.0.209 path="/envoi-sms"
time="May 03 08:20:06" level=debug msg="Querying keystore" api_id=f29bea48468a4aa851d889a3e1612455 api_name="Envoi SMS" mw=JWTMiddleware org_id=62583367b12cd70001948f0c origin=10.0.0.209 path="/envoi-sms"
time="May 03 08:20:06" level=debug msg="Got key" api_id=f29bea48468a4aa851d889a3e1612455 api_name="Envoi SMS" mw=JWTMiddleware org_id=62583367b12cd70001948f0c origin=10.0.0.209 path="/envoi-sms"
time="May 03 08:20:06" level=debug msg="Could not identify a policy to apply to this token from field: pol" api_id=f29bea48468a4aa851d889a3e1612455 api_name="Envoi SMS" mw=JWTMiddleware org_id=62583367b12cd70001948f0c origin=10.0.0.209 path="/envoi-sms"
time="May 03 08:20:06" level=debug msg="Getting client ID:sms-api-ccr"
time="May 03 08:20:06" level=debug msg="Error trying to get value:redis: nil"
time="May 03 08:20:06" level=debug msg="Failure retrieving client ID key "oauth-clientid.sms-api-ccr": key not found"
time="May 03 08:20:06" level=debug msg="Couldn't get OAuth client" api_id=f29bea48468a4aa851d889a3e1612455 api_name="Envoi SMS" error="key not found" mw=JWTMiddleware org_id=62583367b12cd70001948f0c origin=10.0.0.209 path="/envoi-sms"

Here is an extract of the API definition

"jwt_scope_to_policy_mapping": {},
    "pinned_public_keys": {},
    "expire_analytics_after": 0,
    "external_oauth": {
      "enabled": false,
      "providers": []
    },
    "domain": "",
    "openid_options": {
      "providers": [],
      "segregate_by_client": false
    },
    "jwt_policy_field_name": "pol",
    "enable_proxy_protocol": false,
    "jwt_default_policies": [
      "66335029846a0200019ff8ae"
    ],
    "active": true,
    "jwt_expires_at_validation_skew": 0,
    "config_data": {},
    "notifications": {
      "shared_secret": "",
      "oauth_on_keychange_url": ""
    },
    "jwt_client_base_field": "",
    "auth": {
      "disable_header": false,
      "auth_header_name": "Authorization",
      "cookie_name": "",
      "name": "",
      "validate_signature": false,
      "use_param": false,
      "signature": {
        "algorithm": "",
        "header": "",
        "use_param": false,
        "param_name": "",
        "secret": "",
        "allowed_clock_skew": 0,
        "error_code": 0,
        "error_message": ""
      },...
 "jwt_scope_claim_name": "",
    "use_standard_auth": false,
    "session_lifetime": 0,
    "hmac_allowed_algorithms": [],
    "disable_rate_limit": false,
    "definition": {
      "enabled": false,
      "name": "",
      "default": "",
      "location": "header",
      "key": "x-api-version",
      "strip_path": false,
      "strip_versioning_data": false,
      "versions": {}
    },
    "use_oauth2": false,
    "jwt_source": "BLABLA",
    "jwt_signing_method": "rsa",
    "jwt_not_before_validation_skew": 0,
    "use_go_plugin_auth": false,
    "jwt_identity_base_field": "clientId",
    "allowed_ips": [],
    "request_signing": {
      "is_enabled": false,
      "secret": "",
      "key_id": "",
      "algorithm": "",
      "header_list": [],
      "certificate_id": "",
      "signature_header": ""
    },...

My JWT has a kid in its header and also a field clientId with the right value.

Can you please help me ?

@ibe Hello and welcome to the community :partying_face:

This is an architectural/professional services question that we are not best placed to answer. You could ask for user’s opinions on the forums but you might be better served getting help from more public forums like stack overflow or reddit

You might even get some ideas if you pose this question My API must be used only by applications and not end users. to a generative AI model

Can you point out where in the documentation was unclear?

I have tried to replicate but I cannot. The most common problem I can think of is if you might have associated the wrong policy to the API definition. The error that is returned is a 403
Forbidden

Access to this API has been disallowed

Is this what you get?