Removed circular reference

Trying to fix logging
This commit is contained in:
Roland Hedberg
2012-06-27 18:32:40 +02:00
parent 8d4ae1c89e
commit e537025ea3
6 changed files with 27 additions and 28 deletions

View File

@@ -2,8 +2,9 @@
import re
import base64
from cgi import parse_qs
from saml2 import server
#from cgi import parse_qs
from urlparse import parse_qs
from saml2 import server, root_logger
from saml2 import BINDING_HTTP_REDIRECT, BINDING_HTTP_POST
from saml2 import time_util
from Cookie import SimpleCookie
@@ -157,7 +158,8 @@ def slo(environ, start_response, user, logger):
logger.info("REQ_INFO: %s" % req_info.message)
except KeyError, 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
subject = req_info.subject_id()
@@ -259,11 +261,17 @@ if __name__ == '__main__':
import sys
from wsgiref.simple_server import make_server
import logging
LOG_FILENAME = "./idp.log"
from saml2.config import LOG_FORMAT, LOG_HANDLER
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
logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
IDP = server.Server(sys.argv[1])
SRV = make_server('localhost', PORT, APP_WITH_AUTH)
print "IdP listening on port: %s" % PORT

View File

@@ -15,7 +15,6 @@ reissue_time = 3000
use = s2repoze.plugins.sp:make_plugin
saml_conf = sp_conf
rememberer_name = auth_tkt
debug = 1
sid_store = outstanding
identity_cache = identities

View File

@@ -510,7 +510,8 @@ def make_plugin(rememberer_name=None, # plugin for remember
wayf="",
sid_store="",
identity_cache="",
discovery=""
discovery="",
debug=0
):
if saml_conf is "":

View File

@@ -19,26 +19,22 @@
Contains classes and functions that a SAML2.0 Service Provider (SP) may use
to do attribute aggregation.
"""
import saml2
import logging
from saml2.client import Saml2Client
#from saml2 import client
from saml2 import BINDING_SOAP
logger = logging.getLogger(__name__)
DEFAULT_BINDING = saml2.BINDING_SOAP
DEFAULT_BINDING = BINDING_SOAP
class AttributeResolver(object):
def __init__(self, metadata=None, config=None, saml2client=None):
def __init__(self, saml2client, metadata=None, config=None):
self.metadata = metadata
if saml2client:
self.saml2client = saml2client
self.metadata = saml2client.config.metadata
else:
self.saml2client = Saml2Client(config)
self.saml2client = saml2client
self.metadata = saml2client.config.metadata
def extend(self, subject_id, issuer, vo_members, name_id_format=None,
sp_name_qualifier=None, real_id=None):
"""
@@ -58,7 +54,7 @@ class AttributeResolver(object):
for attr_serv in ass.attribute_service:
logger.info(
"Send attribute request to %s" % attr_serv.location)
if attr_serv.binding != saml2.BINDING_SOAP:
if attr_serv.binding != BINDING_SOAP:
continue
# attribute query assumes SOAP binding
session_info = self.saml2client.attribute_query(

View File

@@ -85,7 +85,7 @@ LOG_HANDLER = {
"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):
pass
@@ -311,11 +311,6 @@ class Config(object):
return handler
def setup_logger(self):
try:
_logconf = self.logger
except KeyError:
return None
if root_logger.level != logging.NOTSET: # Someone got there before me
return root_logger

View File

@@ -75,7 +75,7 @@ class VirtualOrg(object):
com_identifier = self.get_common_identifier(subject_id)
resolver = AttributeResolver(saml2client=self.sp)
resolver = AttributeResolver(self.sp)
# extends returns a list of session_infos
for session_info in resolver.extend(com_identifier,
self.sp.config.entityid,