omniauth-infinum_azure 0.1.0 → 0.1.2

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: 1f4a5d2a4661c20ebb7bc314da3ffd171ec2bd484727da76a5e2f7f4ab68bacd
4
- data.tar.gz: 96b8cd01fae71c5f68330aee530161686f864a13cf2902f941e88cfbe2e745d9
3
+ metadata.gz: 6d6ee3f05a2f24c7982c175e10ecb0349e5998de64c54a4e7bb7c6c34ba796a4
4
+ data.tar.gz: 4ce9430c51a49146624abb713c1ca7f80acab29a4ab0edd0929ecaad4ff8bd07
5
5
  SHA512:
6
- metadata.gz: d52b4726b273611846cbb6b8c2503a9dc2f60abb4c05ec42f2b76804399e1241a5d45a8cc3c3858b8c245aac5f42e60df6d56e4a9d988d985f8bde553110667e
7
- data.tar.gz: '090a8f3553b5167ffb0d8a9a6e1512a0864528d3f5a6cd36b6c0d5ef8212035429100fdb7d7bd2250bf2a96acbeb964696793a6071560555b0d8942dc3392599'
6
+ metadata.gz: 92d285a92924b6e80568ed17f97ddc262444e07cae1c3d0f465acca6f0bf42e41f0bbcac03b677ae5ac611441158474c24fdcfe080bb04a6351736ffe4f9338d
7
+ data.tar.gz: f545b18b77a23973729e1c54c7bc2936f016c7ffcca0b292de79ef2a9e1e6db5f120645c179d8d0a8b343c68d2ef7907f50bb6c15d0f46233eb23ff31feff361
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: single_quotes
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ Layout/LineLength:
12
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.2] - 2023-03-08
4
+
5
+ - Bugfixing #2 - unsafe to use gem
6
+
7
+ ## [0.1.1] - 2023-03-08
8
+
9
+ - Bugfixing #1 - unsafe to use gem
10
+
11
+ ## [0.1.0] - 2023-03-07
12
+
13
+ - Initial release
@@ -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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in omniauth-infinum_azure.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-infinum_azure (0.1.2)
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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module InfinumAzure
5
+ VERSION = '0.1.2'
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-oauth2'
4
+
5
+ require 'omniauth/infinum_azure/version'
6
+ require 'omniauth/strategies/infinum_azure'
@@ -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, '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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-infinum_azure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marko Ćilimković
@@ -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