You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gpchandran (via GitHub)" <gi...@apache.org> on 2024/08/20 02:21:54 UTC

[I] Forbidden error when selecting database when Dataset creation or SQLab [superset]

gpchandran opened a new issue, #29971:
URL: https://github.com/apache/superset/issues/29971

   ### Bug description
   
   1. Installed Apache 4.0.2 with Azure Postgres DB as metadata DB
   2. Created Snowflake DB connection and Test Connection Successful
   3. On the Create Dataset UI, when I try to select Database , getting Forbidden 403 from UI,  Debug enabled in Logs but not seeing any erros in logs
   
   ### How to reproduce the bug
   
   1. Install Apache Superset 4.0.2 in AKS using with managed Azure Managed Postgres DB
   2. Login with Admin user
   3. Create Snowflake or Postgress DB connection and make sure test connection  is successful
   4. Go to Dataset Tab and click on the create dataset option
   5. Select Database, getting forbidden error here
   6. PFA screenshot
   
   ### Screenshots/recordings
   
   <img width="1344" alt="image" src="https://github.com/user-attachments/assets/53e94bcc-8b14-4c58-b15e-830321306f17">
   
   
   ### Superset version
   
   4.0.2
   
   ### Python version
   
   3.10
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database from Dataset creation or SQLab [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29971:
URL: https://github.com/apache/superset/issues/29971#issuecomment-2297876222

   <!-- Answer -->
   Given that the database connection is successful and an admin user is being used, the "403 Forbidden" error is likely due to a misconfiguration or a bug in the permission settings. Here are some steps to further investigate and resolve the issue:
   
   1. **Verify Admin Permissions**:
      Even though the admin role should have all necessary permissions, double-check that the admin role includes `database_access` and `schema_access` permissions for the relevant database and schema. The admin role should have all possible rights, including access to all databases by default <sup>[[1]](https://github.com/apache/superset/blob/master/docs/docs/security/security.mdx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/RESOURCES/STANDARD_ROLES.md)</sup>.
   
   2. **Check Security Manager Configuration**:
      Ensure that the `security_manager` is correctly configured to grant the necessary permissions. The `raise_for_access` method in the `security_manager` is responsible for checking access permissions. If the user does not have the necessary permissions, a `SupersetSecurityException` is raised <sup>[[3]](https://github.com/apache/superset/blob/master/superset/commands/dataset/create.py)</sup>.
   
   3. **Feature Flags and Configuration**:
      Review the `superset_config.py` file for any feature flags or configuration settings that might affect database access permissions. Specifically, check the `ENABLE_SUPERSET_META_DB` and `SSH_TUNNELING` feature flags <sup>[[4]](https://github.com/apache/superset/blob/master/superset/config.py)</sup>.
   
   4. **Known Issues**:
      There is a known issue in Apache Superset 4.0.2 related to database access permissions that could cause a "403 Forbidden" error. The `QueryIsForbiddenToAccessException` class indicates that a "403 Forbidden" error can occur due to query security access issues <sup>[[5]](https://github.com/apache/superset/blob/master/superset/sqllab/exceptions.py)</sup><sup>[[6]](https://github.com/apache/superset/blob/master/superset/databases/api.py)</sup><sup>[[7]](https://github.com/apache/superset/blob/master/superset/security/manager.py)</sup>.
   
   By ensuring that the admin user has the correct permissions and that the security manager and configuration settings are properly set, you should be able to resolve the "403 Forbidden" error. If the issue persists, it might be worth checking for any updates or patches for Apache Superset that address this specific issue.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database from Dataset creation or SQLab [superset]

Posted by "gpchandran (via GitHub)" <gi...@apache.org>.
gpchandran closed issue #29971: Forbidden error when selecting database from Dataset creation or SQLab
URL: https://github.com/apache/superset/issues/29971


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database from Dataset creation or SQLab [superset]

Posted by "gpchandran (via GitHub)" <gi...@apache.org>.
gpchandran commented on issue #29971:
URL: https://github.com/apache/superset/issues/29971#issuecomment-2297874987

   @dosu
   
   1. Database connection successfully created and test connection is successful - so this not a firewall issue or database driver issue
   2. Admin user and role being used for this testing, wouldn't be a permission issue
   Something else going , please advise
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database from Dataset creation or SQLab [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29971:
URL: https://github.com/apache/superset/issues/29971#issuecomment-2297845091

   <!-- Greeting -->
   Hello @gpchandran, I'm here to help you with any bugs, questions, or contributions you might have. Let's work together to resolve this issue.
   
   <!-- Answer -->
   To resolve the "403 Forbidden" error when selecting a database during dataset creation in Apache Superset 4.0.2 with Azure Postgres DB as the metadata database, follow these steps:
   
   1. **Check User Permissions**: Ensure that the user has the necessary permissions to access the database. This includes verifying that the user has the appropriate roles and permissions assigned in Superset.
   
   2. **Superset Security Configuration**: Verify that the Superset security configuration is correctly set up. The `SupersetSecurityException` might be raised if the user does not have the required access permissions.
   
   3. **SQLAlchemy URI Blocklist**: Ensure that the SQLAlchemy URI for the Azure Postgres DB is not being blocked by the `check_sqlalchemy_uri` function. This function checks the URI against a blocklist of unsafe dialects.
   
   4. **Database Drivers**: Make sure you have installed the required database drivers for Azure Postgres DB. Superset requires a Python DB-API database driver and a SQLAlchemy dialect to be installed for each database engine you want to connect to.
   
   5. **Feature Flags**: Ensure that the feature flag `ENABLE_SUPERSET_META_DB` is enabled if you are using Superset as a metadata database.
   
   Here is a relevant part of the code that checks for access permissions:
   
   ```python
   if sql:
       try:
           security_manager.raise_for_access(
               database=database,
               sql=sql,
               catalog=catalog,
               schema=schema,
           )
       except SupersetSecurityException as ex:
           exceptions.append(DatasetDataAccessIsNotAllowed(ex.error.message))
   ```
   
   And the `check_sqlalchemy_uri` function:
   
   ```python
   def check_sqlalchemy_uri(uri: URL) -> None:
       if not feature_flag_manager.is_feature_enabled("ENABLE_SUPERSET_META_DB"):
           BLOCKLIST.add(re.compile(r"superset$"))
   
       for blocklist_regex in BLOCKLIST:
           if not re.match(blocklist_regex, uri.drivername):
               continue
           try:
               dialect = uri.get_dialect().__name__
           except (NoSuchModuleError, ValueError):
               dialect = uri.drivername
   
           raise SupersetSecurityException(
               SupersetError(
                   error_type=SupersetErrorType.DATABASE_SECURITY_ACCESS_ERROR,
                   message=_(
                       "%(dialect)s cannot be used as a data source for security reasons.",
                       dialect=dialect,
                   ),
                   level=ErrorLevel.ERROR,
               )
           )
   ```
   
   By ensuring the user has the correct permissions and the configuration is properly set, you should be able to resolve the "403 Forbidden" error <sup>[[1]](https://github.com/apache/superset/blob/master/superset/commands/dataset/create.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/security/analytics_db_safety.py)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/docs/docs/configuration/databases.mdx)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database when Dataset creation or SQLab [superset]

Posted by "gpchandran (via GitHub)" <gi...@apache.org>.
gpchandran commented on issue #29971:
URL: https://github.com/apache/superset/issues/29971#issuecomment-2297842103

   <img width="1344" alt="image" src="https://github.com/user-attachments/assets/49fa8f10-35fa-4ce8-bc46-506e7b4d8275">
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Forbidden error when selecting database from Dataset creation or SQLab [superset]

Posted by "gpchandran (via GitHub)" <gi...@apache.org>.
gpchandran commented on issue #29971:
URL: https://github.com/apache/superset/issues/29971#issuecomment-2369305703

   Internal  security issue , closing it


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org