Skip to content

Instantly share code, notes, and snippets.

@turtlebender
Forked from mattias-lidman/gist:1672794
Created January 24, 2012 21:29
Show Gist options
  • Save turtlebender/1672825 to your computer and use it in GitHub Desktop.
Save turtlebender/1672825 to your computer and use it in GitHub Desktop.
from globusonline.graph import data_store
import globusonline.graph
from globusonline.graph.request import TestRequest
from globusonline.graph.users import resources as users
from globusonline.graph import groups
from ConfigParser import RawConfigParser
from sys import argv
# Setup:
config = RawConfigParser()
GO_CONFIG = argv[1] if len(argv) > 1 else '/home/mattias/virtualenv/globusonline-graph/development.ini'
config.read(GO_CONFIG)
app_options = dict(config.items('app:graph'))
store = data_store.from_settings(app_options)
crypto = globusonline.graph.auth.security.Crypto(app_options['shared_secret'])
request = TestRequest(store, crypto)
# Do stuff:
import uuid
from globusonline.graph.credentials.resources import UserCredentials
from globusonline.graph.users.resources import User
for rel in store.get_reference_node("myproxy").instance:
cred = rel.target_node.attributes
if not rel.target_node.has_myproxy.incoming.single:
continue
user_node = rel.target_node.has_myproxy.incoming.single.source_node
user = User(None, user_node, request)
print cred
if cred.has_key('server') and cred.has_key('username') and cred.has_key('id_index') and \
"/O=Grid/OU=GlobusTest/OU=simpleCA-mgt6-mgmt.ether.alcf.anl.gov/CN=Globus Simple CA" in (cred['x509_issuer']):
credential_id = cred['username'] + '_' + 'oauth.alcf.anl.gov'
cred.pop('id_index')
cred['server'] = 'oauth.alcf.anl.gov'
unique_key = str(uuid.uuid4())
user_creds = user.credentials
print("Inserting new credential")
user_creds.add_credential('oauth', unique_key, credential_id, cred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment