Initial commit.

This commit is contained in:
Julien Fontanet 2015-09-07 17:01:37 +02:00
commit 8c9f32c927
10 changed files with 266 additions and 0 deletions

View 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"
]
}

View 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

View File

@ -0,0 +1,8 @@
/bower_components/
/dist/
npm-debug.log
npm-debug.log.*
!node_modules/*
node_modules/*/

View File

@ -0,0 +1,3 @@
try { require('clarify') } catch (_) {}
try { require('trace') } catch (_) {}
try { require('source-map-support/register') } catch (_) {}

View File

@ -0,0 +1 @@
--require ./.mocha.js

View File

@ -0,0 +1,10 @@
/examples/
example.js
example.js.map
*.example.js
*.example.js.map
/test/
/tests/
*.spec.js
*.spec.js.map

View File

@ -0,0 +1,11 @@
language: node_js
node_js:
- 'iojs-v3'
- 'iojs-v2'
- 'iojs-v1'
- '0.12'
- '0.10'
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

View File

@ -0,0 +1,74 @@
# xo-server-auth-github [![Build Status](https://travis-ci.org/vatesfr/xo-server-auth-github.png?branch=master)](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 --save xo-server-auth-github
```
## Usage
> This plugin is based on [passport-github](https://github.com/bergie/passport-github),
> see [its documentation](https://github.com/bergie/passport-github#configure-strategy)
> for more information about the configuration.
To enable this plugin you have to add it into the configuration file
of XO-Server:
```yaml
plugins:
auth-github:
# Both these values will be given to you when your instance of XO
# is registered in GitHub
# (https://github.com/settings/developers).
clientID: c2f2f881062f170e2ec3
clientSecret: 4335e70f62e2dbb7917df0126b1015b5617bceea
```
## 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)

View File

@ -0,0 +1,56 @@
{
"name": "xo-server-auth-github",
"version": "0.0.0",
"license": "AGPL-3",
"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/"
],
"dependencies": {
"babel-runtime": "^5.8.20",
"passport-github": "^1.0.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"
}
}

View File

@ -0,0 +1,23 @@
import {Strategy} from 'passport-github'
// ===================================================================
class AuthGitHubXoPlugin {
constructor (conf) {
this._conf = conf
}
load (xo) {
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 conf => new AuthGitHubXoPlugin(conf)