ephraimbuddy commented on a change in pull request #15042: URL: https://github.com/apache/airflow/pull/15042#discussion_r616903339
########## File path: airflow/api_connexion/endpoints/auth_endpoint.py ########## @@ -0,0 +1,158 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +import logging + +from flask import current_app, jsonify, request, session as c_session +from flask_appbuilder.const import AUTH_DB, AUTH_LDAP, AUTH_OAUTH, AUTH_OID, AUTH_REMOTE_USER +from flask_jwt_extended import ( + create_access_token, + decode_token, + get_jwt_identity, + get_raw_jwt, + jwt_refresh_token_required, + jwt_required, +) +from flask_login import login_user +from marshmallow import ValidationError + +from airflow.api_connexion.exceptions import BadRequest, Unauthenticated +from airflow.api_connexion.schemas.auth_schema import info_schema, login_form_schema, token_schema +from airflow.models.auth import TokenBlockList + +log = logging.getLogger(__name__) + + +def get_auth_info(): + """Get site authentication info""" + security_manager = current_app.appbuilder.sm + config = current_app.config + auth_type = security_manager.auth_type + type_mapping = { + AUTH_DB: "auth_db", + AUTH_LDAP: "auth_ldap", + AUTH_OID: "auth_oid", + AUTH_OAUTH: "auth_oauth", + AUTH_REMOTE_USER: "auth_remote_user", + } + oauth_providers = config.get("OAUTH_PROVIDERS", None) + openid_providers = config.get("OPENID_PROVIDERS", None) + return info_schema.dump( + { + "auth_type": type_mapping[auth_type], + "oauth_providers": oauth_providers, + "openid_providers": openid_providers, + } + ) + + +def auth_login(): + """Handle DB login""" + body = request.json + try: + data = login_form_schema.load(body) + except ValidationError as err: + raise Unauthenticated(detail=str(err.messages)) Review comment: I changed it on this commit after some thoughts around it https://github.com/apache/airflow/pull/15042/commits/7ee4136bec40f87e0d1a6a8a34b53144bf3cecb5 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
