Ticket #24 (closed Defect: Fixed)
trusted_peers not being referenced as shown in the sample config
| Reported by: | pckizer | Owned by: | Mircea Amarascu |
|---|---|---|---|
| Priority: | Minor | Milestone: | |
| Component: | Authentication | Version: | |
| Severity: | Non-critical | Keywords: | |
| Cc: |
Description
In trying to diagnose some code on our end, we tried adding a host to the trusted_peers as listed in the <config.ini.sample>, but it was still requiring auth for the node.
Looking into the code it became obvious that the <config.ini.sample> showed the trusted_peers under the [Authentication] node, but the code itself was trying to set and read it from the [Server] config section.
As the [Authentication] section made more sense, I patched the code to read the trusted_peers from that section.
The patch is:
diff -ru openxcap-0.9.7.orig/xcap/authentication.py openxcap-0.9.7/xcap/authentication.py --- openxcap-0.9.7.orig/xcap/authentication.py 2007-10-19 06:58:24.000000000 -0500 +++ openxcap-0.9.7/xcap/authentication.py 2007-12-10 15:27:06.000000000 -0600 @@ -23,17 +23,14 @@
from xcap.errors import ResourceNotFound from xcap.uri import XCAPUser, parseNodeURI
-class ServerConfig(ConfigSection): - _datatypes = {'trusted_peers': StringList} - trusted_peers = [] -
class AuthenticationConfig(ConfigSection):
default_realm = 'example.com'
+ _datatypes = {'trusted_peers': StringList} + trusted_peers = []
## We use this to overwrite some of the settings above on a local basis if needed configuration = ConfigFile('config.ini') configuration.read_settings('Authentication', AuthenticationConfig)
-configuration.read_settings('Server', ServerConfig)
## Trusted Peer credentials
@@ -122,7 +119,7 @@
realm = request.xcap_uri.user.domain self._updateRealm(realm) remote_addr = request.remoteAddr.host
- if ServerConfig.trusted_peers: + if AuthenticationConfig.trusted_peers:
return self.portal.login(TrustedPeerCredentials(remote_addr),
None, ITrustedPeer
diff -ru openxcap-0.9.7.orig/xcap/server.py openxcap-0.9.7/xcap/server.py --- openxcap-0.9.7.orig/xcap/server.py 2007-10-10 08:17:38.000000000 -0500 +++ openxcap-0.9.7/xcap/server.py 2007-12-10 15:16:49.000000000 -0600 @@ -36,17 +36,18 @@
raise ValueError("Couldn't find the '%s' backend module: %s" % (value.lower(), str(e)))
class AuthenticationConfig(ConfigSection):
+ _datatypes = {'trusted_peers': StringList}
type = 'basic' cleartext_passwords = True default_realm = 'example.com'
+ trusted_peers = []
class ServerConfig(ConfigSection):
- _datatypes = {'trusted_peers': StringList, 'backend': Backend} + _datatypes = {'backend': Backend}
port = 8000 address = '0.0.0.0' root = 'http://xcap.example.com/' backend = Backend('Database')
- trusted_peers = []
class TLSConfig(ConfigSection):
_datatypes = {'certificate': Certificate, 'private_key': PrivateKey}
@@ -123,9 +124,9 @@
else:
http_checker = ServerConfig.backend.HashPasswordChecker()
portal.registerChecker(http_checker)
- if ServerConfig.trusted_peers: - log.info("Trusted peers: %s" % ", ".join(ServerConfig.trusted_peers)) - portal.registerChecker(authentication.TrustedPeerChecker(ServerConfig.trusted_peers)) + if AuthenticationConfig.trusted_peers: + log.info("Trusted peers: %s" % ", ".join(AuthenticationConfig.trusted_peers)) + portal.registerChecker(authentication.TrustedPeerChecker(AuthenticationConfig.trusted_peers))
auth_type = AuthenticationConfig.type if auth_type == 'basic':
