omniauth-infinum_azure 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/CHANGELOG.md +17 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +65 -0
- data/LICENSE +21 -0
- data/README.md +72 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/omniauth/infinum_azure/version.rb +7 -0
- data/lib/omniauth/infinum_azure.rb +6 -0
- data/lib/omniauth/strategies/infinum_azure.rb +56 -0
- data/omniauth-infinum_azure.gemspec +36 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59659de2d696197818088fac98f3f33328d2a3f161da9ca9a546cf941381b7af
|
4
|
+
data.tar.gz: 96650ce1e8d6f71727a05501b2b7f227cd733f1457987f51b0069d6f17568a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 162d6f73f68f04357842effb9d13f0a25ae1afd32537dbc57cd9bf0ba24a84a7e88b1c114989c9c6bb40b7c57425c02cfa97bf957916a9016abbe5e5100f1394
|
7
|
+
data.tar.gz: 2366b8044627f5f011e49e70baf4c9db42c2b973f6c41e630f60e156ddf517fba8364a586cbf1d28949c3a7fc5b7a39849a4a346723170a5f9fa646af51c24af
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [0.1.3] - 2023-03-14
|
4
|
+
|
5
|
+
- Finishing setup
|
6
|
+
|
7
|
+
## [0.1.2] - 2023-03-08
|
8
|
+
|
9
|
+
- Bugfixing #2 - unsafe to use gem
|
10
|
+
|
11
|
+
## [0.1.1] - 2023-03-08
|
12
|
+
|
13
|
+
- Bugfixing #1 - unsafe to use gem
|
14
|
+
|
15
|
+
## [0.1.0] - 2023-03-07
|
16
|
+
|
17
|
+
- Initial release
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dajana.jeroncic@infinum.hr. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-infinum_azure (0.1.3)
|
5
|
+
omniauth-oauth2
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
faraday (2.7.4)
|
12
|
+
faraday-net_http (>= 2.0, < 3.1)
|
13
|
+
ruby2_keywords (>= 0.0.4)
|
14
|
+
faraday-net_http (3.0.2)
|
15
|
+
hashie (5.0.0)
|
16
|
+
jwt (2.7.0)
|
17
|
+
multi_xml (0.6.0)
|
18
|
+
oauth2 (2.0.9)
|
19
|
+
faraday (>= 0.17.3, < 3.0)
|
20
|
+
jwt (>= 1.0, < 3.0)
|
21
|
+
multi_xml (~> 0.5)
|
22
|
+
rack (>= 1.2, < 4)
|
23
|
+
snaky_hash (~> 2.0)
|
24
|
+
version_gem (~> 1.1)
|
25
|
+
omniauth (2.1.1)
|
26
|
+
hashie (>= 3.4.6)
|
27
|
+
rack (>= 2.2.3)
|
28
|
+
rack-protection
|
29
|
+
omniauth-oauth2 (1.8.0)
|
30
|
+
oauth2 (>= 1.4, < 3)
|
31
|
+
omniauth (~> 2.0)
|
32
|
+
rack (3.0.4.2)
|
33
|
+
rack-protection (3.0.5)
|
34
|
+
rack
|
35
|
+
rake (13.0.6)
|
36
|
+
rspec (3.12.0)
|
37
|
+
rspec-core (~> 3.12.0)
|
38
|
+
rspec-expectations (~> 3.12.0)
|
39
|
+
rspec-mocks (~> 3.12.0)
|
40
|
+
rspec-core (3.12.1)
|
41
|
+
rspec-support (~> 3.12.0)
|
42
|
+
rspec-expectations (3.12.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.12.0)
|
45
|
+
rspec-mocks (3.12.3)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.12.0)
|
48
|
+
rspec-support (3.12.0)
|
49
|
+
ruby2_keywords (0.0.5)
|
50
|
+
snaky_hash (2.0.1)
|
51
|
+
hashie
|
52
|
+
version_gem (~> 1.1, >= 1.1.1)
|
53
|
+
version_gem (1.1.1)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
arm64-darwin-21
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 2.1)
|
60
|
+
omniauth-infinum_azure!
|
61
|
+
rake (~> 13.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.4.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Infinum
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Omniauth::InfinumAzure
|
2
|
+
|
3
|
+
Strategy to authenticate with Infinum AzureAD via OAuth2 in OmniAuth.
|
4
|
+
|
5
|
+
This gem is being used inside [infinum_azure-engine](https://github.com/infinum/rails-infinum-azure-engine).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth-infinum_azure'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install omniauth-infinum_azure
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Name of the strategy is `infinum_azure`.
|
26
|
+
|
27
|
+
Initialize omniauth inside devise:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# config/initializers/devise.rb
|
31
|
+
|
32
|
+
config.omniauth(
|
33
|
+
:infinum_azure,
|
34
|
+
'InfinumAzure_client_id',
|
35
|
+
'InfinumAzure_client_secret',
|
36
|
+
client_options: { tenant: 'InfinumAzureTenantName' }
|
37
|
+
)
|
38
|
+
```
|
39
|
+
|
40
|
+
When user is authenticated via omniauth, strategy will parse users info into following:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
{
|
44
|
+
"provider" => "infinum_azure",
|
45
|
+
"uid" => 17, # ID_OF_USER_ON_INFINUM_AZURE_SERVER
|
46
|
+
"info" =>
|
47
|
+
{
|
48
|
+
"email" => 'mirko.mirkec@infinum.hr',
|
49
|
+
"name" => 'Mirko Mirkec'
|
50
|
+
}
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
54
|
+
Lastly, callback method should be created with same name as strategy, in this case `infinum_azure`, inside `OmniauthCallbackController`. In this method user should be authenticated and signed in.
|
55
|
+
|
56
|
+
## Development
|
57
|
+
|
58
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
59
|
+
|
60
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/infinum/ruby-infinum-azure-omniauth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
69
|
+
|
70
|
+
## Code of Conduct
|
71
|
+
|
72
|
+
Everyone interacting in the Omniauth::InfinumAzure project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/infinum/ruby-infinum-azure-omniauth/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'omniauth/infinum'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class InfinumAzure < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'infinum_azure'
|
7
|
+
option :policy, 'B2C_1_sign_in'
|
8
|
+
option :scope, 'openid'
|
9
|
+
|
10
|
+
def base_azure_url
|
11
|
+
"https://#{options.tenant}.b2clogin.com/#{options.tenant}.onmicrosoft.com/#{options.policy}/oauth2/v2.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
def client
|
15
|
+
options.client_options.authorize_url = File.join(base_azure_url, 'authorize')
|
16
|
+
options.client_options.token_url = File.join(base_azure_url, 'token')
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def logout_url
|
22
|
+
File.join(base_azure_url, 'logout') + "?post_logout_redirect_uri=#{File.join(full_host, path_prefix, 'logout')}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def other_phase
|
26
|
+
return call_app! unless current_path == File.join(path_prefix, name.to_s, 'logout')
|
27
|
+
|
28
|
+
redirect(logout_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
uid do
|
32
|
+
raw_info['sub']
|
33
|
+
end
|
34
|
+
|
35
|
+
info do
|
36
|
+
{
|
37
|
+
email: raw_info['emails'][0],
|
38
|
+
name: raw_info['name']
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def extra
|
43
|
+
{
|
44
|
+
refresh_token: access_token.refresh_token,
|
45
|
+
refresh_token_expires_in: access_token.params[:refresh_token_expires_in],
|
46
|
+
params: access_token.params,
|
47
|
+
raw_info: raw_info
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def raw_info
|
52
|
+
@raw_info ||= ::JWT.decode(access_token.token, nil, false).first
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'omniauth/infinum_azure/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'omniauth-infinum_azure'
|
7
|
+
spec.version = Omniauth::InfinumAzure::VERSION
|
8
|
+
spec.authors = ['Marko Ćilimković']
|
9
|
+
spec.email = ['marko.cilimkovic@infinum.hr']
|
10
|
+
|
11
|
+
spec.summary = 'Gem that contains OAuth2 strategies for Infinum, such as Infinum Azure AD'
|
12
|
+
spec.homepage = 'https://github.com/infinum/ruby-infinum-azure-omniauth'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = '>= 2.7.0'
|
15
|
+
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/infinum/ruby-infinum-azure-omniauth'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/infinum/ruby-infinum-azure-omniauth/blob/master/CHANGELOG.md'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
|
35
|
+
spec.add_dependency 'omniauth-oauth2'
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-infinum_azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marko Ćilimković
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,23 @@ email:
|
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
|
-
files:
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/omniauth/infinum_azure.rb
|
89
|
+
- lib/omniauth/infinum_azure/version.rb
|
90
|
+
- lib/omniauth/strategies/infinum_azure.rb
|
91
|
+
- omniauth-infinum_azure.gemspec
|
76
92
|
homepage: https://github.com/infinum/ruby-infinum-azure-omniauth
|
77
93
|
licenses:
|
78
94
|
- MIT
|