Reputation: 1
i am currently facing an problem with express-gateway to validate the incoming jwt tokens from the response header trying to get the jwt from api and validate it using secretorpublickey from fusion auth
my gateway.config.yml file looks like this my current code also in my backend code does not have jwt token means api works with or without jwt token i am able to log to incoming request when i am hit the api through postman with jwt token getting it in express - gateway but when using the jwt policy getting Unauthorized if i remove the jwt policy and then hit the api will get the success with or without jwt token in postman
having confusion while implementing this. Any help will be appreciated or how to implement this in custom js code means i have tried also the middlewares but nothing works
some_pipeline:
apiEndpoints:
- some_api
policies:
- jwt:
- action:
secretOrPublicKey: "something"
jwtAlgorithms: ["HS256"]
issuer: "something"
audience: "something
- expression:
- action:
jscode: |
if (!req.user) {
res.status(401).send({
message: "JWT verification failed: Invalid signature or secret key mismatch."
});
} else {
next();
}
- log: # policy name
- action: # array of condition/actions objects
message: "Request received: ${req.method} ${req.originalUrl}, Headers: ${JSON.stringify(req.headers)}, Body: ${JSON.stringify(req.body)}"
- cors:
- action:
origin: "*"
methods: "GET,HEAD,PUT,PATCH,POST,DELETE"
allowedHeaders:
[
"Content-type",
"Authorization",
"Origin",
"Access-Control-Allow-Origin",
"Accept",
"Options",
]
preflightContinue: false
optionsSuccessStatus: 204
- proxy:
- action:
serviceEndpoint: some_service
changeOrigin: true
Any help will be appreciated on this issue
Upvotes: 0
Views: 20