mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 17:38:54 +00:00
Merge pull request #623 from stanhu/support-mysql-ssl
Feature: support MySQL over SSL
This commit is contained in:
commit
eb5c4dd5f3
@ -49,6 +49,10 @@
|
||||
prop.type = 'file';
|
||||
}
|
||||
|
||||
if (prop.type == 'boolean') {
|
||||
prop.type = 'checkbox';
|
||||
}
|
||||
|
||||
prop.required = _.contains(type.configuration_schema.required, name);
|
||||
});
|
||||
});
|
||||
|
@ -46,9 +46,25 @@ class Mysql(BaseQueryRunner):
|
||||
'type': 'string',
|
||||
'title': 'Database name'
|
||||
},
|
||||
"port": {
|
||||
"type": "number"
|
||||
'port': {
|
||||
'type': 'number'
|
||||
},
|
||||
'use_ssl': {
|
||||
'type': 'boolean',
|
||||
'title': 'Use SSL'
|
||||
},
|
||||
'ssl_cacert': {
|
||||
'type': 'string',
|
||||
'title': 'Path to CA certificate file to verify peer against (SSL)'
|
||||
},
|
||||
'ssl_cert': {
|
||||
'type': 'string',
|
||||
'title': 'Path to client certificate file (SSL)'
|
||||
},
|
||||
'ssl_key': {
|
||||
'type': 'string',
|
||||
'title': 'Path to private key file (SSL)'
|
||||
}
|
||||
},
|
||||
'required': ['db'],
|
||||
'secret': ['passwd']
|
||||
@ -111,7 +127,8 @@ class Mysql(BaseQueryRunner):
|
||||
passwd=self.configuration.get('passwd', ''),
|
||||
db=self.configuration['db'],
|
||||
port=self.configuration.get('port', 3306),
|
||||
charset='utf8', use_unicode=True)
|
||||
charset='utf8', use_unicode=True,
|
||||
ssl=self._get_ssl_parameters())
|
||||
cursor = connection.cursor()
|
||||
logger.debug("MySQL running query: %s", query)
|
||||
cursor.execute(query)
|
||||
@ -145,4 +162,19 @@ class Mysql(BaseQueryRunner):
|
||||
|
||||
return json_data, error
|
||||
|
||||
def _get_ssl_parameters(self):
|
||||
ssl_params = {}
|
||||
|
||||
if self.configuration.get('use_ssl'):
|
||||
config_map = dict(ssl_cacert='ca',
|
||||
ssl_cert='cert',
|
||||
ssl_key='key')
|
||||
for key, cfg in config_map.items():
|
||||
val = self.configuration.get(key)
|
||||
if val:
|
||||
ssl_params[cfg] = val
|
||||
|
||||
return ssl_params
|
||||
|
||||
|
||||
register(Mysql)
|
||||
|
Loading…
Reference in New Issue
Block a user