1

I'm kinda of new in EG. I have followed the documentation about issuing a jwt token instead of opaque but still receiving an opaque access token. Not sure what I'm missing to change.

This is my system.config file

db:
  redis:
  host: localhost
  port: 6379
  namespace: EG

crypto:
  cipherKey: sensitiveKey
  algorithm: aes256
  saltRounds: 10
session:
  secret: keyboard cat
  resave: false
  saveUninitialized: false
accessTokens:
  timeToExpiry: 7200000
  tokenType: 'jwt'
  issuer: 'express-gateway'
  audience: 'something'
  subject: 'test'
  secretOrPrivateKey: 'ssssst'
refreshTokens:
  timeToExpiry: 7200000
authorizationCodes:
  timeToExpiry: 300000

Already added a user and app with their own credentials (oauth2, basic-auth, jwt) without changing anything on the models.

this is my gateway.config file

http:
  port: 8080
admin:
  port: 9876
  hostname: localhost
apiEndpoints:
  api:
    host: localhost
    paths: '/api/*'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
policies:
  - jwt
  - oauth2
  - proxy
  - rate-limit
pipelines:
  default:
    apiEndpoints:
      - api
    policies:
      - oauth2:
          action:
            jwt:
              issuer: express-gateway
              audience: something
              subject: test
              secretOrPublicKey: ssssst
              checkCredentialExistence: false
      - proxy:
          - action:
              serviceEndpoint: httpbin
              changeOrigin: true

the request for login is like this and secret is the keySecret generated with jwt credential of the app.

http://localhost:8080/oauth2/authorize?response_type=token&client_id=ae921ba9-7b4b-4c53-aaba-354bd6398e52&redirect_uri=http://localhost:3002/explorer&client_secret=0qOpBZkwO2ayQ8dO18yRuh

and the token response looks like this.

14070f7c4ffc49efb1fc1709cc4a7267|90c6efd2cf8342859756d8e3705417a3

Thanks for anyone who can help me.

Cesar Sosa
  • 13
  • 3

1 Answers1

0

The configuration looks correct. I've also personally tried the configuration you provided and I got back a JWT

enter image description here

Maybe you can try to set up a test project on Glitch.me so it's going to be easier to replicate locally.

Vincenzo
  • 1,549
  • 1
  • 9
  • 17
  • Do you use oauth2 client Id and oauth2 client Secret ? – Seb Bizeul Sep 17 '18 at 10:06
  • In my case, it gives me back a JWT but still have a 401 when I'm trying to consume my secured endpoint – Seb Bizeul Sep 17 '18 at 10:10
  • In that case the problem might be because of a non matching public certificate on your side. You might want to check that with your provider. – Vincenzo Sep 17 '18 at 10:41
  • Thanks for your answer Vincenzo. I use my own public and private key to sign the token. I use password grant type to make a post request to `oauth2/token` and want to use eg as a auth provider. Maybe it's better to create another stack question for this? – Seb Bizeul Sep 17 '18 at 11:45
  • You are right Vincenzo ! The signing key was not the same... sorry! – Seb Bizeul Sep 17 '18 at 12:24