I’m using Tyk gateway community version and I’m trying to set up JWT token but it is not working as expected and is giving following error response when the api end point is called.
Thanks in advance.
Error response:
{
“error”: “Key not authorized:token contains an invalid number of segments”
}
My tyk.conf is as follows :
apiVersion: v1
data:
tyk.conf: |
{
“listen_port”: 8080,
“secret”: “352d20ee67be67f6340b4c0605b044b7”,
“template_path”: “/opt/tyk-gateway/templates”,
“tyk_js_path”: “/opt/tyk-gateway/js/tyk.js”,
“middleware_path”: “/opt/tyk-gateway/middleware”,
“use_db_app_configs”: false,
“app_path”: “/opt/tyk-gateway/apps/”,
“storage”: {
“type”: “redis”,
“host”: “localhost”,
“port”: 30072,
“username”: “”,
“password”: “”,
“database”: 0,
“optimisation_max_idle”: 2000,
“optimisation_max_active”: 4000
},
“enable_analytics”: false,
“analytics_config”: {
“type”: “csv”,
“csv_dir”: “/tmp”,
“mongo_url”: “”,
“mongo_db_name”: “”,
“mongo_collection”: “”,
“purge_delay”: -1,
“ignored_ips”: []
},
“health_check”: {
“enable_health_checks”: true,
“health_check_value_timeouts”: 60
},
“optimisations_use_async_session_write”: true,
“enable_non_transactional_rate_limiter”: true,
“enable_sentinel_rate_limiter”: false,
“enable_redis_rolling_limiter”: false,
“allow_master_keys”: false,
“policies”: {
“policy_source”: “file”,
“policy_record_name”: “/opt/tyk-gateway/policies/policies.json”
},
“hash_keys”: true,
“close_connections”: false,
“http_server_options”: {
“enable_websockets”: true
},
“allow_insecure_configs”: true,
“coprocess_options”: {
“enable_coprocess”: true,
“coprocess_grpc_server”: “”,
“coprocess_grpc_api_key”: “”,
“coprocess_python_path”: “”
},
“enable_bundle_downloader”: true,
“bundle_base_url”: “”,
“global_session_lifetime”: 100,
“force_global_session_lifetime”: false,
“max_idle_connections_per_host”: 500
}
“auth”: {
“auth_header_name”: “Authorization”,
“use_param”: false,
“jwt_secret”: “tyk123”,
“enable_jwt”: true,
“jwt_default_issuer”: “”,
“jwt_default_audience”: “”,
“jwt_identity_base_field”: “sub”,
“jwt_client_base_field”: “aud”,
“jwt_policy_field_name”: “pol”,
“jwt_signing_method”: “H256”,
“jwt_default_signing_key”: “LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JR2ZNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0R05BRENCaVFLQmdRRFdtakFiUEV3ZTFRdm44RHdHTnhTdlE1c1gNCnIyWmxNMUwvaCtTczQ0WTNHeHhYY3dKc0RlelREbnhzNFdrekpIZHNPeWh3eDRLNGVnTDBGOEVaZHpBUlBtT28NCkFqWEpEOG8vdlB0V202dFIzRVdkVkNQaTBjZTE2ekZhVUUxRkVZRGZNbDFXUHFtOG9Na2Rsd2tFbG1DT1ZJR2INClFIQjJyQ2R4dFN2ZlZpNk9PUUlEQVFBQg0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0t”,
“jwt_policy_prefix”: “”
}
kind: ConfigMap
metadata:
name: tyk-gateway-conf
My partial log is
time=“Aug 02 06:55:12” level=info msg=“Attempted JWT access with non-existent key.” api_id=5 api_name=“Test API5” mw=JWTMiddleware org_id=1 origin=10.244.0.1 path=“/api/mail”
time=“Aug 02 06:55:12” level=error msg=“JWT validation error” api_id=5 api_name=“Test API5” error=“token contains an invalid number of segments” mw=JWTMiddleware org_id=1 origin=10.244.0.1 path=“/api/mail”