Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with response after set authorization key in header #370

Closed
arefm opened this issue Aug 6, 2017 · 2 comments
Closed

Problem with response after set authorization key in header #370

arefm opened this issue Aug 6, 2017 · 2 comments

Comments

@arefm
Copy link

arefm commented Aug 6, 2017

Hey

I'm getting an Error 404 when trying to set my authorization key (key-auth) in the request header. I'm sure that there isn't any problem with my key because if I don't set it a Forbidden status will return.

before setting any credentials:

$ curl http://localhost:8080/ip

will return:

{
  "origin": "5.116.28.133"
}

after creating a key-auth credential:

$ curl -H "Authorization: apiKey ${keyId}:${keySecret}" http://localhost:8080/ip

will return:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /ip</pre>
</body>
</html>

and it's my gateway config:

http:
  port: 8080
admin:
  port: 9876
  hostname: localhost
apiEndpoints:
  api:
    host: localhost
    paths: '/ip'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
pipelines:
  - name: default
    apiEndpoints:
      - api
    policies:
    - key-auth:
      - proxy:
          - action:
              serviceEndpoint: httpbin 
              changeOrigin: true

Does anyone know why this issue happens?

@kevinswiber
Copy link
Member

Hey @arefm!

It looks like you have an indentation bug in the YAML config. The - key-auth: line needs to move over a couple of spaces. Here's the corrected config:

http:
  port: 8080
admin:
  port: 9876
  hostname: localhost
apiEndpoints:
  api:
    host: localhost
    paths: '/ip'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
pipelines:
  - name: default
    apiEndpoints:
      - api
    policies:
      - key-auth:
      - proxy:
          - action:
              serviceEndpoint: httpbin 
              changeOrigin: true

@kevinswiber
Copy link
Member

Closing for now. Re-open if still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants