1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<html>
<?vsp
declare sid, consumer, consumer_key, res, ret_url, url, tmp varchar;
declare hostUrl, oauthServerUrl, apiServerUrl varchar;
declare exit handler for sqlstate '*' { goto _default; };
if (is_http_ctx ())
{
hostURL := http_request_header (http_request_header () , 'Host' , null , sys_connected_server_address ());
if (isstring (hostURL) and strchr (hostURL , ':') is null)
{
declare hp varchar;
declare hpa any;
hp := sys_connected_server_address ();
hpa := split_and_decode ( hp , 0 , '\0\0:');
if (hpa [1] <> '80')
hostUrl := hostUrl || ':' || hpa [1];
}
goto _exit;
}
_default:;
hostURL := cfg_item_value (virtuoso_ini_path (), 'URIQA', 'DefaultHost');
if (hostURL is null)
{
hostURL := sys_stat ('st_host_name');
if (server_http_port () <> '80')
hostURL := hostURL || ':' || server_http_port ();
}
_exit:;
if (hostURL not like 'http://%')
hostURL := 'http://' || hostURL;
consumer := {?'consumer'};
consumer_key := {?'key'};
oauthServerUrl := sprintf ('%s/OAuth/', hostURL);
apiServerUrl := sprintf ('%s/ods/api/', hostURL);
sid := null;
if ({?'rt'} is not null)
{
-- call sign_request
url := OAUTH..sign_request ('GET', oauthServerUrl || 'request_token', sprintf ('oauth_client_ip=%U', http_client_ip ()), consumer_key, sid);
res := http_get (url);
sid := OAUTH..parse_response (sid, consumer_key, res);
OAUTH..set_session_data (sid, params);
ret_url := sprintf ('%s/ods/oauth_sid.vsp?ready=%U&consumer=%U', hostURL, sid, {?'name'});
-- call authorize
url := sprintf ('%sauthorize?oauth_token=%U&oauth_callback=%U', oauthServerUrl, OAUTH..get_auth_token (sid), ret_url);
http_status_set (301);
http_header (sprintf ('Location: %s\r\n', url));
return;
}
else if ({?'ready'} is not null) -- get access token
{
sid := get_keyword ('ready', params);
-- call get_consumer_key
consumer_key := OAUTH..get_consumer_key (sid);
-- call parse_response
url := OAUTH..sign_request ('GET', oauthServerUrl||'access_token', sprintf ('oauth_client_ip=%U', http_client_ip ()), consumer_key, sid);
-- http get 'access_token'
res := http_get (url);
-- call parse_response
sid := OAUTH..parse_response (sid, consumer_key, res);
}
?>
<head>
<link rel="stylesheet" type="text/css" href="/ods/openid_login.css" />
<title>OAuth Application Key</title>
<script type="text/javascript">
// OAT
var toolkitPath="/ods/oat";
var imagePath="/ods/images/oat/";
var featureList=["ajax"];
function updateList()
{
var keys = $('key');
if (!keys) {return;}
var consumer = $('name');
if (!consumer) {return;}
// clear options
keys.innerHTML = '';
var S = '/OAuth/keys_request?consumer='+encodeURIComponent(consumer.value);
OAT.AJAX.GET(S, '', function(data) {keys.innerHTML = data;});
}
</script>
<script type="text/javascript" src="/ods/oat/loader.js"></script>
</head>
<body>
<div id="PG">
<div id="MD">
<div id="login_page">
<div id="id_col">
<div id="site_id">
<p><img class="id_logo" src="/ods/images/odslogo_200.png" alt="ods logo icon" /></p>
</div>
</div>
<div id="form_col">
<h1>OAuth Application Key for ODS Controllers</h1>
<div id="login_form_ctr">
<div id="login_form">
<form method="POST">
<input type="hidden" name="sid" value="<?V sid ?>"/>
<?vsp
if (sid is not null)
{
http (sprintf ('<br/> <b>SID:</b> %s<br/>', sid));
}
?>
<br/>
<b>User:</b>
<br/>
<input type="text" name="name" id="name" value="<?V consumer ?>" onblur="javascript: updateList();"/>
<br/><br/>
<b>Application:</b>
<br/>
<select name="key" id="key">
<?vsp for (select a_name, a_key from OAUTH..APP_REG, DB.DBA.SYS_USERS where A_OWNER = U_ID and U_NAME = consumer) do { ?>
<option value="<?V a_key ?>" <?vsp if (consumer_key = a_key) http ('selected'); ?>><?V a_name ?></option>
<?vsp } ?>
</select>
<br/>
<br/>
<input type="submit" value="Execute" name="rt" />
</form>
</div>
</div>
</div>
</div>
</div>
<div id="FT">
<div id="FT_LC">
<a href="http://www.openlinksw.com/virtuoso"><img alt="Powered by OpenLink Virtuoso Universal Server" src="/ods/images/virt_power_no_border.png" border="0"/>
</a>
</div>
<div id="FT_RC"><a href="/ods/faq.html">FAQ</a> |
<a href="/ods/privacy.html">Privacy</a> |
<a href="/ods/rabuse.vspx">Report Abuse</a>
<div class="copyright">
Copyright © 1998-2018 OpenLink Software
</div>
</div>
</div>
</div>
</body>
</html>
|