def __init__(self): """Constructor Populates self.redfish with SessionService response. """ super().__init__(self.SCHEMA_NAME) self.redfish["@odata.type"] = self.get_odata_type() self.redfish["@odata.context"] = "/redfish/v1/$metadata" \ "#SessionService.SessionService" self.redfish["@odata.id"] = self.BASE_URI self.redfish["Id"] = "SessionService" self.redfish["Name"] = "Session Service" self.redfish["Description"] = "Session service" # Enable Session Service only when authentication mode is session if config.auth_mode_is_session(): self.redfish["ServiceEnabled"] = True self.redfish["Sessions"] = { "@odata.id": self.BASE_URI + "/Sessions" } else: self.redfish["ServiceEnabled"] = False self._validate()
def hp_oneview_client_exception(exception): logging.exception(exception) response = ResponseBuilder.error_by_hp_oneview_exception(exception) # checking if session has expired on Oneview if config.auth_mode_is_session() and \ response.status_code == status.HTTP_401_UNAUTHORIZED: token = request.headers.get('x-auth-token') client_session.clear_session_by_token(token) return response
def _add_subscription_to_file(subscription): file_content = get_file_content() if file_content: if not file_content.get('members'): # On first subscription request, start SCMB service if config.auth_mode_is_session(): token = request.headers.get('x-auth-token') scmb.init_event_service(token) else: scmb.init_event_service() file_content['members'].append(subscription) _update_all_subscription(file_content)
def check_authentication(): # If authenticating do not check for anything if request.url_rule and \ request.url_rule.rule == SessionCollection.BASE_URI and \ request.method == "POST": return None if connection.is_service_root(): return None if config.auth_mode_is_session(): x_auth_token = request.headers.get('x-auth-token') client_session.check_authentication(x_auth_token) g.oneview_client = \ handler_multiple_oneview.MultipleOneViewResource()
def add_session_service_endpoints(self): self.redfish["SessionService"] = {"@odata.id": SessionService.BASE_URI} self.redfish["Links"] = {"Sessions": {}} if config.auth_mode_is_session(): self.redfish['Links']['Sessions']['@odata.id'] = \ SessionService.BASE_URI + "/Sessions"