omniauth-heroku 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,18 +1,78 @@
1
1
  # OmniAuth Heroku
2
2
 
3
- OmniAuth strategy for authenticating to Heroku.
3
+ [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating to Heroku.
4
4
 
5
5
  Heroku's support for OAuth is still private/experimental.
6
6
 
7
7
 
8
- ## Basic Usage
8
+ ## Configuration
9
+
10
+ OmniAuth works as a Rack middleware. Mount this Heroku adapter with:
9
11
 
10
12
  ```ruby
11
13
  use OmniAuth::Builder do
12
- provider :heroku, ENV['HEROKU_KEY'], ENV['HEROKU_SECRET']
14
+ provider :heroku, ENV['HEROKU_ID'], ENV['HEROKU_SECRET']
15
+ end
16
+ ```
17
+
18
+ Your Heroku OAuth client should be set to receive callbacks on `/auth/heroku/callback`.
19
+
20
+
21
+ ## Usage
22
+
23
+ Initiate the OAuth flow sending users to `/auth/heroku`.
24
+
25
+ Once the authorization flow is complete and the user is bounced back to your application, check `env["omniauth.auth"]["credentials"]`. It contains both a refresh token and an access token (identified just as `"token"`) to the account.
26
+
27
+ We recommend using this access token together with [Heroku.rb](https://github.com/heroku/heroku.rb) to make API calls on behalf of the user.
28
+
29
+
30
+ ## Example - Rails
31
+
32
+ Under `config/initializers/omniauth.rb`:
33
+
34
+ ```ruby
35
+ Rails.application.config.middleware.use OmniAuth::Builder do
36
+ provider :heroku, ENV['HEROKU_ID'], ENV['HEROKU_SECRET']
13
37
  end
14
38
  ```
15
39
 
40
+ Then add to `config/routes.rb`:
41
+
42
+ ```ruby
43
+ Example::Application.routes.draw do
44
+ get "login" => "sessions#new"
45
+ get "/auth/:provider/callback" => "sessions#create"
46
+ end
47
+ ```
48
+
49
+ Controller support:
50
+
51
+ ```ruby
52
+ class SessionsController < ApplicationController
53
+ def new
54
+ redirect_to "/auth/heroku"
55
+ end
56
+
57
+ def create
58
+ access_token = request.env['omniauth.auth']['credentials']['token']
59
+ heroku_api = Heroku::API.new(:api_key => access_token)
60
+ @apps = api.get_apps.body
61
+ end
62
+ end
63
+ ```
64
+
65
+ And view:
66
+
67
+ ```erb
68
+ <h1>Your Heroku apps:</h1>
69
+
70
+ <ul>
71
+ <% @apps.each do |app| %>
72
+ <li><%= app["name"] %></li>
73
+ <% end %>
74
+ </ul>
75
+ ```
16
76
 
17
77
  ## Meta
18
78
 
@@ -10,25 +10,6 @@ module OmniAuth
10
10
  :authorize_url => "#{BaseAuthUrl}/oauth/authorize",
11
11
  :token_url => "#{BaseAuthUrl}/oauth/token"
12
12
  }
13
-
14
- def request_phase
15
- super
16
- end
17
-
18
- uid { raw_info['id'] }
19
-
20
- info do
21
- { 'email' => raw_info['email'] }
22
- end
23
-
24
- extra do
25
- { 'raw_info' => raw_info }
26
- end
27
-
28
- def raw_info
29
- access_token.options[:mode] = :header
30
- @raw_info ||= access_token.get('/account').parsed
31
- end
32
13
  end
33
14
  end
34
15
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.files = `git ls-files`.split("\n")
10
10
  gem.name = "omniauth-heroku"
11
11
  gem.require_paths = ["lib"]
12
- gem.version = "0.0.4"
12
+ gem.version = "0.1.0"
13
13
 
14
14
  gem.add_dependency 'omniauth', '~> 1.0'
15
15
  gem.add_dependency 'omniauth-oauth2', '~> 1.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-heroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 1.8.22
80
+ rubygems_version: 1.8.24
81
81
  signing_key:
82
82
  specification_version: 3
83
83
  summary: OmniAuth strategy for Heroku.