Code Review
/
pti
/
o2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Update chart to support the deployment without persistent database"
[pti/o2.git]
/
o2common
/
authmw
/
authprov.py
diff --git
a/o2common/authmw/authprov.py
b/o2common/authmw/authprov.py
index
c6f5646
..
11243df
100644
(file)
--- a/
o2common/authmw/authprov.py
+++ b/
o2common/authmw/authprov.py
@@
-24,14
+24,6
@@
from o2common.config.config import get_reviewer_token
ssl._create_default_https_context = ssl._create_unverified_context
logger = o2logging.get_logger(__name__)
ssl._create_default_https_context = ssl._create_unverified_context
logger = o2logging.get_logger(__name__)
-# read the conf from config file
-auth_prv_conf = get_auth_provider()
-
-try:
- token_review_url = get_review_url()
-except Exception:
- raise Exception('Get k8s token review url failed')
-
class K8SAuthenticaException(Exception):
def __init__(self, value):
class K8SAuthenticaException(Exception):
def __init__(self, value):
@@
-48,6
+40,8
@@
class auth_definer():
def __init__(self, name):
super().__init__()
self.name = name
def __init__(self, name):
super().__init__()
self.name = name
+ # read the conf from config file
+ auth_prv_conf = get_auth_provider()
if auth_prv_conf == 'k8s':
self.obj = k8s_auth_provider('k8s')
else:
if auth_prv_conf == 'k8s':
self.obj = k8s_auth_provider('k8s')
else:
@@
-71,6
+65,10
@@
class k8s_auth_provider(auth_definer):
def __init__(self, name):
self.name = name
def __init__(self, name):
self.name = name
+ try:
+ self.token_review_url = get_review_url()
+ except Exception:
+ raise Exception('Failed to get k8s token review url.')
def tokenissue(self, **args2):
pass
def tokenissue(self, **args2):
pass
@@
-105,7
+103,7
@@
class k8s_auth_provider(auth_definer):
'Content-Type': 'application/json'}
try:
req = urllib.request.Request(
'Content-Type': 'application/json'}
try:
req = urllib.request.Request(
- token_review_url, data=binary_data, headers=header)
+
self.
token_review_url, data=binary_data, headers=header)
response = urllib.request.urlopen(req)
data = json.load(response)
if data['status']['authenticated'] is True:
response = urllib.request.urlopen(req)
data = json.load(response)
if data['status']['authenticated'] is True: