Skip to content

Commit

Permalink
Basic authentication authentication script. Uses a configuration file
Browse files Browse the repository at this point in the history
for the apikey and username from rackspace. Closes #1.
  • Loading branch information
mbjones committed Oct 29, 2013
1 parent 1354e95 commit 5719e94
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions auth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

TMP=auth-response.xml
CRED=credentials

. ./$CRED

# Delete any existing TOKENs
sed -e '/TOKEN=/ d' $CRED > ${CRED}2 && mv ${CRED}2 $CRED

# Delete any existing TENANTS
sed -e '/TENANT=/ d' $CRED > ${CRED}2 && mv ${CRED}2 $CRED

curl -s -d \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<auth>
<apiKeyCredentials
xmlns=\"http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0\"
username=\"$UNAME\"
apiKey=\"$APIKEY\"/>
</auth>" \
-H 'Content-Type: application/xml' \
-H 'Accept: application/xml' \
'https://identity.api.rackspacecloud.com/v2.0/tokens' | xmlstarlet fo > $TMP
xmlstarlet sel -N mns=http://docs.openstack.org/identity/api/v2.0 -T -t -m "/mns:access/mns:token" -v "concat('TOKEN=',@id)" --nl $TMP >> ./$CRED
xmlstarlet sel -N mns=http://docs.openstack.org/identity/api/v2.0 -T -t -m "/mns:access/mns:token/mns:tenant" -v "concat('TENANT=',@id)" --nl $TMP >> ./$CRED
rm $TMP
2 changes: 2 additions & 0 deletions credentials
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UNAME=your-rackspace-username-here
APIKEY=your-apikey-here

0 comments on commit 5719e94

Please sign in to comment.