Multiple (Chained) Authentication - Allow Basic Auth and Bearer Token auth

Hi @dszortyka. I’m genuinely sorry to learn that this continues to be a persistent problem for you. To further assist on the issue, could you share the output of the logs in debug mode after going through the following steps

  1. Set log_level=“debug” (TYK_GW_LOGLEVEL) on the gateway to enable verbose gateway logs.
  2. Could you duplicate your API definition, give it unique parameters (name, slug and api_id), copy the the auth_config field value here and enable both use_basic_auth and use_standard_auth
  3. Could you duplicate your policy definition, give it unique parameters (name, id, access_rights), copy the auth_type and auth_types field from the definition here
  4. Create 2 keys (one auth token and one basic auth) from the policy definition
#########################################################################
# Create an auth token key definition via a policy definition
#########################################################################
POST /tyk/keys HTTP/1.1
Host: {{host}}:{{port}}
x-tyk-authorization: {{gateway_secret}}
Content-Type: application/json

{
  "alias": "Auth Token Key",
  "apply_policies": [
    "63e39307975cce0001ded5ff"
  ]
}


{
  "key": "55e87688520e441aa3e9c051b932d548",
  "status": "ok",
  "action": "added"
}
#########################################################################
# Create a basic authentication key definition via a policy definition
#########################################################################
POST /tyk/keys/[email protected] HTTP/1.1
Host: {{host}}:{{port}}
x-tyk-authorization: {{gateway_secret}}
Content-Type: application/json

{
  "alias": "Basic Auth Key",
  "apply_policies": [
    "63e39307975cce0001ded5ff"
  ],
  "basic_auth_data": {
		"password": "1234567",
		"hash_type": "bcrypt"
	}
}


{
  "key": "[email protected]",
  "status": "ok",
  "action": "added"
}
  1. Make a call to the API and share debug log output
####################
# Reverse Proxy call
####################
GET /{{listen_path}}/ HTTP/1.1
Host: {{host}}:{{port}}
Content-Type: application/json
AuthToken: Bearer 55e87688520e441aa3e9c051b932d548
Authorization: Basic am9obkBzbWl0aC5jb206MTIzNDU2Nw==


##############
# Debug Log
#############
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=VersionCheck org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340305404000
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 mw=VersionCheck ns=267100 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=RateCheckMW org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340305732700
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 mw=RateCheckMW ns=179700 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=BasicAuthKeyIsValid org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340306162600
time="Aug 22 12:45:40" level=debug msg="Querying local cache" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=BasicAuthKeyIsValid org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="Querying keystore" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=BasicAuthKeyIsValid org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="Got key" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=BasicAuthKeyIsValid org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="cache enabled: miss: bcrypt" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****.com" mw=BasicAuthKeyIsValid org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 mw=BasicAuthKeyIsValid ns=71478100 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****.com" mw=AuthKey org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340377779900
time="Aug 22 12:45:40" level=debug msg="Querying local cache" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****.com" mw=AuthKey org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="Querying keystore" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****.com" mw=AuthKey org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="Got key" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****.com" mw=AuthKey org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 key="****.com" mw=AuthKey ns=5185900 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****d548" mw=KeyExpired org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340382997900
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 key="****d548" mw=KeyExpired ns=23600 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****d548" mw=AccessRightsCheck org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340383038600
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 key="****d548" mw=AccessRightsCheck ns=9800 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****d548" mw=GranularAccessMiddleware org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340383065900
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 key="****d548" mw=GranularAccessMiddleware ns=11900 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" key="****d548" mw=RateLimitAndQuotaCheck org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/ ts=1692708340383095000
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" code=200 key="****d548" mw=RateLimitAndQuotaCheck ns=43000 org_id=61fd63e8a35fd4000162ed94 origin=172.26.0.1 path=/multi-auth-basic-and-standard/
time="Aug 22 12:45:40" level=debug msg="Started proxy"
time="Aug 22 12:45:40" level=debug msg="Stripping proxy listen path: /multi-auth-basic-and-standard/"
time="Aug 22 12:45:40" level=debug msg="Upstream path is: /"
time="Aug 22 12:45:40" level=debug msg=Started api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=ReverseProxy org_id=61fd63e8a35fd4000162ed94 ts=1692708340383230400
time="Aug 22 12:45:40" level=debug msg="Upstream request URL: /" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=ReverseProxy org_id=61fd63e8a35fd4000162ed94
time="Aug 22 12:45:40" level=debug msg="Outbound request URL: http://host.docker.internal:80/anything/multi-auth-basic-and-standard" api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=ReverseProxy org_id=61fd63e8a35fd4000162ed94
time="Aug 22 12:45:40" level=debug msg=Finished api_id=c4c2d14d256344687b201d6bd5b15e55 api_name="Sample Standard Token and Basic Multi Authentication" mw=ReverseProxy ns=16429300 org_id=61fd63e8a35fd4000162ed94
time="Aug 22 12:45:40" level=debug msg="Upstream request took (ms): 16.5391"
time="Aug 22 12:45:40" level=debug msg="Adding Healthcheck to: c4c2d14d256344687b201d6bd5b15e55.Request"
time="Aug 22 12:45:40" level=debug msg="Val is: 16"
time="Aug 22 12:45:40" level=debug msg="Set value to: 1692708340399909600.16"
time="Aug 22 12:45:40" level=debug msg="Done proxy"
time="Aug 22 12:45:40" level=debug msg="Incrementing raw key: c4c2d14d256344687b201d6bd5b15e55.Request"
time="Aug 22 12:45:40" level=debug msg="keyName is: c4c2d14d256344687b201d6bd5b15e55.Request"
time="Aug 22 12:45:40" level=debug msg="Now is:2023-08-22 12:45:40.4006397 +0000 UTC m=+2447.184650101"
time="Aug 22 12:45:40" level=debug msg="Then is: 2023-08-22 12:45:25.4006397 +0000 UTC m=+2432.184650101"
time="Aug 22 12:45:40" level=debug msg="Returned: 0"

1 Like