<p>Is it possible to use spring cloud oauth 2 server with kubernetes api gateway ingress. </p>

<p>I have used it with zuul to authenticate user before making a call.  Can I do similar with ingress? </p>

<p><strong>Edit 1:</strong></p>

<p>To explain it more clearly, what I am trying to achieve</p>

<p>I am using token based oAuth2 implementation given by the spring cloud.</p>

<ol>
<li>oauth is running as one of the service behind the zuul.</li>
<li>zuul has routes mapped for the oauth server and resource server</li>
<li>client call the auth server via zuul and gets the token.</li>
<li>client call resource server via zuul with token passed</li>
<li>zuul is configured to validate the token before making a call to resource server.</li>
</ol>

<p>In this way we can stop any downstream traffic to go without a valid token.</p>

<p>can we do token validation in ingress with auth server running with in a cluster?</p>

Chandresh Mishra
<p>I have not used Spring Cloud OAuth 2 but as OAuth is a standard I believe you can set it up if you are using Nginx Ingress as the ingress controller, you can specify and external Oauth Provider (As OAuth generally has the same flow) like this on your ingress:</p>

<pre><code>...
metadata:
  name: application
  annotations:
    nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
    nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
...
</code></pre>

<p>You can find more information <a href="https://github.com/kubernetes/ingress-nginx/tree/master/docs/examples/auth/oauth-external-auth" rel="nofollow noreferrer">here</a> with an example of using GitHub as an OAuth provider</p>
