Skip to content

Commit

Permalink
Fix #1202. Note that you can't mix and match HTTP auth services and H…
Browse files Browse the repository at this point in the history
…TTPS auth services. Hmmmm.
  • Loading branch information
Flynn committed Feb 13, 2019
1 parent 2f96503 commit cbe55ec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ambassador/ambassador/ir/irauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def add_mappings(self, ir: 'IR', aconf: Config):
for service, params in cluster_hosts.items():
weight, grpc, ctx_name, location = params

self.logger.debug("IRAuth: svc %s, weight %s, grpc %s, ctx_name %s, location %s" %
(service, weight, grpc, ctx_name, location))

cluster = IRCluster(
ir=ir, aconf=aconf, location=location,
service=service,
Expand Down
7 changes: 6 additions & 1 deletion ambassador/ambassador/ir/ircluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,17 @@ def __init__(self, ir: 'IR', aconf: Config,
# If we have a ctx_name, does it match a real context?
if ctx_name:
if ctx_name is True:
ir.logger.debug("using null context")
ctx = IRTLSContext.null_context(ir=ir)
else:
ir.logger.debug("seeking named context %s" % ctx_name)
ctx = ir.get_tls_context(typecast(str, ctx_name))

if not ctx:
ir.logger.debug("no named context %s" % ctx_name)
errors.append("Originate-TLS context %s is not defined" % ctx_name)
else:
ir.logger.debug("found context %s" % ctx)

# TODO: lots of duplication of here, need to replace with broken down functions

Expand Down Expand Up @@ -155,7 +160,7 @@ def __init__(self, ir: 'IR', aconf: Config,
# Parse the service as a URL. Note that we have to supply a scheme to urllib's
# parser, because it's kind of stupid.

ir.logger.debug("cluster %s service %s" % (name, service))
ir.logger.debug("cluster %s service %s otls %s ctx %s" % (name, service, originate_tls, ctx))
p = urllib.parse.urlparse('random://' + service)

# Is there any junk after the host?
Expand Down
9 changes: 6 additions & 3 deletions ambassador/schemas/v1/AuthService.schema
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
{ "type": "array", "items": { "type": "string" } }
]
},
"proto": {

"auth_service": { "type": "string" },
"path_prefix": { "type": "string" },
"tls": { "type": [ "string", "boolean" ] },

"proto": {
"oneOf" : [
{ "enum": [ "http" ] },
{ "enum": [ "grpc" ] }
]
},
"allow_request_body": { "type": "boolean" },
"auth_service": { "type": "string" },
"timeout_ms": { "type": "integer" },
"path_prefix": { "type": "string" },
"allowed_request_headers": {
"type": "array",
"items": { "type": "string" }
Expand Down
10 changes: 9 additions & 1 deletion ambassador/tests/kat/t_extauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,21 @@ def config(self):
buffer:
max_request_bytes: 16384
max_request_time: 5000
---
apiVersion: ambassador/v1
kind: TLSContext
name: {self.name}-same-context-1
secret: same-secret-1.secret-namespace
---
apiVersion: ambassador/v1
kind: AuthService
name: {self.auth.path.k8s}
auth_service: "{self.auth.path.k8s}"
path_prefix: "/extauth"
timeout_ms: 5000
tls: {self.name}-same-context-1
allowed_request_headers:
- X-Foo
Expand Down Expand Up @@ -265,7 +273,7 @@ def config(self):
prefix: /target/
service: {self.target.path.k8s}
---
apiVersion: ambassador/v0
apiVersion: ambassador/v1
kind: Mapping
name: {self.target.path.k8s}-unauthed
prefix: /target/unauthed/
Expand Down

0 comments on commit cbe55ec

Please sign in to comment.