Skip to content

Commit 9723e5f

Browse files
GrumpyCat51Yannick Suter
and
Yannick Suter
authored
docs: Update oauth keycloak example with new security manager (#50284)
* update oauth example with new security manager * Update webserver-authentication.rst --------- Co-authored-by: Yannick Suter <yannick.suter@reprisk.com>
1 parent 651a6dc commit 9723e5f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

providers/fab/docs/auth-manager/webserver-authentication.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ Here is an example of what you might have in your webserver_config.py:
232232

233233
.. code-block:: python
234234
235-
import os
236-
import jwt
237-
import requests
238235
import logging
239236
from base64 import b64decode
237+
238+
import jwt
239+
import requests
240240
from cryptography.hazmat.primitives import serialization
241-
from flask_appbuilder.security.manager import AUTH_DB, AUTH_OAUTH
242-
from airflow import configuration as conf
243-
from airflow.www.security import AirflowSecurityManager
241+
from flask_appbuilder.security.manager import AUTH_OAUTH
242+
243+
from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride
244244
245245
log = logging.getLogger(__name__)
246246
@@ -284,11 +284,11 @@ Here is an example of what you might have in your webserver_config.py:
284284
public_key = serialization.load_der_public_key(key_der)
285285
286286
287-
class CustomSecurityManager(AirflowSecurityManager):
287+
class CustomSecurityManager(FabAirflowSecurityManagerOverride):
288288
def get_oauth_user_info(self, provider, response):
289289
if provider == "keycloak":
290290
token = response["access_token"]
291-
me = jwt.decode(token, public_key, algorithms=["HS256", "RS256"])
291+
me = jwt.decode(token, public_key, algorithms=["HS256", "RS256"], audience="account")
292292
293293
# Extract roles from resource access
294294
realm_access = me.get("realm_access", {})

0 commit comments

Comments
 (0)