Reputation: 13484
I am trying to understand how to use Cloud Endpoints with custom authentication. From the docs I understand that it starts from the securityDefinitions
:
securityDefinitions:
your_custom_auth_id:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
# The value below should be unique
x-google-issuer: "issuer of the token"
x-google-jwks_uri: "url to the public key"
# Optional. Replace YOUR-CLIENT-ID with your client ID
x-google-audiences: "YOUR-CLIENT-ID"
This is how I understand the flow:
authorizationUrl
My questions:
How should the authorizationUrl
be implemented. How does the request look, what response should be return in case of success or failure
What about this values? x-google-issuer: "issuer of the token" x-google-jwks_uri: "url to the public key" x-google-audiences: "YOUR-CLIENT-ID"
Upvotes: 5
Views: 2798
Reputation: 115
To configure custom authentication for Endpoints (and according to the OpenAPI v2 spec), you need two pieces:
securityDefinitions
section of the specsecurity
field.The Google Cloud Endpoints docs describe this here.
Some fields in the SecurityDefinitions section of the OpenAPI spec are for the API producer, and some are for the API consumer.
The following fields are for the API producer and tell Endpoints how to validate the access tokens that accompany API requests:
These fields are specified by the API producer and tell the consumer how to get a valid access token:
x-google-jwks_uri
property of the spec and ensures that the issuer of the token matches the issuer specified in the securityDefinition's x-google-issuer
field.Regarding your questions, the authorizationUrl
should be set up by the OAuth2 provider you are using. That url should allow the consumer to execute the implicit OAuth2 flow to get an access token. All you need to do is specify this
Upvotes: 2