Example #1
0
 def __init__(self, name, key=None, url=None, secret=None, policies=None):
     """Initialize and configure a new authz rest object.
         Parameters:
             base_url - should point to the root of the Authz service
                 (e.g. http://api.pbs.org/authz/api/1.0)
     """
     self.name = name
     if key:
         self.key = key
     if url:
         self.url = ensure_no_trailing_slash(url)
     if secret:
         self.secret = secret
     if policies:
         self.policies = ensure_no_trailing_slash(policies)
Example #2
0
 def __init__(self, base_url):
     """Initialize and configure a new authz rest object.
         Parameters:
             base_url - should point to the root of the Authz service
                 (e.g. http://api.pbs.org/authz/api/1.0)
     """
     self.base_url = ensure_no_trailing_slash(base_url)
Example #3
0
    def __init__(self, config, config_prefix='AUTHZ_'):
        """Initialize and configure a new authz client object.

        Config should be an object that contains the necessary configuration
        options to communicate with the authz service:
          * ENDPOINT_URL - the URL to the authz service.
          * CLIENT_SERVICE - the service name to use when authorizing.
          * USER_AGENT (optional) - the user agent to use when sending requests
            Defaults to the urllib2 default user agent.

        By default the presented config options will be checked using the
        AUTHZ_ prefix (e.g. AUTHZ_ENDPOINT_URL). If can override this prefix
        by specifying the config_prefix argument.
        """
        config = ObjectConfig(config)

        self.endpoint_url = ensure_no_trailing_slash(
            getattr(config, '%sENDPOINT_URL' % config_prefix))
        self.service = getattr(config, '%sCLIENT_SERVICE' % config_prefix)
        self.user_agent = getattr(config, '%sUSER_AGENT' % config_prefix, None)