omniauth-hub_az 0.1.0 → 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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +38 -30
- data/README.md +69 -6
- data/lib/omniauth/hub_az/version.rb +1 -1
- data/lib/omniauth/hub_az.rb +1 -0
- data/omniauth-hub_az.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ef928ff5884d9b4cb44fe222597feb798dc920b8eed2e29d942143866763259
|
4
|
+
data.tar.gz: c369b9406cff29c27531c91838b93e8fbf871a4eb7adcd593a7d6de2e18fc96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7447ac12e6a050c05f10442144a7c910a237ad5fdba245cafdd1195f3865f0439376e9069ece0aa1c32bc8ae832dbbe6c2246b61c68d28d4345b2827f5f1b87b
|
7
|
+
data.tar.gz: 60d37bd4908b6bf012061fb04fc2bc6e714bed223bbcfb0591f437f80046cbf575b5622b6bd1e9b5996039112778572efbd850fecc432676c0b743d2fb2e0e11
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,48 +1,56 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omniauth-hub_az (0.1.
|
4
|
+
omniauth-hub_az (0.1.1)
|
5
5
|
activesupport (>= 5.0)
|
6
|
-
omniauth-oauth2 (~> 1.
|
6
|
+
omniauth-oauth2 (~> 1.8)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.
|
11
|
+
activesupport (6.1.7.2)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>=
|
14
|
-
minitest (
|
15
|
-
tzinfo (~>
|
16
|
-
zeitwerk (~> 2.
|
17
|
-
concurrent-ruby (1.
|
18
|
-
faraday (
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
concurrent-ruby (1.2.0)
|
18
|
+
faraday (2.7.4)
|
19
|
+
faraday-net_http (>= 2.0, < 3.1)
|
20
|
+
ruby2_keywords (>= 0.0.4)
|
21
|
+
faraday-net_http (3.0.2)
|
22
|
+
hashie (5.0.0)
|
23
|
+
i18n (1.12.0)
|
22
24
|
concurrent-ruby (~> 1.0)
|
23
|
-
jwt (2.
|
24
|
-
minitest (5.
|
25
|
-
multi_json (1.15.0)
|
25
|
+
jwt (2.6.0)
|
26
|
+
minitest (5.15.0)
|
26
27
|
multi_xml (0.6.0)
|
27
|
-
|
28
|
-
|
29
|
-
faraday (>= 0.8, < 2.0)
|
28
|
+
oauth2 (2.0.9)
|
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
|
-
rack (>= 1.2, <
|
34
|
-
|
32
|
+
rack (>= 1.2, < 4)
|
33
|
+
snaky_hash (~> 2.0)
|
34
|
+
version_gem (~> 1.1)
|
35
|
+
omniauth (2.1.1)
|
35
36
|
hashie (>= 3.4.6)
|
36
|
-
rack (>=
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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 (3.0.4.1)
|
43
|
+
rack-protection (3.0.5)
|
44
|
+
rack
|
41
45
|
rake (12.3.3)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
ruby2_keywords (0.0.5)
|
47
|
+
snaky_hash (2.0.1)
|
48
|
+
hashie
|
49
|
+
version_gem (~> 1.1, >= 1.1.1)
|
50
|
+
tzinfo (2.0.5)
|
51
|
+
concurrent-ruby (~> 1.0)
|
52
|
+
version_gem (1.1.1)
|
53
|
+
zeitwerk (2.6.6)
|
46
54
|
|
47
55
|
PLATFORMS
|
48
56
|
ruby
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Omniauth::HubAz
|
2
2
|
|
3
|
-
|
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
|
-
|
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/
|
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/
|
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).
|
data/lib/omniauth/hub_az.rb
CHANGED
data/omniauth-hub_az.gemspec
CHANGED
@@ -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.
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stijn Mathysen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 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.
|
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.
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|