Configuring OAuth using GlobalConfig

EnRoute Technical Reference

EnRoute can be configured to authenticate requests using OAuth.

Here is a GlobalConfig to configure Google Authentication

Creating Client to configure OAuth in Google API Console

Using Google as an identity provider, needs creating an OAuth Client. Create the OAuth Client using the credentials

Create credentials of type OAuth Client Id

Select OAuth ClientId

The application type should be web-application

Select OAuth ClientId

Provide a name and authorized urls. The authorized urls is the domain name of your url and the path on which the application can be accessed

Select OAuth ClientId

Once the application is created, note the client ID and Client secret. This will be used to configure EnRoute

Select OAuth ClientId

Fetch the OIDC Wellknown config

curl -s

The output of above command is -

 "issuer": "",
 "authorization_endpoint": "",
 "device_authorization_endpoint": "",
 "token_endpoint": "",
 "userinfo_endpoint": "",
 "revocation_endpoint": "",
 "jwks_uri": "",
 "response_types_supported": [
  "code token",
  "code id_token",
  "token id_token",
  "code token id_token",
 "subject_types_supported": [
 "id_token_signing_alg_values_supported": [
 "scopes_supported": [
 "token_endpoint_auth_methods_supported": [
 "claims_supported": [
 "code_challenge_methods_supported": [
 "grant_types_supported": [

Note the different endpoints in the above configuration that we’ll be using

Secrets to support OAuth

In this step, we create the Client Secret and HMAC Secret

The Client Secret is the one we received when we created the OAuth Client in the earlier step

kubectl create secret generic clientsecret2 --from-literal=clientsecret=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

The HMAC secret is the one used to create cookies from access token

HMACSECRET=`head -c 32 /dev/urandom`
kubectl create secret generic hmacsecret --from-literal=hmacsecret=$HMACSECRET

ExternalService to connect to Google Authentication Serivce

kind: Service
apiVersion: v1
  name: google-oauth2
  namespace: default
  type: ExternalName
  - port: 443
    protocol: TCP
    targetPort: 443

GlobalConfig for OAuth with Google

We now create the GlobalConfig to configure authentication using the client, secret and externalservice created in the step above

kind: GlobalConfig
  name: enroute-globalconfig-oauth
  namespace: default
  config: |
     "openid_connect" : {
        "provider": {
           "authorization_endpoint" : "",
           "token_endpoint"         : ""
        "client_id": "",
        "client_secret" : "clientsecret",
        "hmac_secret" : "hmacsecret",
        "client_secret_namespace" : "default",
        "hmac_secret_namespace" : "default",
        "scopes" : ["email"],
        "redirect_url" : "%REQ(x-forwarded-proto)%://%REQ(:authority)%/oauth2/callback",
        "redirect_path_matcher" : "/oauth2/callback",
        "default_signout_path" : "/signout"
     "external_oauth_service" : {
        "name"      : "google-oauth2",
        "namespace" : "default",
        "port"      : 443,
        "protocol"  : "tls"
  name: enroute-globalconfig-oauth
  type: globalconfig_oauth

When a GatewayHost is configured for the domain, all the requests will undergo OAuth authentication

kind: GatewayHost
    app: httpbin
  name: httpbin-9000-gatewayhost-httpbin-host
  namespace: httpbin
  - conditions:
    - prefix: /
    - name: httpbin
      port: 9000
    fqdn: ''
      secretName: saaraslabs