omniauth-bungie-oauth2 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c61ec53e71ca799b4ca1b7d81e660c2e66420af2
4
- data.tar.gz: '080e78001f67eacdc86d5e606673f67c128b3eb9'
3
+ metadata.gz: a1c3aa5d2f1b05dc0187ed37d39f075c66fb3b29
4
+ data.tar.gz: c9aad36bed6c0079d5e37db9eb3a622cce82d215
5
5
  SHA512:
6
- metadata.gz: e2523fa010311c7786fbfad35b4ca2d13f207c8e47023ae8d53e64b5f4ee609ce6f257fcb13c682258302b76364439ebe691819216dd705a3ad959d495c72539
7
- data.tar.gz: e4781cfe6382f59ec9d9d77a8a7737ce928559850e4a657928fec2536f84eb0466063e7124a2b0fa2d0d9ce45ab908c071b562f097913b04d997303cbd605cab
6
+ metadata.gz: 310acd967bf14533cd1d490992be687ead6bb733d102a5193f43ff65ce967319c350ae790868e8fb1a12eb1890fe25c099d11c7abea7eeff7f99ca1307aa8165
7
+ data.tar.gz: 67edafe5cce55d5f2c5e2eb39ab343e5eb9a679c86a687fe072b37e4beec746e50863368d665281c1c87fd40f9356d71468be35ef0afabc1c8856340e2d97b31
data/README.md CHANGED
@@ -19,7 +19,9 @@ And then execute:
19
19
 
20
20
  ## Usage
21
21
 
22
- For full usage this gem You must create an application on [Bungie.net](https://www.bungie.net/en/application).
22
+ ### Settings
23
+
24
+ For full usage this gem You must create an application with authentication access on [Bungie.net](https://www.bungie.net/en/application).
23
25
 
24
26
  After this, you can integrate this strategy with your application. (More about A Bungie OAuth2 you can read on [Help page](https://www.bungie.net/en/Help/Article/45481))
25
27
 
@@ -34,6 +36,57 @@ config.middleware.use OmniAuth::Builder do
34
36
  end
35
37
  ~~~~
36
38
 
39
+ ### Rails integration
40
+
41
+ For integration with Rails You have to setup your strategy configuration in `config/initializers/devise.rb`:
42
+
43
+ ~~~~ruby
44
+ Devise.setup do |config|
45
+ config.omniauth :bungie,
46
+ 'x_api_key_from_bungie_app_settings',
47
+ 'authorization_url_from_bungie_app_settings',
48
+ :origin => 'origin_url_if_you_need'
49
+ end
50
+ ~~~~
51
+
52
+ After this You should define omniauth callback in routes and controller.
53
+
54
+ **routes.rb:**
55
+
56
+ ~~~~ruby
57
+ devise_for :users, :controllers => {
58
+ :omniauth_callbacks => 'devise/omniauth_callbacks',
59
+ }
60
+ ~~~~
61
+
62
+ **devise/omniauth_callbacks_controller.rb**
63
+
64
+ ~~~~ruby
65
+ class Devise::OmniauthCallbacksController < Devise::OmniauthCallbacksController
66
+ def bungie
67
+ @user = User.from_omniauth(request.env["omniauth.auth"])
68
+
69
+ if @user.persisted?
70
+ @user.remember_me = true
71
+
72
+ sign_in_and_redirect @user, :event => :authentication
73
+
74
+ set_flash_message(:notice, :success, :kind => 'Bungie') if is_navigational_format?
75
+ else
76
+ session["devise.bungie_data"] = request.env["omniauth.auth"]
77
+
78
+ redirect_to '/'
79
+ end
80
+ end
81
+
82
+ def failure
83
+ redirect_to '/'
84
+ end
85
+ end
86
+ ~~~~
87
+
88
+ ### Result
89
+
37
90
  After all manipulation the `request.env["omniauth.auth"]` have the next fields:
38
91
 
39
92
  * `uid` with BungieNetUser membershipId
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
@@ -36,7 +36,7 @@ module OAuth2
36
36
 
37
37
  response = get_normalized_response(response)
38
38
 
39
- raise(error) if options[:raise_errors] && !(response.is_a?(Hash) && response['access_token'])
39
+ raise(error) if options[:raise_errors] && (!response.is_a?(Hash) || response['access_token'].nil?)
40
40
 
41
41
  access_token_class.from_hash(self, response.merge(access_token_opts))
42
42
  end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module BungieOauth2
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-bungie-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Ruban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.5.2
188
+ rubygems_version: 2.6.8
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: A Bungie OAuth2 strategy for Omniauth