forked from snowflakedb/snowflake-connector-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth_idtoken.py
32 lines (24 loc) · 980 Bytes
/
auth_idtoken.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2020 Snowflake Computing Inc. All right reserved.
#
from .auth_by_plugin import AuthByPlugin
from .network import ID_TOKEN_AUTHENTICATOR
class AuthByIdToken(AuthByPlugin):
"""Internal IdToken Based Authentication.
Works by accepting an id_toke and use that to authenticate. Only be used when users are using EXTERNAL_BROWSER_AUTHENTICATOR
"""
@property
def assertion_content(self):
return self._id_token
def __init__(self, id_token):
"""Initialized an instance with an IdToken."""
self._id_token = id_token
def authenticate(self, authenticator, service_name, account, user, password):
"""Nothing to do here."""
pass
def update_body(self, body):
"""Idtoken needs the authenticator and token attributes set."""
body[u'data'][u'AUTHENTICATOR'] = ID_TOKEN_AUTHENTICATOR
body[u'data'][u'TOKEN'] = self._id_token