Skip to content

Commit

Permalink
feat(jans-cedarling): add well-known authzen configuration endpoint (#…
Browse files Browse the repository at this point in the history
…10435)

* feat(jans-cedarling): add authzen configuration

Signed-off-by: SafinWasi <[email protected]>

* docs(jans-cedarling): update openapi

Signed-off-by: SafinWasi <[email protected]>

* chore(jans-cedarling): add log level to options

Signed-off-by: SafinWasi <[email protected]>

* chore: use hostname

Signed-off-by: SafinWasi <[email protected]>

---------

Signed-off-by: SafinWasi <[email protected]>
  • Loading branch information
SafinWasi authored Dec 18, 2024
1 parent 2bb25f1 commit cc6fc7b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
19 changes: 19 additions & 0 deletions jans-cedarling/flask-sidecar/flask-sidecar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,30 @@ components:
- id
- type
type: object
WellKnown:
properties:
access_evaluation_v1_endpoint:
type: string
type: object
info:
title: Cedarling Sidecar
version: v1
openapi: 3.0.0
paths:
/.well-known/authzen-configuration:
get:
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/WellKnown'
description: OK
default:
$ref: '#/components/responses/DEFAULT_ERROR'
summary: Returns authzen configuration endpoint
tags:
- Evaluate
/cedarling/evaluation:
post:
requestBody:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from main.v1.resource import blp as evaluation_routes

def register_routes(app):
app.register_blueprint(evaluation_routes, url_prefix="/cedarling")
app.register_blueprint(evaluation_routes, url_prefix="")
17 changes: 15 additions & 2 deletions jans-cedarling/flask-sidecar/main/v1/resource.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from main.extensions import BlueprintApi
from main.v1.schema import EvaluationRequestSchema, DecisionSchema
from main.v1.schema import EvaluationRequestSchema, DecisionSchema, WellKnownSchema
from flask.views import MethodView
from flask import request
from main.extensions import cedarling

blp = BlueprintApi("Evaluate",
__name__,
description="AuthZen evaluation endpoint")

@blp.route("/evaluation")
@blp.route("/cedarling/evaluation")
class Evaluation(MethodView):
@blp.arguments(EvaluationRequestSchema, location="json")
@blp.response(200, DecisionSchema)
Expand All @@ -22,3 +23,15 @@ def post(self, payload):
payload.get("context", {})
)
return auth_response

@blp.route("/.well-known/authzen-configuration")
class WellKnown(MethodView):
@blp.response(200, WellKnownSchema)
def get(self):
"""
Returns authzen configuration endpoint
"""
response = {
"access_evaluation_v1_endpoint": f"{request.host_url}cedarling/evaluation"
}
return response
3 changes: 3 additions & 0 deletions jans-cedarling/flask-sidecar/main/v1/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ class EvaluationRequestSchema(BaseSchema):
class DecisionSchema(BaseSchema):
decision = ma.fields.Bool(required=True)
context = ma.fields.Dict()

class WellKnownSchema(BaseSchema):
access_evaluation_v1_endpoint = ma.fields.Str()
1 change: 1 addition & 0 deletions jans-cedarling/flask-sidecar/secrets/bootstrap.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"CEDARLING_POLICY_STORE_URI": "https://gluu.org",
"CEDARLING_POLICY_STORE_ID": "gICAgcHJpbmNpcGFsIGlz",
"CEDARLING_LOG_TYPE": "std_out",
"CEDARLING_LOG_LEVEL": "INFO",
"CEDARLING_LOG_TTL": null,
"CEDARLING_USER_AUTHZ": "enabled",
"CEDARLING_WORKLOAD_AUTHZ": "enabled",
Expand Down

0 comments on commit cc6fc7b

Please sign in to comment.