Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrubelic committed Mar 30, 2017
0 parents commit 6a3c24d
Show file tree
Hide file tree
Showing 23 changed files with 18,913 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# vue-authenticate
`vue-authenticate` is easily configurable solution for *Vue.js* that provides local login/registration as well as Social login using Github, Facebook, Google and Twitter OAuth providers.

The best part about this library is that it is not strictly coupled to one request handling library like `vue-resource`. You will be able to use it with different libraries.

For now it is tested to work with `vue-resource` and `axios` (using `vue-axios` wrapper).

This library was inspired by well known authentication library for Angular called [Satellizer](https://github.com/sahat/satellizer) developed by [Sahat Yalkabov](http://sahatyalkabov.com). They share almost identical configuration and API so you can easily switch from Angular to Vue.js project.

## Instalation
`npm install vue-authenticate`

## Usage
```javascript
import Vue from 'vue'
import VueResource from 'vue-resource'
import VueAuthenticate from '../src/index.js'

Vue.use(VueRouter)
Vue.use(VueResource)

Vue.use(VueAuthenticate, {
baseUrl: 'http://localhost:4000',

providers: {
github: {
clientId: '91b3c6a5b8411640e1b3',
redirectUri: 'http://localhost:8080/auth/callback'
}
}
}
```
### Email & password login and registration
```javascript
new Vue({
methods: {
login: function () {
this.$auth.login({ email, password }).then(function () {
// Execute application logic after successful login
})
},

register: function () {
this.$auth.register({ name, email, password }).then(function () {
// Execute application logic after successful registration
})
}
}
})
```
### Social authentication
```javascript
new Vue({
methods: {
authenticate: function (provider) {
this.$auth.authenticate(provider).then(function () {
// Execute application logic after successful social authentication
})
}
}
})
```
```html
<button @click="authenticate('github')">auth Github</button>
<button @click="authenticate('facebook')">auth Facebook</button>
<button @click="authenticate('google')">auth Google</button>
<button @click="authenticate('twitter')">auth Twitter</button>
```
## License
The MIT License (MIT)
Copyright (c) 2017 Davor Grubelić
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 changes: 33 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var gulp = require('gulp'),
connect = require('gulp-connect')
webpack = require('webpack'),
gulpWebpack = require('gulp-webpack')
history = require('connect-history-api-fallback')

gulp.task('compile', function () {
var webpackConfig = require('./test/webpack.config.js')
return gulp.src('./test/index.js')
.pipe(gulpWebpack(webpackConfig, webpack))
.pipe(gulp.dest('./test'))
.pipe(connect.reload())
})

gulp.task('server', function () {
connect.server({
name: 'VueAuthentication',
root: './test',
base: 'test',
port: 8080,
livereload: true,
verbose: true,
middleware: function () {
return [history()]
}
});
})

gulp.task('watch', function () {
gulp.watch(['./test/index.js', './src/**/*.js'], ['compile'])
})

gulp.task('dev', ['compile', 'server', 'watch'])
68 changes: 68 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "vue-authenticate",
"version": "1.0.0",
"description": "Authentication library for Vue.js",
"main": "src/index.js",
"scripts": {
"dev": "parallelshell \"node-dev ./test/server.js\" \"gulp dev\""
},
"keywords": [
"vue",
"vuejs",
"auth"
],
"author": {
"name": "Davor Grubelic",
"email": "[email protected]",
"url": "https://dgrubelic.me"
},
"repository": {
"type": "git",
"url": "https://github.com/dgrubelic/vue-authenticate.git"
},
"license": "MIT",
"dependencies": {
"promise-polyfill": "^6.0.2",
"vue": "^2.2.5",
"vue-resource": "^1.2.1"
},
"devDependencies": {
"axios": "^0.15.3",
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"body-parser": "^1.17.1",
"connect-history-api-fallback": "^1.3.0",
"cors": "^2.8.1",
"express": "^4.15.2",
"gulp": "^3.9.1",
"gulp-connect": "^5.0.0",
"gulp-webpack": "^1.5.0",
"node-dev": "^3.1.3",
"oauth": "^0.9.15",
"oauth-signature": "^1.3.1",
"parallelshell": "^2.0.0",
"request": "^2.81.0",
"unix-timestamp": "^0.2.0",
"vue-axios": "^2.0.1",
"vue-router": "^2.3.0",
"webpack": "^2.3.2",
"webpack-dev-server": "^2.4.2"
},
"tags": [
"auth",
"authentication",
"login",
"registration",
"jwt",
"token",
"vuejs",
"vue.js",
"github",
"facebook",
"google",
"twitter",
"oauth",
"oauth 1.0",
"oauth 2.0"
]
}
Loading

0 comments on commit 6a3c24d

Please sign in to comment.