From 2128b57ab2988069c88d050105eebe73b6cba107 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 6 Nov 2014 22:59:48 +0000 Subject: [PATCH] Add oauth grant --- package.json | 6 +- red/api/auth/clients.js | 32 ++++++++ red/api/auth/index.js | 63 ++++++++++++++++ red/api/auth/strategies.js | 71 ++++++++++++++++++ red/api/auth/tokens.js | 40 ++++++++++ red/api/auth/users.js | 40 ++++++++++ red/api/index.js | 69 +++++++++++------ red/api/info.js | 26 +++++++ test/red/api/auth/clients_spec.js | 0 test/red/api/auth/index_spec.js | 106 +++++++++++++++++++++++++++ test/red/api/auth/strategies_spec.js | 19 +++++ test/red/api/auth/tokens_spec.js | 0 test/red/api/auth/users_spec.js | 0 test/red/api/flows_spec.js | 1 - test/red/api/index_spec.js | 5 +- test/red/api/info_spec.js | 60 +++++++++++++++ test/red/api/nodes_spec.js | 1 - test/red/api/ui_spec.js | 34 --------- 18 files changed, 509 insertions(+), 64 deletions(-) create mode 100644 red/api/auth/clients.js create mode 100644 red/api/auth/index.js create mode 100644 red/api/auth/strategies.js create mode 100644 red/api/auth/tokens.js create mode 100644 red/api/auth/users.js create mode 100644 red/api/info.js create mode 100644 test/red/api/auth/clients_spec.js create mode 100644 test/red/api/auth/index_spec.js create mode 100644 test/red/api/auth/strategies_spec.js create mode 100644 test/red/api/auth/tokens_spec.js create mode 100644 test/red/api/auth/users_spec.js create mode 100644 test/red/api/info_spec.js diff --git a/package.json b/package.json index b88eb9fe0..d74315260 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,11 @@ "is-utf8":"0.2.0", "serialport":"1.4.10", "feedparser":"0.19.2", - "fs.notify":"0.0.4" + "fs.notify":"0.0.4", + "passport":"0.2.1", + "passport-http-bearer":"1.0.1", + "passport-oauth2-client-password":"0.1.2", + "oauth2orize":"1.0.1" }, "devDependencies": { "grunt": "0.4.5", diff --git a/red/api/auth/clients.js b/red/api/auth/clients.js new file mode 100644 index 000000000..fdb5432eb --- /dev/null +++ b/red/api/auth/clients.js @@ -0,0 +1,32 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var when = require("when"); + +var clients = [ + {id:"node-red-admin",secret:"not_available"} +]; + +module.exports = { + get: function(id) { + for (var i=0;i