Skip to content

Commit 85c1608

Browse files
committed
putting everything under sso and ssl
1 parent 2355763 commit 85c1608

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ To be documented
2424

2525
Vizualisation of on-going production
2626
--------------
27-
Browse to http://cms-caltech-db.cern.ch/ from within cern network
27+
Browse to https://cms-caltech-db.cern.ch/ from within cern network
28+
Restricted acces to "razor-cms" e-group.
2829

2930
Specifying specific tasks
3031
--------------

cert.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## get the sso cookie
2+
cern-get-sso-cookie -u https://cms-caltech-db.cern.ch -o ~/private/ct-cookie.txt --krb
3+
14
## setup a cannocial location for a proxy
25
export X509_USER_PROXY=$HOME/cert/voms_proxy.cert
36

couchdb/http.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
try:
2727
from http.client import BadStatusLine, HTTPConnection, HTTPSConnection
2828
except ImportError:
29+
print "Getting it from httplib"
2930
from httplib import BadStatusLine, HTTPConnection, HTTPSConnection
3031

3132
try:
@@ -85,6 +86,7 @@ def __init__(self, *a, **k):
8586

8687
class HTTPSConnection(TimeoutMixin, _HTTPSConnection):
8788
def __init__(self, *a, **k):
89+
print "this is the https version"
8890
timeout = k.pop('timeout', None)
8991
_HTTPSConnection.__init__(self, *a, **k)
9092
self.timeout = timeout
@@ -267,6 +269,7 @@ def __init__(self, cache=None, timeout=None, max_redirects=5,
267269
self.connection_pool = ConnectionPool(timeout)
268270
self.retry_delays = list(retry_delays) # We don't want this changing on us.
269271
self.retryable_errors = set(retryable_errors)
272+
self.cookie_items={}
270273

271274
def request(self, method, url, body=None, headers=None, credentials=None,
272275
num_redirects=0):
@@ -303,6 +306,22 @@ def request(self, method, url, body=None, headers=None, credentials=None,
303306
if authorization:
304307
headers['Authorization'] = authorization
305308

309+
if not self.cookie_items and 'https' in url:
310+
import os
311+
print "Fetching sso cookies"
312+
cookies = filter(None,open('%s/private/ct-cookie.txt'%(os.getenv('HOME'))).read().split('\n'))
313+
for c in cookies:
314+
for key in ['_shibsession','_saml_idp']:
315+
if key in c:
316+
rekey=filter(lambda w : w.startswith(key), c.split())[0]
317+
item=c.split()[ c.split().index( rekey )+1]
318+
self.cookie_items[rekey] =item
319+
import pprint
320+
pprint.pprint( self.cookie_items)
321+
if self.cookie_items:
322+
headers.update({"Cookie": '; '.join(map(lambda (k,v) : "%s=%s"%(k,v), self.cookie_items.items()))})
323+
324+
306325
path_query = util.urlunsplit(('', '') + util.urlsplit(url)[2:4] + ('',))
307326
conn = self.connection_pool.get(url)
308327

@@ -498,7 +517,10 @@ def get(self, url):
498517
cls = HTTPSConnection
499518
else:
500519
raise ValueError('%s is not a supported scheme' % scheme)
520+
#print "We have selected a",cls,"from"#,cls.__class__
501521
conn = cls(host, timeout=self.timeout)
522+
#import cookielib
523+
#cf = cookielib.FileCookieJar('/afs/cern.ch/user/v/vlimant/private/ct-cookie.txt')
502524
conn.connect()
503525

504526
return conn

db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class db:
88
def __init__(self):
9-
self.couch = couchdb.Server('http://cms-caltech-db/db/')
9+
self.couch = couchdb.Server('https://cms-caltech-db/db/')
1010
self.rdb = self.couch['tasks']
1111
self.cdb = self.couch['prods']
1212
self.odb = self.couch['outputs']

0 commit comments

Comments
 (0)