forked from snowflakedb/snowflake-connector-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_by_plugin.py
44 lines (36 loc) · 1.25 KB
/
auth_by_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
#
from .errors import Error, DatabaseError
from .sqlstate import SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED
class AuthByPlugin(object):
"""
External Authenticator interface.
"""
@property
def assertion_content(self):
raise NotImplementedError
def update_body(self, body):
raise NotImplementedError
def authenticate(
self, authenticator, service_name, account, user, password):
raise NotImplementedError
def handle_failure(self, ret):
""" Handles a failure when connecting to Snowflake
Args:
ret: dictionary returned from Snowflake.
"""
Error.errorhandler_wrapper(
self._rest._connection, None, DatabaseError,
{
u'msg': (u"Failed to connect to DB: {host}:{port}, "
u"{message}").format(
host=self._rest._host,
port=self._rest._port,
message=ret[u'message'],
),
u'errno': int(ret.get(u'code', -1)),
u'sqlstate': SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED,
})