Commit c1e13cac authored by Chris Hines's avatar Chris Hines
Browse files

add a selector for different sites

parent 0388f4bd
......@@ -18,7 +18,7 @@ long_description = 'Generate a SSH Certificate from an OAuth2 compliat cert serv
setup(
name='ssossh',
version='0.0.3',
version='0.0.4',
description=long_description,
long_description=long_description,
......
......@@ -94,7 +94,7 @@ def sign_cert(keypath, token, url):
sess = requests.Session()
headers = {"Authorization": "Bearer {}".format(token)}
data = {"public_key": pub_key}
resp = sess.post(url, json=data, headers=headers, verify=False)
resp = sess.post(url, json=data, headers=headers, verify=True)
try:
data = resp.json()
except:
......@@ -155,6 +155,15 @@ def do_request(authservice):
raise Exception('OAuth2 error: A security check failed. Nonce is {} state is {}'.format(nonce,state))
return token
def select_service(config):
prompt="Enter the number of the site you would like to login to:\n"
n=0
for s in config:
n=n+1
prompt=prompt+"{}: {}\n".format(n,s['name'])
v = input(prompt)
return int(v)-1
def main():
"""
......@@ -173,7 +182,11 @@ def main():
with pkg_resources.open_text(config,'authservers.json') as f:
config = json.loads(f.read())
authservice = config[0]
if len(config) > 1:
service = select_service(config)
else:
service = 0
authservice = config[service]
token = do_request(authservice)
path = make_key()
......
......@@ -11,17 +11,5 @@
"scope": "user:email",
"cafp": "RSA SHA256:cmDxHrZQSPlBMUUcI/BWmruXho1XOzfXPDHSqVTwV2I",
"desc": "<div><div>Don't have an account?</div><div style=\"height:25px\"></div><div><a href=https://docs.massive.org.au/M3/requesting-an-account.html style=\"text-decoration: none\">Signup</a></div><div style=\"height:25px\"></div></div>"
},
{
"authorise": "http://localhost:5000/oauth2/oauth/authorize/choose",
"base": "http://localhost:5000/oauth2/",
"client_id": "Q96kt2Vtw6S78dpORktM81DH",
"sign": "http://localhost:5000/sign/monash_hpcid/api/v1/sign_key",
"logout": "http://localhost:5000/oauth2/logout",
"name": "Local SSHAuthZ (testing/dev)",
"icon": null,
"scope": "user:email",
"cafp": "RSA SHA256:cmDxHrZQSPlBMUUcI/BWmruXho1XOzfXPDHSqVTwV2I",
"desc": "<div><div>Don't have an account?</div><div style=\"height:25px\"></div><div><a href=https://docs.massive.org.au/M3/requesting-an-account.html style=\"text-decoration: none\">Signup</a></div><div style=\"height:25px\"></div></div>"
}
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment