from o2common.config.config import get_review_url
from o2common.helper import o2logging
+AUTH_ENABLED = True
+FLASK_API_VERSION = '1.0.0'
+
# apibase = config.get_o2ims_api_base()
-auth = True
app = Flask(__name__)
logger = o2logging.get_logger(__name__)
raise Exception('Get k8s token review url failed')
-FLASK_API_VERSION = '1.0.0'
-
-if auth:
+if AUTH_ENABLED:
# perform service account identity&privilege check.
_get_k8s_url()
ad = authprov.auth_definer('ad')
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):
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:
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
'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: