sinatra-g_auth 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6a4273f658fd134c4b9f1b762fda97271176fde
4
- data.tar.gz: ffc6e07eef6553fddf29f57397d209378da7c51e
3
+ metadata.gz: c16292e30405a43d9d800e9a71407d9e2b8a0033
4
+ data.tar.gz: cd44f54d65d74c15becf347afe272fcc03b80e98
5
5
  SHA512:
6
- metadata.gz: 79bf9fb443e64d24b9c8ab7cbee6adc4cd2ce44d6c2d204ecc28f2553bc73a036340ed2d77ecb24e88c224e145538531efabdd4163d27e12fa0575bfa5e07777
7
- data.tar.gz: 83008b00e13f9e4ba4f929365c8cf118b6da3b589149783765bc2ba70bedfa0d0f13cf12b2c3bce8b7a50b7a6ad6aaa438dff7a40f552782ac849c87a125c666
6
+ metadata.gz: 84027e93975844fbe898990bd1653f9757cac08da08f56bc9cd1689419f6482b97c99ece98848638dd3bd338dcc9349252f98d689588cba858d0d3276d828e94
7
+ data.tar.gz: 916fc25bb7e4968b4ade146b416404e0c512ad079a510bee752c2706bdd3c1b36b491fbf60f961b63e65fb564c14639814f1c23434a7f6f6b2325c5bf32eeca1
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # SinatraGAuth
1
+ # Sinatra::GAuth
2
2
 
3
- TODO: Write a gem description
3
+ Quickly add Google Apps authentication to any Sintra app.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'sinatra_g_auth'
9
+ gem 'sinatra-g_auth', require: 'sinatra/g_auth'
10
10
 
11
11
  And then execute:
12
12
 
@@ -14,11 +14,66 @@ And then execute:
14
14
 
15
15
  Or install it yourself as:
16
16
 
17
- $ gem install sinatra_g_auth
17
+ $ gem install sinatra-g_auth
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Configure the settings and register the extension to get up and running.
22
+
23
+ ````ruby
24
+ class App < Sinatra::Base
25
+ set :gauth_domain, 'example.org' # set this to your google apps domain
26
+ set :gauth_tmp_dir, './tmp' # path to a directory that's writable by your web process
27
+ set :gauth_redirect, '/' # where to redirect users after they've authenticated
28
+ register Sinatra::GAuth # add the sinatra extension to your stack
29
+
30
+ get '/protected' do
31
+ protect_with_gauth! # add this to any route you want protected
32
+ # ...
33
+ end
34
+ end
35
+ ````
36
+
37
+ Once the user has authenticated with google, some basic information is added to the session:
38
+
39
+ ````ruby
40
+ session[:_gauth][:id] # => google ID
41
+ session[:_gauth][:name] # => user's full name
42
+ session[:_gauth][:email] # => google apps email address
43
+ ````
44
+
45
+ If attempting to add `protect_with_gauth!` to a before filter, be sure to skip paths that begin with `/auth`:
46
+
47
+ ````ruby
48
+ before(%r{^(?!(\/auth))}) do
49
+ protect_with_gauth!
50
+ end
51
+ ````
52
+
53
+ This extension will enable sessions, but does not configure a session store. Do that with the middleware of your choice (e.g. `Rack::Session::Cookie`, `Rack::Session::Dalli`, etc).
54
+
55
+ Authentication is automatic for any routes that call `protect_with_gauth!`. You can add a more user friendly login page, like this:
56
+
57
+ ````ruby
58
+ get '/login' do
59
+ '<a href="/auth/g">Login with Google Apps</a>'
60
+ end
61
+ ````
62
+
63
+ This extension does not provide a logout mechanism, but one can be added easily if you like:
64
+
65
+ ````ruby
66
+ get '/logout' do
67
+ session.clear
68
+ # redirect or whatever...
69
+ end
70
+ ````
71
+
72
+ ## Project Status
73
+
74
+ - Build: [![Build Status](https://secure.travis-ci.org/styleseek/sinatra-g_auth.png?branch=master)](https://travis-ci.org/styleseek/sinatra-g_auth)
75
+ - Code Quality: [![Code Climate](https://codeclimate.com/github/styleseek/sinatra-g_auth.png)](https://codeclimate.com/github/styleseek/sinatra-g_auth)
76
+ - Dependencies: [![Dependency Status](https://gemnasium.com/styleseek/sinatra-g_auth.png)](https://gemnasium.com/styleseek/sinatra-g_auth)
22
77
 
23
78
  ## Contributing
24
79
 
@@ -7,7 +7,7 @@ module Sinatra
7
7
  module GAuth
8
8
  module Helpers
9
9
  def protect_with_gauth!
10
- redirect '/auth/g' unless session[:_gauth]
10
+ redirect "#{request.script_name}/auth/g" unless session[:_gauth]
11
11
  end
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module GAuth
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-g_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Marden