Issue 1:
I've changed the directory of caravel.db to a local path.

When I restarted the machine and exeuted the "pip install caravel --upgrade",

input the "caravel db upgrade", the error is "sqlalchemy.exc.OperationalError: (pysqlite2.dbapi2.OperationalError) duplicate column name: verbose_name [SQL: u'ALTER TABLE table_columns ADD COLUMN verbose_name VARCHAR(1024)']"

then I input the "caravel init", and error is "sqlalchemy.exc.OperationalError: (pysqlite2.dbapi2.OperationalError) no such column: sql_metrics.is_restricted [SQL: u'SELECT sql_metrics.created_on AS sql_metrics_created_on, sql_metrics.changed_on AS sql_metrics_changed_on, sql_metrics.id AS sql_metrics_id, sql_metrics.metric_name AS sql_metrics_metric_name, sql_metrics.verbose_name AS sql_metrics_verbose_name, sql_metrics.metric_type AS sql_metrics_metric_type, sql_metrics.table_id AS sql_metrics_table_id, sql_metrics.expression AS sql_metrics_expression, sql_metrics.description AS sql_metrics_description, sql_metrics.is_restricted AS sql_metrics_is_restricted, sql_metrics.changed_by_fk AS sql_metrics_changed_by_fk, sql_metrics.created_by_fk AS sql_metrics_created_by_fk \nFROM sql_metrics']"

I tried many ways to solve this problem, but none of them worked.

Thanks for your solution,

best

Issue 2:
Can't login via OAuth2 LDAP with some issues.

Error with client_id=None

Error ERROR:flask_appbuilder.security.views:Error returning OAuth user info: name 'logging' is not defined

First issue is docs-based, because with config:

'consumer_key':'SOME_CLIENT_ID',
'consumer_secret':'SOME_SECRET'

says Keycloak this: ... type=LOGIN_ERROR, realmId=SOME_REALM, clientId=None, userId=null, ..., so Superset don't care about client_id.

When I've duplicated consumer_key as client_id it started working up to the second problem.

Second problem is Error written above. Keycloak says:

and ERROR:flask_appbuilder.security.views:Error returning OAuth user info: name 'logging' is not defined. IDK what to do :/

Expected results

Successful OAuth2 login

Actual results

Lying docs, can't easily setup OAuth2

How to reproduce the bug

Try to setup OAuth2 with keycloak provider

Environment

superset version: 1.0.1

python version: 3.8.7

node.js version: v12.18.4

Checklist

Make sure to follow these steps before submitting your issue - thank you!

I have checked the superset logs for python stacktraces and included it here as text if there are any.

I have reproduced the issue with at least the latest released version of superset.

I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

superset_config.py

...
#---------------------------------------------------------
# OAuth Config
#---------------------------------------------------------
from custom_sso_security_manager import CustomSsoSecurityManager
CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager

AUTH_TYPE = AUTH_OAUTH
OAUTH_PROVIDERS = [
{ 'name':'SSO',
'token_key':'access_token', # Name of the token in the response of access_token_url
'icon':'fa-address-card', # Icon for the provider
'remote_app': {
'consumer_key':'SOME_CLIENT_ID', # Client Id (Identify Superset application)
'client_id':'SOME_CLIENT_ID', # Client Id (Identify Superset application)
'consumer_secret':'SOME_CLIENT_SECRET', # Secret for this Client Id (Identify Superset application)
'client_secret':'SOME_CLIENT_SECRET', # Secret for this Client Id (Identify Superset application)
'request_token_params':{
'scope': 'email profile' # Scope for the Authorization
},
'access_token_method':'POST', # HTTP Method to call access_token_url
'access_token_params':{ # Additional parameters for calls to access_token_url
'client_id':'SOME_CLIENT_ID'
},
'access_token_headers':{ # Additional headers for calls to access_token_url
'Authorization': 'Basic Base64EncodedClientIdAndSecret'
},
'base_url':'https://<KEYCLOAK_URL>/auth/realms/<REALM>',
'access_token_url':'https://<KEYCLOAK_URL>/auth/realms/<REALM>/protocol/openid-connect/token',
'authorize_url':'https://<KEYCLOAK_URL>/auth/realms/<REALM>/protocol/openid-connect/auth'
}
}
]
...

custom_sso_security_manager.py

from superset.security import SupersetSecurityManager

class CustomSsoSecurityManager(SupersetSecurityManager):

def oauth_user_info(self, provider, response=None):
logging.debug("Oauth2 provider: {0}.".format(provider))
if provider == 'SSO':
# As example, this line request a GET to base_url + '/' + userDetails with Bearer Authentication,
# and expects that authorization server checks the token, and response with user details
me = self.appbuilder.sm.oauth_remotes[provider].get('userDetails').data
logging.debug("user_data: {0}".format(me))
return { 'name' : me['name'], 'email' : me['email'], 'id' : me['user_name'], 'username' : me['user_name'], 'first_name':'', 'last_name':''}
...

It's configured exactly as in docs (except the client ID that's not working as in docs)