Author: zhoresh
Date: Wed Jan 26 23:52:38 2011
New Revision: 1063924
URL: http://svn.apache.org/viewvc?rev=1063924&view=rev
Log:
Make rpc transport OAuth2 an opt in feature |
http://codereview.appspot.com/4090044/
Modified:
shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js
Modified:
shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js?rev=1063924&r1=1063923&r2=1063924&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
Wed Jan 26 23:52:38 2011
@@ -50,6 +50,9 @@ var JsonRpcContainer = function(configPa
this.environment_ = new opensocial.Environment(configParams.domain,
supportedFieldsMap);
+ // Enable usage of Auth2 token passing in rpc
+ this.useOAuth2 = configParams.useOAuth2;
+
this.securityToken_ = shindig.auth.getSecurityToken();
gadgets.rpc.register('shindig.requestShareApp_callback',
@@ -218,13 +221,18 @@ var JsonRpcRequestItem = function(rpc, o
};
var headers = {'Content-Type':'application/json'};
-
+ var url = [this.path_];
+
var token = shindig.auth.getSecurityToken();
if (token) {
- headers['Authorization'] = 'OAuth2 ' + token;
+ if (this.useOAuth2) {
+ headers['Authorization'] = 'OAuth2 ' + token;
+ } else {
+ url.push('?st=', encodeURIComponent(token));
+ }
}
- this.sendRequest(this.path_, sendResponse, makeRequestParams, headers);
+ this.sendRequest(url.join(''), sendResponse, makeRequestParams, headers);
};
JsonRpcContainer.prototype.sendRequest = function(relativeUrl, callback,
params, headers) {
@@ -457,12 +465,17 @@ var JsonRpcRequestItem = function(rpc, o
};
var headers = {'Content-Type': 'application/json'};
+ var url = [this.invalidatePath_];
var token = shindig.auth.getSecurityToken();
if (token) {
- headers['Authorization'] = 'OAuth2 ' + token;
+ if (this.useOAuth2) {
+ headers['Authorization'] = 'OAuth2 ' + token;
+ } else {
+ url.push('?st=', encodeURIComponent(token));
+ }
}
- this.sendRequest(this.invalidatePath_, null, makeRequestParams, headers);
+ this.sendRequest(url.join(''), null, makeRequestParams, headers);
};
})();
Modified:
shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js?rev=1063924&r1=1063923&r2=1063924&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/osapi/jsonrpctransport.js
Wed Jan 26 23:52:38 2011
@@ -22,6 +22,8 @@
*/
(function() {
+ var useOAuth2;
+
/**
* Called by a batch to execute all requests
* @param {Object} requests
@@ -63,13 +65,19 @@
var url = this.name;
var token = shindig.auth.getSecurityToken();
if (token) {
- headers['Authorization'] = 'OAuth2 ' + token;
+ if (useOAuth2) {
+ headers['Authorization'] = 'OAuth2 ' + token;
+ } else {
+ url += '?st=';
+ url += encodeURIComponent(token);
+ }
}
gadgets.io.makeNonProxiedRequest(url, processResponse, request, headers);
}
function init(config) {
var services = config['osapi.services'];
+ useOAuth2 = config['osapi.useOAuth2'];
if (services) {
// Iterate over the defined services, extract the http endpoints and
// create a transport per-endpoint