├── .gitignore ├── package.json ├── .github ├── ISSUE_TEMPLATE │ ├── -anything-else.md │ └── --bug_report.md └── PULL_REQUEST_TEMPLATE.md ├── README.md ├── lib └── index.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "node-red-auth-github", 3 | "version" : "0.1.1", 4 | "description" : "A GitHub authentication plugin for Node-RED", 5 | "homepage" : "http://nodered.org", 6 | "license" : "Apache-2.0", 7 | "repository" : { 8 | "type":"git", 9 | "url":"https://github.com/node-red/node-red-auth-twitter.git" 10 | }, 11 | "main": "./lib/index.js", 12 | "author": [ 13 | {"name": "Nick O'Leary", "email": "nick.oleary@gmail.com"} 14 | ], 15 | "keywords": [ 16 | "node-red", 17 | "github", 18 | "node-red-auth", 19 | "authentication", 20 | "auth" 21 | ], 22 | "dependencies": { 23 | "passport-github": "1.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/-anything-else.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Anything Else 3 | about: Something that is not a bug report 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please DO NOT raise an issue. 11 | 12 | We DO NOT use the issue tracker for general support or feature requests. Only bug reports should be raised here using the 'Bug report' template. 13 | 14 | For general support, please use the [Node-RED Forum](https://discourse.nodered.org) or [slack team](https://nodered.org/slack). You could also consider asking a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`. 15 | That way the whole Node-RED user community can help, rather than rely on the core development team. 16 | 17 | For feature requests, please use the Node-RED Forum](https://discourse.nodered.org). Many ideas have already been discussed there and you should search that for your request before starting a new discussion. 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 12 | 13 | - [ ] Bugfix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | 16 | 23 | 24 | ## Proposed changes 25 | 26 | 27 | 28 | ## Checklist 29 | 30 | 31 | - [ ] I have read the [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md) 32 | - [ ] For non-bugfix PRs, I have discussed this change on the forum/slack team. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Reproducible software issues 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 26 | 27 | ### What are the steps to reproduce? 28 | 29 | ### What happens? 30 | 31 | ### What do you expect to happen? 32 | 33 | ### Please tell us about your environment: 34 | 35 | - [ ] node-red-auth-github version: 36 | - [ ] Node-RED version: 37 | - [ ] Node.js version: 38 | - [ ] npm version: 39 | - [ ] Platform/OS: 40 | - [ ] Browser: 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node-RED Authentication with GitHub 2 | 3 | [Node-RED](https://nodered.org) plugin for authenticating users with GitHub. 4 | 5 | This modules lets you restrict access to the Node-RED editor to specific GitHub 6 | users. 7 | 8 | **Note:** this requires Node-RED 0.17 or later 9 | 10 | 11 | ## Install 12 | 13 | In your Node-RED user directory, typically `~/.node-red`: 14 | 15 | $ npm install node-red/node-red-auth-github 16 | 17 | ## Usage 18 | 19 | ### Register a new GitHub application 20 | 21 | To enable access control with GitHub, you must first [register a new application 22 | on your GitHub account](https://github.com/settings/developers). 23 | 24 | Once created, you will be provided a _Client ID_ and _Client Secret_ that 25 | you will need to use to configure the authentication plugin. 26 | 27 | ### Configure `adminAuth` 28 | 29 | Access control for the Node-RED editor is configured in your `settings.js` file 30 | using the `adminAuth` property. 31 | 32 | adminAuth: require('node-red-auth-github')({ 33 | clientID: GITHUB_CLIENT_ID, 34 | clientSecret: GITHUB_CLIENT_SECRET, 35 | baseURL: "http://localhost:1880/", 36 | users: [ 37 | { username: "knolleary",permissions: ["*"]} 38 | ] 39 | }) 40 | 41 | The `baseURL` property is the URL used to access the Node-RED editor. 42 | 43 | The `users` property is the list of GitHub users who are allowed to access the 44 | editor. It is the same as used by `adminAuth` as described in the [security documentation](http://nodered.org/docs/security), but without the `password` property. 45 | 46 | A default user can be specified by adding a `default` property to the options object: 47 | 48 | users: [ 49 | ... 50 | ], 51 | default: { 52 | permissions: "read" 53 | } 54 | 55 | ## Copyright and license 56 | 57 | Copyright JS Foundation and other contributors, http://js.foundation under [the Apache 2.0 license](LICENSE). 58 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright JS Foundation and other contributors, http://js.foundation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | var path = require("path"); 18 | var githubStrategy = require("passport-github"); 19 | 20 | var requiredOptions = [ 21 | 'clientID', 22 | 'clientSecret', 23 | 'baseURL', 24 | 'users' 25 | ]; 26 | 27 | module.exports = function(opts) { 28 | for (var i=0;i