Merge remote-tracking branch 'xo-server-auth-google/master'
This commit is contained in:
commit
585b943a52
24
packages/xo-server-auth-google/.npmignore
Normal file
24
packages/xo-server-auth-google/.npmignore
Normal file
@ -0,0 +1,24 @@
|
||||
/benchmark/
|
||||
/benchmarks/
|
||||
*.bench.js
|
||||
*.bench.js.map
|
||||
|
||||
/examples/
|
||||
example.js
|
||||
example.js.map
|
||||
*.example.js
|
||||
*.example.js.map
|
||||
|
||||
/fixture/
|
||||
/fixtures/
|
||||
*.fixture.js
|
||||
*.fixture.js.map
|
||||
*.fixtures.js
|
||||
*.fixtures.js.map
|
||||
|
||||
/test/
|
||||
/tests/
|
||||
*.spec.js
|
||||
*.spec.js.map
|
||||
|
||||
__snapshots__/
|
9
packages/xo-server-auth-google/.travis.yml
Normal file
9
packages/xo-server-auth-google/.travis.yml
Normal file
@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
- 6
|
||||
- 4
|
||||
|
||||
# Use containers.
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
sudo: false
|
77
packages/xo-server-auth-google/README.md
Normal file
77
packages/xo-server-auth-google/README.md
Normal file
@ -0,0 +1,77 @@
|
||||
# xo-server-auth-google [](https://travis-ci.org/vatesfr/xen-orchestra)
|
||||
|
||||
> Google authentication plugin for XO-Server
|
||||
|
||||
This plugin allows Google users to authenticate to Xen-Orchestra.
|
||||
|
||||
The first time a user signs in, XO will create a new XO user with the
|
||||
same identifier.
|
||||
|
||||
## Install
|
||||
|
||||
Installation of the [npm package](https://npmjs.org/package/xo-server-auth-google):
|
||||
|
||||
```
|
||||
> npm install --global xo-server-auth-google
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> This plugin is based on [passport-google](https://google.com/jaredhanson/passport-google),
|
||||
> see [its documentation](https://google.com/jaredhanson/passport-google#configure-strategy)
|
||||
> for more information about the configuration.
|
||||
|
||||
### Creating the Google project
|
||||
|
||||
[Create a new project](https://console.developers.google.com/project):
|
||||
|
||||

|
||||

|
||||
|
||||
Enable the Google+ API:
|
||||
|
||||

|
||||
|
||||
Add OAuth 2.0 credentials:
|
||||
|
||||

|
||||

|
||||
|
||||
### Add the plugin to XO-Server config
|
||||
|
||||
Like all other xo-server plugins, it can be configured directly via
|
||||
the web iterface, see [the plugin documentation](https://xen-orchestra.com/docs/plugins.html).
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
# Install dependencies
|
||||
> npm install
|
||||
|
||||
# Run the tests
|
||||
> npm test
|
||||
|
||||
# Continuously compile
|
||||
> npm run dev
|
||||
|
||||
# Continuously run the tests
|
||||
> npm run dev-test
|
||||
|
||||
# Build for production (automatically called by npm install)
|
||||
> npm run build
|
||||
```
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are *very* welcomed, either on the documentation or on
|
||||
the code.
|
||||
|
||||
You may:
|
||||
|
||||
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
|
||||
you've encountered;
|
||||
- fork and create a pull request.
|
||||
|
||||
## License
|
||||
|
||||
AGPL3 © [Vates SAS](http://vates.fr)
|
BIN
packages/xo-server-auth-google/add-oauth2-credentials-2.png
Normal file
BIN
packages/xo-server-auth-google/add-oauth2-credentials-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
packages/xo-server-auth-google/add-oauth2-credentials.png
Normal file
BIN
packages/xo-server-auth-google/add-oauth2-credentials.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
BIN
packages/xo-server-auth-google/create-project-2.png
Normal file
BIN
packages/xo-server-auth-google/create-project-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
packages/xo-server-auth-google/create-project.png
Normal file
BIN
packages/xo-server-auth-google/create-project.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
packages/xo-server-auth-google/enable-google+-api.png
Normal file
BIN
packages/xo-server-auth-google/enable-google+-api.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
99
packages/xo-server-auth-google/package.json
Normal file
99
packages/xo-server-auth-google/package.json
Normal file
@ -0,0 +1,99 @@
|
||||
{
|
||||
"name": "xo-server-auth-google",
|
||||
"version": "0.2.0",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "Google authentication plugin for XO-Server",
|
||||
"keywords": [
|
||||
"authentication",
|
||||
"google",
|
||||
"orchestra",
|
||||
"plugin",
|
||||
"xen",
|
||||
"xen-orchestra",
|
||||
"xo-server"
|
||||
],
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/packages/xo-server-auth-google",
|
||||
"bugs": "https://github.com/vatesfr/xo-web/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Julien Fontanet",
|
||||
"email": "julien.fontanet@isonoe.net"
|
||||
},
|
||||
"preferGlobal": false,
|
||||
"main": "dist/",
|
||||
"bin": {},
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.23.0",
|
||||
"passport-google-oauth20": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-eslint": "^7.2.1",
|
||||
"babel-plugin-lodash": "^3.2.11",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-preset-env": "^1.3.3",
|
||||
"babel-preset-stage-3": "^6.24.1",
|
||||
"cross-env": "^4.0.0",
|
||||
"dependency-check": "^2.8.0",
|
||||
"husky": "^0.13.3",
|
||||
"jest": "^19.0.2",
|
||||
"rimraf": "^2.6.1",
|
||||
"standard": "^10.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
|
||||
"commitmsg": "npm test",
|
||||
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
|
||||
"dev-test": "jest --bail --watch",
|
||||
"posttest": "standard && dependency-check ./package.json",
|
||||
"prebuild": "rimraf dist/",
|
||||
"predev": "npm run prebuild",
|
||||
"prepublish": "npm run build",
|
||||
"test": "jest"
|
||||
},
|
||||
"babel": {
|
||||
"env": {
|
||||
"test": {
|
||||
"ignore": null
|
||||
}
|
||||
},
|
||||
"ignore": "*.spec.js",
|
||||
"plugins": [
|
||||
"transform-runtime",
|
||||
"lodash"
|
||||
],
|
||||
"presets": [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
"targets": {
|
||||
"node": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"stage-3"
|
||||
]
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"roots": [
|
||||
"<rootDir>/src"
|
||||
],
|
||||
"testRegex": "\\.spec\\.js$"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"dist"
|
||||
],
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
}
|
61
packages/xo-server-auth-google/src/index.js
Normal file
61
packages/xo-server-auth-google/src/index.js
Normal file
@ -0,0 +1,61 @@
|
||||
import { Strategy } from 'passport-google-oauth20'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const configurationSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
callbackURL: {
|
||||
type: 'string',
|
||||
description: 'Must be exactly the same as specified on the Google developer console.'
|
||||
},
|
||||
clientID: {
|
||||
type: 'string'
|
||||
},
|
||||
clientSecret: {
|
||||
type: 'string'
|
||||
},
|
||||
scope: {
|
||||
default: 'https://www.googleapis.com/auth/plus.login',
|
||||
description: 'Note that changing this value will break existing users.',
|
||||
enum: [ 'https://www.googleapis.com/auth/plus.login', 'email' ],
|
||||
enumNames: [ 'Google+ name', 'Simple email address' ]
|
||||
}
|
||||
},
|
||||
required: ['callbackURL', 'clientID', 'clientSecret']
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class AuthGoogleXoPlugin {
|
||||
constructor ({ xo }) {
|
||||
this._conf = null
|
||||
this._xo = xo
|
||||
}
|
||||
|
||||
configure (conf) {
|
||||
this._conf = conf
|
||||
}
|
||||
|
||||
load () {
|
||||
const conf = this._conf
|
||||
const xo = this._xo
|
||||
|
||||
xo.registerPassportStrategy(new Strategy(conf, async (accessToken, refreshToken, profile, done) => {
|
||||
try {
|
||||
done(null, await xo.registerUser(
|
||||
'google',
|
||||
conf.scope === 'email'
|
||||
? profile.emails[0].value
|
||||
: profile.displayName
|
||||
))
|
||||
} catch (error) {
|
||||
done(error.message)
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export default opts => new AuthGoogleXoPlugin(opts)
|
3610
packages/xo-server-auth-google/yarn.lock
Normal file
3610
packages/xo-server-auth-google/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user