getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
http://redash.io/
BSD 2-Clause "Simplified" License
25.36k stars 4.3k forks source link

Unable to clear `AWS Secret Key` #7042

Open yktakaha4 opened 3 days ago

yktakaha4 commented 3 days ago

Issue Summary

I can't delete the AWS Secret Key in the Amazon Athena data source credentials from the GUI. This behavior becomes problematic when switching from an IAM user to an instance IAM role.

image

Also, making a request to the POST /api/data_sources/ endpoint didn't change the result, so I guessed that the backend needed to be fixed.

$ curl -XPOST -d '{
  "id": 13,
  "name": "service-logs",
  "type": "athena",
  "syntax": "sql",
  "paused": 0,
  "pause_reason": null,
  "supports_auto_limit": false,
  "options": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "region": "ap-northeast-1",
    "s3_staging_dir": "s3://xxx",
    "schema": "yyy"
  },
  "queue_name": "queries",
  "scheduled_queue_name": "scheduled_queries",
  "groups": {
    "2": false
  }
}' -H "Content-Type: application/json" -H "Authorization: xxx" "https://redash.example.com/api/data_sources/13"

I don't know if similar issues occur with other AWS data sources. (eg. Elasticsearch)

Steps to Reproduce

  1. Create new Amazon Athena Data Source with AWS Secret Key .
  2. Clear AWS Secret Key , then save.
  3. Open again, key will be restored.

Technical details:

yktakaha4 commented 3 days ago

I don't know what to fix yet, but it may be necessary to set an empty string in options or enable operations to delete keys. I would like to create a PR. https://github.com/getredash/redash/blob/9b2f635692741396def5b78e0ba0d564a852de6f/redash/utils/configuration.py#L72-L83