omniauth-hub_az 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: ea6b3cdd9d7d7fc5a1351f0ffce55b9e126b737bff47b32bcfe5b07581c04c77
4
- data.tar.gz: e9746b012f98d8a4586a2d5f30133007b9e85bb8bdaf27a9ee5eaf25e1b54ff8
3
+ metadata.gz: b954fb1dcfaadfff6c6eac8ac924329da08d0f5655cb0090a6c0b64cc5c0857c
4
+ data.tar.gz: 7f3a7b842eb5d339550b9b98f5c0e8d60125ab87d106a779eeeb204a94ca73ea
5
5
  SHA512:
6
- metadata.gz: f54080ded310eb5efbbcbe0f8ee21070aa152a63499c706528c2a39a945a30b6b177e831f6640b3275b2a9bf329829fb5c55021436e8aaf3ea44294d7b368ae6
7
- data.tar.gz: 4705da313c9689ae2ac31093c773dc80b5ffcf1a11d1d1066ec76e897a70909d52b11f26e142eeb057917c0883083eedf398f610f0bbad6d14166b7e3b55ff64
6
+ metadata.gz: 5b38ef4515a46a379bd0a523e0fb9618cce1a8a5f5b9b7fdfe932805c9eb0b8e2b398e402949858e25c58f98b7d3c9c3913ed811aa39961b2e523180cf0dfec8
7
+ data.tar.gz: f97d2a83991b4d668f2953247995a23a9b655e97b9b575f3d43ae834efdb839826b7fdd7a39e7974b5c947233f43c5cb3ce7b2fb22aaae3cd49dd68ec54781ca
data/Gemfile.lock CHANGED
@@ -3,46 +3,53 @@ PATH
3
3
  specs:
4
4
  omniauth-hub_az (0.1.0)
5
5
  activesupport (>= 5.0)
6
- omniauth-oauth2 (~> 1.6)
6
+ omniauth-oauth2 (~> 1.8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.0.3.2)
11
+ activesupport (6.1.6.1)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 0.7, < 2)
14
- minitest (~> 5.1)
15
- tzinfo (~> 1.1)
16
- zeitwerk (~> 2.2, >= 2.2.2)
17
- concurrent-ruby (1.1.6)
18
- faraday (1.0.1)
19
- multipart-post (>= 1.2, < 3)
20
- hashie (4.1.0)
21
- i18n (1.8.5)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
17
+ concurrent-ruby (1.1.10)
18
+ faraday (2.3.0)
19
+ faraday-net_http (~> 2.0)
20
+ ruby2_keywords (>= 0.0.4)
21
+ faraday-net_http (2.0.3)
22
+ hashie (5.0.0)
23
+ i18n (1.12.0)
22
24
  concurrent-ruby (~> 1.0)
23
- jwt (2.2.1)
25
+ jwt (2.4.1)
24
26
  minitest (5.14.1)
25
- multi_json (1.15.0)
26
27
  multi_xml (0.6.0)
27
- multipart-post (2.1.1)
28
- oauth2 (1.4.4)
29
- faraday (>= 0.8, < 2.0)
28
+ oauth2 (2.0.6)
29
+ faraday (>= 0.17.3, < 3.0)
30
30
  jwt (>= 1.0, < 3.0)
31
- multi_json (~> 1.3)
32
31
  multi_xml (~> 0.5)
33
32
  rack (>= 1.2, < 3)
34
- omniauth (1.9.1)
33
+ rash_alt (>= 0.4, < 1)
34
+ version_gem (~> 1.1)
35
+ omniauth (2.1.0)
35
36
  hashie (>= 3.4.6)
36
- rack (>= 1.6.2, < 3)
37
- omniauth-oauth2 (1.6.0)
38
- oauth2 (~> 1.1)
39
- omniauth (~> 1.9)
40
- rack (2.2.3)
37
+ rack (>= 2.2.3)
38
+ rack-protection
39
+ omniauth-oauth2 (1.8.0)
40
+ oauth2 (>= 1.4, < 3)
41
+ omniauth (~> 2.0)
42
+ rack (2.2.4)
43
+ rack-protection (2.2.1)
44
+ rack
41
45
  rake (12.3.3)
42
- thread_safe (0.3.6)
43
- tzinfo (1.2.7)
44
- thread_safe (~> 0.1)
45
- zeitwerk (2.4.0)
46
+ rash_alt (0.4.12)
47
+ hashie (>= 3.4)
48
+ ruby2_keywords (0.0.5)
49
+ tzinfo (2.0.5)
50
+ concurrent-ruby (~> 1.0)
51
+ version_gem (1.1.0)
52
+ zeitwerk (2.6.0)
46
53
 
47
54
  PLATFORMS
48
55
  ruby
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Omniauth::HubAz
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/hub_az`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ An omniauth gem to authenticate with hub-az
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,72 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+
24
+ ### Configration
25
+
26
+ Create an initializer file and configure the following parameters;
27
+
28
+ ```ruby
29
+ Omniauth::HubAz.setup do |config|
30
+ config.public_key = OpenSSL::PKey::RSA.new(Rails.application.credentials.hub_az[:public_key])
31
+ config.algorithm = 'RS512'
32
+ end
33
+ ```
34
+
35
+ ### Use with Devise
36
+
37
+ Configure the `devise.rb` initializer;
38
+
39
+ ```ruby
40
+ config.omniauth :hub_az, Rails.application.credentials.hub_az[:client_id], Rails.application.credentials.hub_az[:client_secret]
41
+ ```
42
+
43
+ Change your routes file to handle omniauth authentication;
44
+ ```ruby
45
+ #...
46
+ devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
47
+ ```
48
+
49
+ and create that controller
50
+ ```ruby
51
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
52
+
53
+ def hub_az
54
+ authorization = request.env["omniauth.auth"]
55
+
56
+ # test that the info is valid? (verification with the public key was successfull)
57
+ if authorization.info.valid? && authorization.info.roles.include?('some-role')
58
+ @user = User.find_or_initialize_by(email: authorization.info.email) do |user|
59
+ user.password = Devise.friendly_token[0, 20]
60
+ end
61
+ # set additional attributes that should be updated after each authentication
62
+ @user.save!
63
+
64
+ sign_in_and_redirect @user, event: :authentication
65
+ else
66
+ redirect_to new_user_session_path, alert: 'Unable to login, make sure you have the correct roles assigned.'
67
+ end
68
+ end
69
+
70
+ end
71
+ ```
72
+
73
+ ### Api Controller validation
74
+
75
+ Include the mixin to your API controller to obtain additional methods to valid an incoming Bearer token;
76
+
77
+ ```ruby
78
+ class Api::V1::ExampleController < ApplicationController
79
+
80
+ include Omniauth::HubAz::Mixins::ControllerHelper
81
+
82
+ before_action :valid_hub_az_token_required!
83
+ before_action do
84
+ hub_az_token_requires_role!('some-api-role')
85
+ end
86
+
87
+ end
88
+ ```
26
89
 
27
90
  ## Development
28
91
 
@@ -32,7 +95,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
95
 
33
96
  ## Contributing
34
97
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-hub_az. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/omniauth-hub_az/blob/master/CODE_OF_CONDUCT.md).
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/stijnster/omniauth-hub_az. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/stijnster/omniauth-hub_az/blob/master/CODE_OF_CONDUCT.md).
36
99
 
37
100
 
38
101
  ## License
@@ -41,4 +104,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
104
 
42
105
  ## Code of Conduct
43
106
 
44
- Everyone interacting in the Omniauth::HubAz project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-hub_az/blob/master/CODE_OF_CONDUCT.md).
107
+ Everyone interacting in the Omniauth::HubAz project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/stijnster/omniauth-hub_az/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module HubAz
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext'
2
3
  require 'omniauth-oauth2'
3
4
 
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency 'omniauth-oauth2', '~> 1.6'
30
+ spec.add_dependency 'omniauth-oauth2', '~> 1.8'
31
31
  spec.add_dependency 'activesupport', '>= 5.0'
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-hub_az
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stijn Mathysen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement