Merge remote-tracking branch 'xo-server-auth-github/master'
This commit is contained in:
commit
e304c554d0
65
packages/xo-server-auth-github/.editorconfig
Normal file
65
packages/xo-server-auth-github/.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,jsx,ts,tsx}]
|
||||
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
|
5
packages/xo-server-auth-github/.gitignore
vendored
Normal file
5
packages/xo-server-auth-github/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/dist/
|
||||
/node_modules/
|
||||
|
||||
npm-debug.log
|
||||
npm-debug.log.*
|
5
packages/xo-server-auth-github/.mocha.js
Normal file
5
packages/xo-server-auth-github/.mocha.js
Normal file
@ -0,0 +1,5 @@
|
||||
Error.stackTraceLimit = 100
|
||||
|
||||
try { require('trace') } catch (_) {}
|
||||
try { require('clarify') } catch (_) {}
|
||||
try { require('source-map-support/register') } catch (_) {}
|
1
packages/xo-server-auth-github/.mocha.opts
Normal file
1
packages/xo-server-auth-github/.mocha.opts
Normal file
@ -0,0 +1 @@
|
||||
--require ./.mocha.js
|
10
packages/xo-server-auth-github/.npmignore
Normal file
10
packages/xo-server-auth-github/.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
|
8
packages/xo-server-auth-github/.travis.yml
Normal file
8
packages/xo-server-auth-github/.travis.yml
Normal file
@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '4'
|
||||
|
||||
# Use containers.
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
sudo: false
|
64
packages/xo-server-auth-github/README.md
Normal file
64
packages/xo-server-auth-github/README.md
Normal file
@ -0,0 +1,64 @@
|
||||
# xo-server-auth-github [](https://travis-ci.org/vatesfr/xo-server-auth-github)
|
||||
|
||||
> GitHub authentication plugin for XO-Server
|
||||
|
||||
This plugin allows GitHub 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-github):
|
||||
|
||||
```
|
||||
> npm install --global xo-server-auth-github
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> This plugin is based on [passport-github](https://github.com/jaredhanson/passport-github),
|
||||
> see [its documentation](https://github.com/jaredhanson/passport-github#configure-strategy)
|
||||
> for more information about the configuration.
|
||||
|
||||
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
|
||||
|
||||
### 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://github.com/vatesfr/xo-server-auth-github/issues)
|
||||
you've encountered;
|
||||
- fork and create a pull request.
|
||||
|
||||
## License
|
||||
|
||||
AGPL3 © [Vates SAS](http://vates.fr)
|
BIN
packages/xo-server-auth-github/github.png
Normal file
BIN
packages/xo-server-auth-github/github.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
80
packages/xo-server-auth-github/package.json
Normal file
80
packages/xo-server-auth-github/package.json
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "xo-server-auth-github",
|
||||
"version": "0.2.1",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "GitHub authentication plugin for XO-Server",
|
||||
"keywords": [
|
||||
"xo-server",
|
||||
"xo-server",
|
||||
"authentication",
|
||||
"github"
|
||||
],
|
||||
"homepage": "https://github.com/vatesfr/xo-server-auth-github",
|
||||
"bugs": "https://github.com/vatesfr/xo-server-auth-github/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xo-server-auth-github"
|
||||
},
|
||||
"author": {
|
||||
"name": "Julien Fontanet",
|
||||
"email": "julien.fontanet@isonoe.net"
|
||||
},
|
||||
"preferGlobal": false,
|
||||
"main": "dist/",
|
||||
"bin": {},
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.11.6",
|
||||
"passport-github": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.16.0",
|
||||
"babel-eslint": "^7.0.0",
|
||||
"babel-plugin-transform-runtime": "^6.15.0",
|
||||
"babel-preset-latest": "^6.16.0",
|
||||
"babel-preset-stage-0": "^6.16.0",
|
||||
"clarify": "^2.0.0",
|
||||
"dependency-check": "^2.6.0",
|
||||
"ghooks": "^1.3.2",
|
||||
"mocha": "^3.1.0",
|
||||
"must": "^0.13.2",
|
||||
"source-map-support": "^0.4.3",
|
||||
"standard": "^8.2.0",
|
||||
"trace": "^2.3.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
|
||||
"depcheck": "dependency-check ./package.json",
|
||||
"dev": "NODE_DEV=development babel --watch --source-maps --out-dir=dist/ src/",
|
||||
"dev-test": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\"",
|
||||
"lint": "standard",
|
||||
"posttest": "npm run lint && npm run depcheck",
|
||||
"prepublish": "npm run build",
|
||||
"test": "mocha --opts .mocha.opts \"dist/**/*.spec.js\""
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"transform-runtime"
|
||||
],
|
||||
"presets": [
|
||||
"latest",
|
||||
"stage-0"
|
||||
]
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"dist"
|
||||
],
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
"commit-msg": "npm test"
|
||||
}
|
||||
}
|
||||
}
|
44
packages/xo-server-auth-github/src/index.js
Normal file
44
packages/xo-server-auth-github/src/index.js
Normal file
@ -0,0 +1,44 @@
|
||||
import {Strategy} from 'passport-github'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const configurationSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
clientID: {
|
||||
type: 'string'
|
||||
},
|
||||
clientSecret: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
required: ['clientID', 'clientSecret']
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class AuthGitHubXoPlugin {
|
||||
constructor (xo) {
|
||||
this._xo = xo
|
||||
}
|
||||
|
||||
configure (conf) {
|
||||
this._conf = conf
|
||||
}
|
||||
|
||||
load () {
|
||||
const {_xo: xo} = this
|
||||
|
||||
xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
|
||||
try {
|
||||
done(null, await xo.registerUser('github', profile.username))
|
||||
} catch (error) {
|
||||
done(error.message)
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export default ({xo}) => new AuthGitHubXoPlugin(xo)
|
17
packages/xo-server-auth-github/src/index.spec.js
Normal file
17
packages/xo-server-auth-github/src/index.spec.js
Normal file
@ -0,0 +1,17 @@
|
||||
/* eslint-env mocha */
|
||||
|
||||
import expect from 'must'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
import myLib from './'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
describe.skip('myLib', () => {
|
||||
it('does something', () => {
|
||||
// TODO: some real tests.
|
||||
|
||||
expect(myLib).to.exists()
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user