Removed circular reference
Trying to fix logging
This commit is contained in:
		| @@ -2,8 +2,9 @@ | |||||||
|  |  | ||||||
| import re | import re | ||||||
| import base64 | import base64 | ||||||
| from cgi import parse_qs | #from cgi import parse_qs | ||||||
| from saml2 import server | from urlparse import parse_qs | ||||||
|  | from saml2 import server, root_logger | ||||||
| from saml2 import BINDING_HTTP_REDIRECT, BINDING_HTTP_POST | from saml2 import BINDING_HTTP_REDIRECT, BINDING_HTTP_POST | ||||||
| from saml2 import time_util | from saml2 import time_util | ||||||
| from Cookie import SimpleCookie | from Cookie import SimpleCookie | ||||||
| @@ -157,7 +158,8 @@ def slo(environ, start_response, user, logger): | |||||||
|         logger.info("REQ_INFO: %s" % req_info.message) |         logger.info("REQ_INFO: %s" % req_info.message) | ||||||
|     except KeyError, exc: |     except KeyError, exc: | ||||||
|         if logger: logger.info("logout request error: %s" % (exc,)) |         if logger: logger.info("logout request error: %s" % (exc,)) | ||||||
|         # return error reply |         start_response('400 Bad request', [('Content-Type', 'text/plain')]) | ||||||
|  |         return ['Request parse error'] | ||||||
|  |  | ||||||
|     # look for the subject |     # look for the subject | ||||||
|     subject = req_info.subject_id() |     subject = req_info.subject_id() | ||||||
| @@ -259,10 +261,16 @@ if __name__ == '__main__': | |||||||
|     import sys |     import sys | ||||||
|     from wsgiref.simple_server import make_server |     from wsgiref.simple_server import make_server | ||||||
|     import logging |     import logging | ||||||
|     LOG_FILENAME = "./idp.log" |     from saml2.config import LOG_FORMAT, LOG_HANDLER | ||||||
|     PORT = 8088 |  | ||||||
|  |  | ||||||
|     logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)     |     handler = LOG_HANDLER["rotating"]("./idp.log") | ||||||
|  |     formatter = logging.Formatter(LOG_FORMAT) | ||||||
|  |     handler.setFormatter(formatter) | ||||||
|  |     root_logger.addHandler(handler) | ||||||
|  |     root_logger.info("Logging started") | ||||||
|  |     root_logger.setLevel(logging.INFO) | ||||||
|  |  | ||||||
|  |     PORT = 8088 | ||||||
|  |  | ||||||
|     IDP = server.Server(sys.argv[1]) |     IDP = server.Server(sys.argv[1]) | ||||||
|     SRV = make_server('localhost', PORT, APP_WITH_AUTH) |     SRV = make_server('localhost', PORT, APP_WITH_AUTH) | ||||||
|   | |||||||
| @@ -15,7 +15,6 @@ reissue_time = 3000 | |||||||
| use = s2repoze.plugins.sp:make_plugin | use = s2repoze.plugins.sp:make_plugin | ||||||
| saml_conf = sp_conf | saml_conf = sp_conf | ||||||
| rememberer_name = auth_tkt | rememberer_name = auth_tkt | ||||||
| debug = 1 |  | ||||||
| sid_store = outstanding | sid_store = outstanding | ||||||
| identity_cache = identities | identity_cache = identities | ||||||
|  |  | ||||||
|   | |||||||
| @@ -510,7 +510,8 @@ def make_plugin(rememberer_name=None, # plugin for remember | |||||||
|                  wayf="", |                  wayf="", | ||||||
|                  sid_store="", |                  sid_store="", | ||||||
|                  identity_cache="", |                  identity_cache="", | ||||||
|                  discovery="" |                  discovery="", | ||||||
|  |                  debug=0 | ||||||
|                  ): |                  ): | ||||||
|      |      | ||||||
|     if saml_conf is "": |     if saml_conf is "": | ||||||
|   | |||||||
| @@ -19,25 +19,21 @@ | |||||||
| Contains classes and functions that a SAML2.0 Service Provider (SP) may use | Contains classes and functions that a SAML2.0 Service Provider (SP) may use | ||||||
| to do attribute aggregation. | to do attribute aggregation. | ||||||
| """ | """ | ||||||
| import saml2 |  | ||||||
|  |  | ||||||
| import logging | import logging | ||||||
| from saml2.client import Saml2Client | #from saml2 import client | ||||||
|  | from saml2 import BINDING_SOAP | ||||||
|  |  | ||||||
| logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||||
|  |  | ||||||
| DEFAULT_BINDING = saml2.BINDING_SOAP | DEFAULT_BINDING = BINDING_SOAP | ||||||
|  |  | ||||||
| class AttributeResolver(object): | class AttributeResolver(object): | ||||||
|  |  | ||||||
|     def __init__(self, metadata=None, config=None, saml2client=None): |     def __init__(self, saml2client, metadata=None, config=None): | ||||||
|         self.metadata = metadata |         self.metadata = metadata | ||||||
|  |  | ||||||
|         if saml2client: |         self.saml2client = saml2client | ||||||
|             self.saml2client = saml2client |         self.metadata = saml2client.config.metadata | ||||||
|             self.metadata = saml2client.config.metadata |  | ||||||
|         else: |  | ||||||
|             self.saml2client = Saml2Client(config) |  | ||||||
|  |  | ||||||
|     def extend(self, subject_id, issuer, vo_members, name_id_format=None, |     def extend(self, subject_id, issuer, vo_members, name_id_format=None, | ||||||
|                 sp_name_qualifier=None, real_id=None): |                 sp_name_qualifier=None, real_id=None): | ||||||
| @@ -58,7 +54,7 @@ class AttributeResolver(object): | |||||||
|                 for attr_serv in ass.attribute_service: |                 for attr_serv in ass.attribute_service: | ||||||
|                     logger.info( |                     logger.info( | ||||||
|                             "Send attribute request to %s" % attr_serv.location) |                             "Send attribute request to %s" % attr_serv.location) | ||||||
|                     if attr_serv.binding != saml2.BINDING_SOAP: |                     if attr_serv.binding != BINDING_SOAP: | ||||||
|                         continue |                         continue | ||||||
|                     # attribute query assumes SOAP binding |                     # attribute query assumes SOAP binding | ||||||
|                     session_info = self.saml2client.attribute_query( |                     session_info = self.saml2client.attribute_query( | ||||||
|   | |||||||
| @@ -85,7 +85,7 @@ LOG_HANDLER = { | |||||||
|     "timerotate": logging.handlers.TimedRotatingFileHandler, |     "timerotate": logging.handlers.TimedRotatingFileHandler, | ||||||
| } | } | ||||||
|  |  | ||||||
| LOG_FORMAT = "%(asctime)s %(name)s: %(levelname)s %(message)s" | LOG_FORMAT = "%(asctime)s %(name)s:%(levelname)s %(message)s" | ||||||
|  |  | ||||||
| class ConfigurationError(Exception): | class ConfigurationError(Exception): | ||||||
|     pass |     pass | ||||||
| @@ -311,11 +311,6 @@ class Config(object): | |||||||
|         return handler |         return handler | ||||||
|      |      | ||||||
|     def setup_logger(self): |     def setup_logger(self): | ||||||
|         try: |  | ||||||
|             _logconf = self.logger |  | ||||||
|         except KeyError: |  | ||||||
|             return None |  | ||||||
|  |  | ||||||
|         if root_logger.level != logging.NOTSET: # Someone got there before me |         if root_logger.level != logging.NOTSET: # Someone got there before me | ||||||
|             return root_logger |             return root_logger | ||||||
|  |  | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ class VirtualOrg(object): | |||||||
|              |              | ||||||
|             com_identifier = self.get_common_identifier(subject_id) |             com_identifier = self.get_common_identifier(subject_id) | ||||||
|                  |                  | ||||||
|             resolver = AttributeResolver(saml2client=self.sp) |             resolver = AttributeResolver(self.sp) | ||||||
|             # extends returns a list of session_infos       |             # extends returns a list of session_infos       | ||||||
|             for session_info in resolver.extend(com_identifier, |             for session_info in resolver.extend(com_identifier, | ||||||
|                                         self.sp.config.entityid,  |                                         self.sp.config.entityid,  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Roland Hedberg
					Roland Hedberg