summaryrefslogtreecommitdiff
path: root/src/services/vyos-http-api-server
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-10-23 11:08:06 -0500
committerJohn Estabrook <jestabro@vyos.io>2022-10-25 10:35:48 -0500
commit28676844e3f4317786e457fcd8651939a05c88ff (patch)
tree1031b5079f076584a9c9a40833d4452bf33106d4 /src/services/vyos-http-api-server
parentaf56ddf4615974c6b5f5886520d6abb0781cea80 (diff)
downloadvyos-1x-28676844e3f4317786e457fcd8651939a05c88ff.tar.gz
vyos-1x-28676844e3f4317786e457fcd8651939a05c88ff.zip
graphql: T4574: add context to read token in queries/mutations
Diffstat (limited to 'src/services/vyos-http-api-server')
-rwxr-xr-xsrc/services/vyos-http-api-server5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server
index 7a35546e5..840041b73 100755
--- a/src/services/vyos-http-api-server
+++ b/src/services/vyos-http-api-server
@@ -647,6 +647,7 @@ def reset_op(data: ResetModel):
###
def graphql_init(fast_api_app):
+ from api.graphql.libs.token_auth import get_user_context
api.graphql.state.init()
api.graphql.state.settings['app'] = app
@@ -658,9 +659,9 @@ def graphql_init(fast_api_app):
if app.state.vyos_origins:
origins = app.state.vyos_origins
- app.add_route('/graphql', CORSMiddleware(GraphQL(schema, debug=True, introspection=in_spec), allow_origins=origins, allow_methods=("GET", "POST", "OPTIONS")))
+ app.add_route('/graphql', CORSMiddleware(GraphQL(schema, context_value=get_user_context, debug=True, introspection=in_spec), allow_origins=origins, allow_methods=("GET", "POST", "OPTIONS")))
else:
- app.add_route('/graphql', GraphQL(schema, debug=True, introspection=in_spec))
+ app.add_route('/graphql', GraphQL(schema, context_value=get_user_context, debug=True, introspection=in_spec))
###