[gnome-maps/wip/osm-edit: 5/6] osmEdit: Remove stop-gap solutions for password authentication
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 5/6] osmEdit: Remove stop-gap solutions for password authentication
- Date: Wed, 2 Dec 2015 21:47:49 +0000 (UTC)
commit 5968475609277601911b7735096c9b722fb910ff
Author: Marcus Lundblad <ml update uu se>
Date: Tue Dec 1 22:29:51 2015 +0100
osmEdit: Remove stop-gap solutions for password authentication
src/osmConnection.js | 85 +-------------------------------------------------
src/osmEdit.js | 4 --
2 files changed, 1 insertions(+), 88 deletions(-)
---
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 9f27b81..95b0d58 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -32,7 +32,6 @@ const Secret = imports.gi.Secret;
const Soup = imports.gi.Soup;
const BASE_URL = 'https://api.openstreetmap.org/api';
-const TEST_BASE_URL = 'http://api06.dev.openstreetmap.org/api';
const API_VERSION = '0.6';
/* OAuth constants */
@@ -59,31 +58,9 @@ const OSMConnection = new Lang.Class({
this._callProxy = Rest.OAuthProxy.new(CONSUMER_KEY, CONSUMER_SECRET,
BASE_URL + '/' + API_VERSION,
false);
-
- /* TODO: stopgap to supply username/password
- to use with HTTP basic auth, should be
- replaced with OAUTH and real settings */
- this._username = GLib.getenv('OSM_USERNAME');
- this._password = GLib.getenv('OSM_PASSWORD');
-
- let useLiveApi = GLib.getenv('OSM_USE_LIVE_API');
-
- /* for now use the test API unless explicitly
- set to use the live one */
- if (useLiveApi == 'yes')
- this._useTestApi = false;
- else
- this._useTestApi = true;
-
- this._session.connect('authenticate', this._authenticate.bind(this));
-
Maps.osm_init();
},
- get useTestAPI() {
- return this._useTestApi;
- },
-
getOSMObject: function(type, id, callback, cancellable) {
let url = this._getQueryUrl(type, id);
let uri = new Soup.URI(url);
@@ -112,19 +89,7 @@ const OSMConnection = new Lang.Class({
},
_getQueryUrl: function(type, id) {
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- },
-
- _getBaseUrl: function() {
- return this._useTestApi ? TEST_BASE_URL : BASE_URL;
+ return BASE_URL + '/' + API_VERSION + '/' + type + '/' + id;
},
openChangeset: function(comment, callback) {
@@ -258,36 +223,10 @@ const OSMConnection = new Lang.Class({
callback(true, call.get_status_code(), call.get_payload());
},
- _getOpenChangesetUrl: function() {
- return this._getBaseUrl() + '/' + API_VERSION + '/changeset/create';
- },
-
- _getCloseChangesetUrl: function(changesetId) {
- return this._getBaseUrl() + '/' + API_VERSION + '/changeset/' +
- changesetId + '/close';
- },
-
_getCloseChangesetFunction: function(changesetId) {
return '/changeset/' + changesetId + '/close';
},
- _getCreateOrUpdateUrl: function(object, type) {
- if (object.id) {
- let id = object.id;
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- } else {
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/create';
- }
- },
-
_getCreateOrUpdateFunction: function(object, type) {
if (object.id)
return type + '/' + object.id;
@@ -295,32 +234,10 @@ const OSMConnection = new Lang.Class({
return type + '/create';
},
- _getDeleteUrl: function(object, type) {
- let id = object.id;
-
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- },
-
_getDeleteFunction: function(object, type) {
return type + '/' + id;
},
- _authenticate: function(session, msg, auth, retrying, user_data) {
- Utils.debug('authenticate triggered');
- if (retrying)
- session.cancel_message(msg, Soup.Status.UNAUTHORIZED);
-
- auth.authenticate(this._username, this._password);
- },
-
requestOAuthToken: function(callback) {
this._oauthProxy.request_token_async('request_token', 'oob',
function(proxy, error, weakObject,
diff --git a/src/osmEdit.js b/src/osmEdit.js
index b13d884..ce4b223 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -40,10 +40,6 @@ const OSMEdit = new Lang.Class({
this._isSignedIn = this._username !== null && this._username.length > 0;
},
- get useTestApi() {
- return this._osmConnection.useTestApi;
- },
-
get object() {
return this._osmObject;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]