FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
databricks-sql-python/src/databricks/sql/auth/auth_utils.py at main · databricks/databricks-sql-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
databricks
/
databricks-sql-python
Public
Notifications
You must be signed in to change notification settings
Fork
147
Star
233
Code
Issues
99
Pull requests
78
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
databricks-sql-python
/
src
/
databricks
/
sql
/
auth
/
auth_utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (38 loc) · 1.26 KB
Breadcrumbs
databricks-sql-python
/
src
/
databricks
/
sql
/
auth
/
auth_utils.py
Copy path
File metadata and controls
47 lines (38 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
import
logging
import
jwt
from
datetime
import
datetime
,
timedelta
from
typing
import
Optional
,
Dict
,
Tuple
from
urllib
.
parse
import
urlparse
logger
=
logging
.
getLogger
(
__name__
)
def
decode_token
(
access_token
:
str
)
->
Optional
[
Dict
]:
"""
Decode a JWT token without verification to extract claims.
Args:
access_token: The JWT access token to decode
Returns:
Decoded token claims or None if decoding fails
"""
try
:
return
jwt
.
decode
(
access_token
,
options
=
{
"verify_signature"
:
False
})
except
Exception
as
e
:
logger
.
debug
(
"Failed to decode JWT token: %s"
,
e
)
return
None
def
is_same_host
(
url1
:
str
,
url2
:
str
)
->
bool
:
"""
Check if two URLs have the same host.
Args:
url1: First URL
url2: Second URL
Returns:
True if hosts are the same, False otherwise
"""
try
:
host1
=
urlparse
(
url1
).
netloc
host2
=
urlparse
(
url2
).
netloc
# Handle port differences (e.g., example.com vs example.com:443)
host1_without_port
=
host1
.
split
(
":"
)[
0
]
host2_without_port
=
host2
.
split
(
":"
)[
0
]
return
host1_without_port
==
host2_without_port
except
Exception
as
e
:
logger
.
debug
(
"Failed to parse URLs: %s"
,
e
)
return
False
Back
|
FazBrowse Home
|
New Git URL