Initial commit.
This commit is contained in:
commit
ad06c8147f
15
packages/xo-server-auth-google/.babelrc
Normal file
15
packages/xo-server-auth-google/.babelrc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"comments": false,
|
||||||
|
"compact": true,
|
||||||
|
"optional": [
|
||||||
|
// Experimental features.
|
||||||
|
// "minification.constantFolding",
|
||||||
|
// "minification.deadCodeElimination",
|
||||||
|
|
||||||
|
"es7.asyncFunctions",
|
||||||
|
"es7.decorators",
|
||||||
|
"es7.exportExtensions",
|
||||||
|
"es7.functionBind",
|
||||||
|
"runtime"
|
||||||
|
]
|
||||||
|
}
|
65
packages/xo-server-auth-google/.editorconfig
Normal file
65
packages/xo-server-auth-google/.editorconfig
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# http://EditorConfig.org
|
||||||
|
#
|
||||||
|
# Julien Fontanet's configuration
|
||||||
|
# https://gist.github.com/julien-f/8096213
|
||||||
|
|
||||||
|
# Top-most EditorConfig file.
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Common config.
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespaces = true
|
||||||
|
|
||||||
|
# CoffeeScript
|
||||||
|
#
|
||||||
|
# https://github.com/polarmobile/coffeescript-style-guide/blob/master/README.md
|
||||||
|
[*.{,lit}coffee]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Markdown
|
||||||
|
[*.{md,mdwn,mdown,markdown}]
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Package.json
|
||||||
|
#
|
||||||
|
# This indentation style is the one used by npm.
|
||||||
|
[/package.json]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Jade
|
||||||
|
[*.jade]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# JavaScript
|
||||||
|
#
|
||||||
|
# Two spaces seems to be the standard most common style, at least in
|
||||||
|
# Node.js (http://nodeguide.com/style.html#tabs-vs-spaces).
|
||||||
|
[*.js]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Less
|
||||||
|
[*.less]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Sass
|
||||||
|
#
|
||||||
|
# Style used for http://libsass.com
|
||||||
|
[*.s[ac]ss]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# YAML
|
||||||
|
#
|
||||||
|
# Only spaces are allowed.
|
||||||
|
[*.yaml]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
8
packages/xo-server-auth-google/.gitignore
vendored
Normal file
8
packages/xo-server-auth-google/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/bower_components/
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
npm-debug.log
|
||||||
|
npm-debug.log.*
|
||||||
|
|
||||||
|
!node_modules/*
|
||||||
|
node_modules/*/
|
3
packages/xo-server-auth-google/.mocha.js
Normal file
3
packages/xo-server-auth-google/.mocha.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
try { require('clarify') } catch (_) {}
|
||||||
|
try { require('trace') } catch (_) {}
|
||||||
|
try { require('source-map-support/register') } catch (_) {}
|
1
packages/xo-server-auth-google/.mocha.opts
Normal file
1
packages/xo-server-auth-google/.mocha.opts
Normal file
@ -0,0 +1 @@
|
|||||||
|
--require ./.mocha.js
|
10
packages/xo-server-auth-google/.npmignore
Normal file
10
packages/xo-server-auth-google/.npmignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/examples/
|
||||||
|
example.js
|
||||||
|
example.js.map
|
||||||
|
*.example.js
|
||||||
|
*.example.js.map
|
||||||
|
|
||||||
|
/test/
|
||||||
|
/tests/
|
||||||
|
*.spec.js
|
||||||
|
*.spec.js.map
|
12
packages/xo-server-auth-google/.travis.yml
Normal file
12
packages/xo-server-auth-google/.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- '4'
|
||||||
|
- 'iojs-v3'
|
||||||
|
- 'iojs-v2'
|
||||||
|
- 'iojs-v1'
|
||||||
|
- '0.12'
|
||||||
|
- '0.10'
|
||||||
|
|
||||||
|
# Use containers.
|
||||||
|
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||||
|
sudo: false
|
93
packages/xo-server-auth-google/README.md
Normal file
93
packages/xo-server-auth-google/README.md
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# xo-server-auth-google [](https://travis-ci.org/vatesfr/xo-server-auth-google)
|
||||||
|
|
||||||
|
> 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
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugins:
|
||||||
|
|
||||||
|
auth-google:
|
||||||
|
|
||||||
|
# Both these values will be given to you when your instance of XO
|
||||||
|
# is registered in Google
|
||||||
|
# (https://google.com/settings/developers).
|
||||||
|
clientID: 326211154583-nt2s112d3t7f4f1hh49oo9164nivvbnu.apps.googleusercontent.com
|
||||||
|
clientSecret: -HTDb8I4jXiLRMaRL15qCffQ
|
||||||
|
|
||||||
|
# Must be exactly the same as specified on the Google developer
|
||||||
|
# console.
|
||||||
|
callbackURL: 'http://xo.company.net/signin/google/callback'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Installing dependencies
|
||||||
|
|
||||||
|
```
|
||||||
|
> npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compilation
|
||||||
|
|
||||||
|
The sources files are watched and automatically recompiled on changes.
|
||||||
|
|
||||||
|
```
|
||||||
|
> npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
```
|
||||||
|
> npm run test-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributions
|
||||||
|
|
||||||
|
Contributions are *very* welcomed, either on the documentation or on
|
||||||
|
the code.
|
||||||
|
|
||||||
|
You may:
|
||||||
|
|
||||||
|
- report any [issue](https://google.com/vatesfr/xo-server-auth-google/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 |
56
packages/xo-server-auth-google/package.json
Normal file
56
packages/xo-server-auth-google/package.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "xo-server-auth-google",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"description": "Google authentication plugin for XO-Server",
|
||||||
|
"keywords": [
|
||||||
|
"xo-server",
|
||||||
|
"xo-server",
|
||||||
|
"authentication",
|
||||||
|
"google"
|
||||||
|
],
|
||||||
|
"homepage": "https://google.com/vatesfr/xo-server-auth-google",
|
||||||
|
"bugs": "https://google.com/vatesfr/xo-server-auth-google/issues",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://google.com/vatesfr/xo-server-auth-google"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Julien Fontanet",
|
||||||
|
"email": "julien.fontanet@isonoe.net"
|
||||||
|
},
|
||||||
|
"preferGlobal": false,
|
||||||
|
"main": "dist/",
|
||||||
|
"bin": {},
|
||||||
|
"files": [
|
||||||
|
"dist/"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"babel-runtime": "^5.8.20",
|
||||||
|
"passport-google-oauth": "^0.2.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel": "^5.8.23",
|
||||||
|
"babel-eslint": "^4.1.1",
|
||||||
|
"clarify": "^1.0.5",
|
||||||
|
"mocha": "^2.3.1",
|
||||||
|
"must": "^0.12.0",
|
||||||
|
"source-map-support": "^0.3.2",
|
||||||
|
"standard": "^5.2.1",
|
||||||
|
"trace": "^1.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "babel --source-maps --out-dir=dist/ src/",
|
||||||
|
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
|
||||||
|
"lint": "standard",
|
||||||
|
"prepublish": "npm run build",
|
||||||
|
"test": "npm run lint && mocha --opts .mocha.opts \"dist/**/*.spec.js\"",
|
||||||
|
"test-dev": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\""
|
||||||
|
},
|
||||||
|
"standard": {
|
||||||
|
"ignore": [
|
||||||
|
"dist/**"
|
||||||
|
],
|
||||||
|
"parser": "babel-eslint"
|
||||||
|
}
|
||||||
|
}
|
26
packages/xo-server-auth-google/src/index.js
Normal file
26
packages/xo-server-auth-google/src/index.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import {OAuth2Strategy as Strategy} from 'passport-google-oauth'
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
|
||||||
|
class AuthGoogleXoPlugin {
|
||||||
|
constructor (conf) {
|
||||||
|
conf.scope = 'https://www.googleapis.com/auth/plus.login'
|
||||||
|
|
||||||
|
this._conf = conf
|
||||||
|
}
|
||||||
|
|
||||||
|
load (xo) {
|
||||||
|
xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
|
||||||
|
try {
|
||||||
|
console.log(profile)
|
||||||
|
done(null, await xo.registerUser('google', profile.displayName))
|
||||||
|
} catch (error) {
|
||||||
|
done(error.message)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
|
||||||
|
export default conf => new AuthGoogleXoPlugin(conf)
|
Loading…
Reference in New Issue
Block a user