codeant-ai-for-open-source[bot] commented on code in PR #37234: URL: https://github.com/apache/superset/pull/37234#discussion_r2824026707
########## superset/views/oauth.py: ########## @@ -0,0 +1,79 @@ +# 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. + +from typing import Optional + +import jwt +from flask import flash, g, get_flashed_messages, redirect, request, session, url_for +from flask_appbuilder import expose +from flask_appbuilder._compat import as_unicode +from flask_appbuilder.security.decorators import no_cache +from flask_appbuilder.security.utils import generate_random_string +from flask_appbuilder.security.views import AuthOAuthView, WerkzeugResponse + +from superset.views.base import BaseSupersetView + + +class SupersetOAuthView(BaseSupersetView, AuthOAuthView): + route_base = "/login" + + @expose("/") + @expose("/<provider>") + @no_cache + def login(self, provider: Optional[str] = None) -> WerkzeugResponse: + get_flashed_messages(category_filter=["danger"]) + + if provider is None: + providers = [k for k in self.appbuilder.sm.oauth_remotes.keys()] Review Comment: **Suggestion:** The automatic skipping of the provider selection screen when there is a single OAuth provider happens unconditionally, ignoring the `OAUTH_SKIP_PROVIDER_SELECTION` feature flag described in the PR; this means the behavior cannot be toggled and will always skip selection, which contradicts the intended feature-flagged behavior. [logic error] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ⚠️ Feature flag OAUTH_SKIP_PROVIDER_SELECTION has no effect. - ⚠️ Provider selection UI cannot be preserved when desired. - ⚠️ Cannot safely roll out skip-selection behavior gradually. ``` </details> ```suggestion if provider is None and self.appbuilder.app.config.get("OAUTH_SKIP_PROVIDER_SELECTION"): ``` <details> <summary><b>Steps of Reproduction ✅ </b></summary> ```mdx 1. Start Superset with this PR code and configure a single OAuth provider (e.g. Google) so that `self.appbuilder.sm.oauth_remotes` in `superset/views/oauth.py:41` contains exactly one key. 2. Ensure the feature flag `OAUTH_SKIP_PROVIDER_SELECTION` is unset or set to `False` in the Flask config accessed via `self.appbuilder.app.config` (so the intended behavior is to NOT auto-skip). 3. In a fresh browser session (no authenticated user), send `GET /login` which is handled by `SupersetOAuthView.login` at `superset/views/oauth.py:37` with `provider=None`. 4. Observe that the block at `superset/views/oauth.py:41-44` unconditionally sets `provider` to the only configured provider and the code proceeds past the template-rendering branch at `superset/views/oauth.py:48-53`, directly initiating the OAuth redirect, meaning the provider selection screen is always skipped regardless of the `OAUTH_SKIP_PROVIDER_SELECTION` flag. ``` </details> <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/views/oauth.py **Line:** 41:41 **Comment:** *Logic Error: The automatic skipping of the provider selection screen when there is a single OAuth provider happens unconditionally, ignoring the `OAUTH_SKIP_PROVIDER_SELECTION` feature flag described in the PR; this means the behavior cannot be toggled and will always skip selection, which contradicts the intended feature-flagged behavior. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37234&comment_hash=2089baa06fc74fa2dc9be98696e34a04a1cd4597dbeb22dd0c8d4ec4540b2259&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37234&comment_hash=2089baa06fc74fa2dc9be98696e34a04a1cd4597dbeb22dd0c8d4ec4540b2259&reaction=dislike'>👎</a> -- 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]
