Skip to content

Commit

Permalink
Support a v3 with latest deck (#104)
Browse files Browse the repository at this point in the history
* v3 to support new deck

* upg flask and jinja

* upd v3 of the api to use new deck
  • Loading branch information
ikethecoder authored Oct 17, 2023
1 parent f69b27a commit 3c7bc99
Show file tree
Hide file tree
Showing 15 changed files with 998 additions and 6 deletions.
6 changes: 6 additions & 0 deletions microservices/gatewayApi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -

#COPY --from=build /deck/deck /usr/local/bin

# gwa api v1/v2
RUN curl -sL https://github.com/kong/deck/releases/download/v1.5.0/deck_1.5.0_linux_amd64.tar.gz -o deck.tar.gz && \
tar -xf deck.tar.gz -C /tmp && \
cp /tmp/deck /usr/local/bin/

# gwa api v3
RUN curl -sL https://github.com/Kong/deck/releases/download/v1.27.1/deck_1.27.1_linux_amd64.tar.gz -o deck.tar.gz && \
tar -xf deck.tar.gz -C /tmp && \
cp /tmp/deck /usr/local/bin/deck127

COPY requirements.txt requirements.txt

RUN pip install -r requirements.txt
Expand Down
2 changes: 2 additions & 0 deletions microservices/gatewayApi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import v1.v1 as v1
import v2.v2 as v2
import v3.v3 as v3

def create_app(test_config=None):

Expand Down Expand Up @@ -43,6 +44,7 @@ def create_app(test_config=None):
##Routes##
v1.Register(app)
v2.Register(app)
v3.Register(app)
Compress(app)

@app.before_request
Expand Down
4 changes: 2 additions & 2 deletions microservices/gatewayApi/clients/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def record_gateway_event(event_id, action, result, namespace, message="", blob="
entity = 'gateway configuration'

actor = "Unknown Actor"
if "clientId" in g.principal:
if 'principal' in g and "clientId" in g.principal:
actor = g.principal["clientId"]
if "name" in g.principal:
if 'principal' in g and "name" in g.principal:
actor = g.principal["name"]

payload = {
Expand Down
3 changes: 2 additions & 1 deletion microservices/gatewayApi/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
werkzeug==2.2.2
ply==3.10
cryptography==38.0.4
authlib==0.15.3
Expand All @@ -21,4 +22,4 @@ pytest-cov==4.0.0
pytest-mock==3.10.0
pycodestyle==2.10.0
pylint==1.7.2
flask-jwt-simple==0.0.3
flask-jwt-simple==0.0.3
5 changes: 3 additions & 2 deletions microservices/gatewayApi/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def openapi_spec(ver:str):
return Response(open("%s/%s.yaml" % (conf.data['workingFolder'], ver)).read(), mimetype='application/x-yaml')

#app.add_url_rule("/%s/docs/openapi.yaml" % version, openapi_spec)
app.register_blueprint(swaggerui_blueprint)

for version in versions:
## Template the spec and write it to a temporary location
Expand All @@ -52,10 +51,12 @@ def openapi_spec(ver:str):
authorization_url = discovery["authorization_endpoint"],
accesstoken_url = discovery["token_endpoint"]
))


log.info("Configured /%s/docs" % version)

app.register_blueprint(swaggerui_blueprint)
log.info("Swagger UI registered")

except:
traceback.print_exc(file=sys.stdout)
log.error("Failed to do OIDC Discovery for %s, sleeping 5 seconds and trying again." % version)
Expand Down
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions microservices/gatewayApi/v3/auth/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from auth.auth import admin_jwt
from auth.authz import enforce_authorization, enforce_role_authorization, users_group_root, admins_group_root, ns_claim
from auth.uma import uma_enforce
Empty file.
Loading

0 comments on commit 3c7bc99

Please sign in to comment.