Reputation: 299
Okay so I seen this QA here
Non-OAuth2 JWT validation with Google Cloud Endpoints
This does not quite answer my question. Currently, I have a Node service that generates a Bearer token and passes it to the client. The client then passes the token back on subsequent requests.
The token is created through our auth token service. It is the passed to the client. This works. However when the token is passed back from the client through the API gateway and to the backend service it never makes it to the service.
Here is an example of the bearer token that is passed in
eyJhbGciOiJSUzI1NR5cCI6IkpkkSXVCJ9.eyJ1c2VyX2lkIjoiWHZYSlZuZDdRZnhMMXZwZ0dTcWwiLCJyb2xlIjoidXNlciIsImlhdCI6MTU4ODczOTg3NywiZXhwIjoxNTg4NzksxjgzMDc3fQ.LJ3YQJMrVX4go-NZ_nfEdT7lrsmFD6kv9WAnDXB3w2ZXDmXn7eJJ5posUxOp5jfu32jpMCNdFywquQ
The token goes through the API gateway created through Cloud endpoints (Take it easy on me, Im new to Google Cloud Endpoints.). So what am I missing and how would I pass the token in?
swagger: '2.0'
info:
title: API Gateway
description: Description
version: 1.0.0
host: {host}
schemes:
- https
paths:
/auth/token/decode:
get:
summary: Auth Endpoint - Decode Token
operationId: auth_endpoint_decode
x-google-backend:
address: {backend-host}
protocol: h2
responses:
200:
description: "Token Decoded"
400:
description: "Page Error"
/auth/token/create:
post:
summary: Auth Endpoint - Create Token
operationId: auth_endpoint_create
parameters:
- description: "Message to echo"
in: body
name: content
required: true
schema:
type: object
properties:
username:
type: string
password:
type: string
x-google-backend:
address: {backend-host-2}
protocol: h2
responses:
200:
description: "Encoded Token"
400:
description: "Page Error"
So what Im trying to achieve is for the client to be able to pass back the token that was created and for that token to make it into my Node service so that it can be decoded.
Any help is greatly appreciated.. Thank You..
Update:
I found that there is a token being passed into my backend service. It just isn't the same as the token that I passed in. So the token I am passing in from the frontend is:
eyJhbGciOiJSUz21Ni5sIn65cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiWHZYSlZuZDdRZnhMMXZwZ0dTcWwiLCJyb2xlIjoddXN6ciIsImlhdCI6MTU4ODc3NTgyMSwiZXhwIjoxNTg4ODE5MDIxLCJpc3MiOiJhdXRoLXNlc4ZpY2UtbWx5Y3RkNnJlYS11Yy5hLnJ1bi5hcHAifQ.oBI7MaK08Tbg9PQ5vRahdZAS_nhKOWqu4EG5onyNA587KBf2A50eFLRFfkB3AY6t5RXBIbOvUQCXS6UQup1RPg
And the token passed into my backend is a much longer token:
eyJhbGciOiJSUzI14iIsImtpZCI6Ijc0YmQ4NmZjNjFlNGM2Y2L0NTAxMjZmZjRlMzhiMDY5YjhmOGYzNWMiLCJ0eX5iOiJKV1QifQ.eyJhdWQiOiJodFRwczovL2F1dGgtc2VydmljZS1xYmZmNHd0YWNxLXVjLmEucnVuLmFwcC9hdXRoL3Rva2VuL2RlY29kZSIsImF6cCI6IjEwNjAwNzMxMjY3MTM0MTM3MzA3MCIsImVtYWlsIjoiMTExOGA4MjE1NjQ4LWNvbXB1dGVAZGV2ZWxvcGVyLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ7bWFpbF92ZXJpZmllZCI6dHJ1ZSwiZXhwIjoxNTg4Nzc5MTgyLCJpYXQiOjE1ODg7NzU1ODIsImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbSIsInN1YiI6IjEwNjAwNzMxMjY3MTM0MTM3MzA3MCJ9.qLq4aAJ_UxCoHM00fVJpkvTEPkWZ1VTVelvlGktZ6ldDe9LPsHiE1KmyTxjm7HpKouesY8FmL-lopzArroHJSXfFff-VUujTQ6WI-nrHuRMRUzV7a6PwLCCwoDks6Exp04GG9EjweMcb1ZgQQrCTYk1K1SOCD9sZ2VqROEvV0_YNblFsUJS9b9INeacnhrcYDhi6inlSbsVNKpwqBOZJYE5_W9wLAlIK08RUPOmcLaqBD7pvzSYCZps4K75bOev__xT07yizFppAxlVvqB3PTSTFTCeyCnuUFtJ3kmfNf94Uu51jTpTExPKrumdJ18SLnPoopHJG-GCzSJSmccSOTA
Upvotes: 0
Views: 240
Reputation: 75910
If you want to preserve the original authorization
header, you have to deactivate the endpoint auth. Documentation here
In your path, do this:
paths:
/auth/token/decode:
get:
summary: Auth Endpoint - Decode Token
operationId: auth_endpoint_decode
x-google-backend:
address: {backend-host}
protocol: h2
disable_auth: true
responses:
200:
description: "Token Decoded"
400:
description: "Page Error"
Upvotes: 1