aminghadersohi commented on code in PR #37973:
URL: https://github.com/apache/superset/pull/37973#discussion_r2907084894


##########
superset/config.py:
##########
@@ -1633,6 +1633,12 @@ def allowed_schemas_for_csv_upload(  # pylint: 
disable=unused-argument
 FAB_ADD_SECURITY_VIEW_MENU_VIEW = False
 FAB_ADD_SECURITY_PERMISSION_VIEWS_VIEW = False
 
+# API Key Authentication via FAB SecurityManager
+# When enabled, users can create API keys for programmatic access
+# Keys are validated by FAB's @protect() decorator automatically
+FAB_API_KEY_ENABLED = True

Review Comment:
   Done — moved `FAB_API_KEY_ENABLED` from a standalone config into 
`DEFAULT_FEATURE_FLAGS` with `False` as the default. This way it won't show up 
unless explicitly enabled, and it follows the standard feature flag pattern 
used across the codebase.



##########
superset-frontend/src/pages/UserInfo/index.tsx:
##########
@@ -205,6 +209,12 @@ export function UserInfo({ user }: { user: 
UserWithPermissionsAndRoles }) {
               </Descriptions.Item>
             </Descriptions>
           </Collapse.Panel>
+          <Collapse.Panel
+            header={<DescriptionTitle>{t('API Keys')}</DescriptionTitle>}
+            key="apiKeys"
+          >
+            <ApiKeyList />

Review Comment:
   Good call — created a `FAB_API_KEY_ENABLED` feature flag (added to both 
`DEFAULT_FEATURE_FLAGS` in `config.py` and the `FeatureFlag` enum in 
`featureFlags.ts`). The API Keys panel is now gated behind 
`isFeatureEnabled(FeatureFlag.FabApiKeyEnabled)` so it only renders when the 
flag is enabled.



##########
superset/migrations/versions/2026-02-14_12-00_f1a2b3c4d5e6_add_fab_api_key_table.py:
##########
@@ -0,0 +1,71 @@
+# 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.
+"""add FAB api key table
+
+Revision ID: f1a2b3c4d5e6
+Revises: 4b2a8c9d3e1f
+Create Date: 2026-02-14 12:00:00.000000
+
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "f1a2b3c4d5e6"
+down_revision = "4b2a8c9d3e1f"
+
+
+def upgrade():
+    """Create ab_api_key table for FAB API key authentication.
+
+    This table is managed by FAB's SecurityManager. For fresh installs,
+    FAB's create_all() handles table creation. This migration ensures
+    existing Superset installs get the table on upgrade.
+    """
+    conn = op.get_bind()
+    inspector = sa.inspect(conn)
+    if "ab_api_key" in inspector.get_table_names():
+        return
+
+    op.create_table(
+        "ab_api_key",
+        sa.Column("id", sa.Integer(), nullable=False),
+        sa.Column("uuid", sa.String(length=36), nullable=False),
+        sa.Column("name", sa.String(length=256), nullable=False),
+        sa.Column("key_hash", sa.String(length=256), nullable=False),
+        sa.Column("key_prefix", sa.String(length=16), nullable=False),
+        sa.Column("user_id", sa.Integer(), nullable=False),
+        sa.Column("scopes", sa.Text(), nullable=True),
+        sa.Column("active", sa.Boolean(), nullable=False, server_default="1"),

Review Comment:
   Fixed — changed `server_default="1"` to `server_default=sa.text("true")` for 
cross-database compatibility.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to