omniauth-datadog 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d9fd78b5c80c4b67a30397af101fa942610488d9f9e7a899f270d2a9de02d580
4
+ data.tar.gz: 719797f96a45d281503ceae638b21636dd1ceefd4d06decd55860593a0d4028b
5
+ SHA512:
6
+ metadata.gz: 53da80f466d43c7cecca5608879aeecf0a1b5a74b8549a8e8e0e8a6d0f4b68096e22661b1cad1995e664dc7cc490789f9dae3e3aee2edbe47e1591aece5c7a7a
7
+ data.tar.gz: 89f7e23f098ac82d0315e1119f531ce632872e7a1b56dfd313b9f2f2bf1563b55691aca9f71253cbcc7bcaf345b293dc3af6bfec6dea1ac663ecf9e1783c5594
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '3.1.2'
18
+
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Run the default task
27
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,15 @@
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
12
+
13
+ .byebug_history
14
+
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in omniauth-datadog.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-datadog (0.1.0)
5
+ omniauth-oauth2 (~> 1.8.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ faraday (2.6.0)
13
+ faraday-net_http (>= 2.0, < 3.1)
14
+ ruby2_keywords (>= 0.0.4)
15
+ faraday-net_http (3.0.1)
16
+ hashie (5.0.0)
17
+ json (2.6.2)
18
+ jwt (2.5.0)
19
+ multi_xml (0.6.0)
20
+ oauth2 (2.0.9)
21
+ faraday (>= 0.17.3, < 3.0)
22
+ jwt (>= 1.0, < 3.0)
23
+ multi_xml (~> 0.5)
24
+ rack (>= 1.2, < 4)
25
+ snaky_hash (~> 2.0)
26
+ version_gem (~> 1.1)
27
+ omniauth (2.1.0)
28
+ hashie (>= 3.4.6)
29
+ rack (>= 2.2.3)
30
+ rack-protection
31
+ omniauth-oauth2 (1.8.0)
32
+ oauth2 (>= 1.4, < 3)
33
+ omniauth (~> 2.0)
34
+ parallel (1.22.1)
35
+ parser (3.1.2.1)
36
+ ast (~> 2.4.1)
37
+ rack (3.0.0)
38
+ rack-protection (3.0.2)
39
+ rack
40
+ rainbow (3.1.1)
41
+ rake (13.0.6)
42
+ regexp_parser (2.6.0)
43
+ rexml (3.2.5)
44
+ rspec (3.12.0)
45
+ rspec-core (~> 3.12.0)
46
+ rspec-expectations (~> 3.12.0)
47
+ rspec-mocks (~> 3.12.0)
48
+ rspec-core (3.12.0)
49
+ rspec-support (~> 3.12.0)
50
+ rspec-expectations (3.12.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.12.0)
53
+ rspec-mocks (3.12.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.12.0)
56
+ rspec-support (3.12.0)
57
+ rubocop (1.37.1)
58
+ json (~> 2.3)
59
+ parallel (~> 1.10)
60
+ parser (>= 3.1.2.1)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.23.0, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 1.4.0, < 3.0)
67
+ rubocop-ast (1.23.0)
68
+ parser (>= 3.1.1.0)
69
+ ruby-progressbar (1.11.0)
70
+ ruby2_keywords (0.0.5)
71
+ snaky_hash (2.0.1)
72
+ hashie
73
+ version_gem (~> 1.1, >= 1.1.1)
74
+ unicode-display_width (2.3.0)
75
+ version_gem (1.1.1)
76
+
77
+ PLATFORMS
78
+ arm64-darwin-21
79
+
80
+ DEPENDENCIES
81
+ bundler (~> 2.0)
82
+ omniauth-datadog!
83
+ rake (~> 13.0)
84
+ rspec (~> 3.0)
85
+ rubocop (~> 1.21)
86
+
87
+ BUNDLED WITH
88
+ 2.3.23
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Brooke McKim
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # OmniAuth Datadog
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/datadog`. 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
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add omniauth-datadog
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install omniauth-datadog
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-datadog.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rubocop/rake_task"
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
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/datadog"
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,48 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Datadog < OmniAuth::Strategies::OAuth2
4
+ CLIENT_OPTIONS = {
5
+ site: 'https://app.datadoghq.com',
6
+ authorize_url: 'oauth2/v1/authorize',
7
+ token_url: 'oauth2/v1/token',
8
+ auth_scheme: :request_body
9
+ }
10
+
11
+ VALID_DOMAINS = [
12
+ 'datadoghq.eu',
13
+ 'datadoghq.com'
14
+ ]
15
+
16
+ option :client_options, CLIENT_OPTIONS
17
+ option :pkce, true
18
+
19
+ uid do
20
+ raw_info['dd_oid']
21
+ end
22
+
23
+ info do
24
+ raw_info
25
+ end
26
+
27
+ def raw_info
28
+ @raw_info ||= request.params.slice('dd_org_name', 'dd_oid', 'site')
29
+ end
30
+
31
+ def callback_url
32
+ full_host + callback_path
33
+ end
34
+
35
+ def build_access_token
36
+ verifier = request.params["code"]
37
+ client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(options.auth_token_params))
38
+ end
39
+
40
+ # Datadog has a few different domains.
41
+ def client
42
+ client_options = options.client_options
43
+ client_options['site'] = request.params['site'] if request.params['site'] && VALID_DOMAINS.any? { |d| request.params['site'].end_with?(d) }
44
+ ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(client_options))
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Datadog
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-datadog/version'
2
+ require 'omniauth/strategies/datadog'
@@ -0,0 +1,28 @@
1
+ require_relative "lib/omniauth-datadog/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "omniauth-datadog"
5
+ spec.version = OmniAuth::Datadog::VERSION
6
+ spec.authors = ["Vantage Engineering"]
7
+ spec.email = ["support@vantage.sh"]
8
+ spec.require_paths = %w[lib]
9
+
10
+ spec.summary = "OmniAuth OAUTH2 Strategy for Datadog."
11
+ spec.description = "OmniAuth OAUTH2 Strategy for Datadog."
12
+ spec.homepage = "https://github.com/vantage-sh/omniauth-datadog"
13
+ spec.license = "MIT"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/vantage-sh/omniauth-datadog"
17
+
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
19
+ spec.files = `git ls-files`.split("\n")
20
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+
22
+ # Uncomment to register a new dependency of your gem
23
+ spec.add_dependency "omniauth-oauth2", "~> 1.8.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe OmniAuth::Strategies::Datadog do
4
+ let(:request) { instance_double('Request', :params => { 'dd_org_name' => 'orgname', 'dd_oid' => 'organizationid', 'site' => 'https://app.datadoghq.com' }) }
5
+ let(:parsed_response) { instance_double('ParsedResponse') }
6
+ let(:response) { instance_double('Response', :parsed => parsed_response) }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Datadog.new({})
10
+ end
11
+
12
+ context 'client options' do
13
+ it 'should have correct site' do
14
+ expect(subject.options.client_options.site).to eq('https://app.datadoghq.com')
15
+ end
16
+
17
+ it 'should have correct authorize url' do
18
+ expect(subject.options.client_options.authorize_url).to eq('oauth2/v1/authorize')
19
+ end
20
+
21
+ it 'should have correct token url' do
22
+ expect(subject.options.client_options.token_url).to eq('oauth2/v1/token')
23
+ end
24
+ end
25
+
26
+ context '#uid' do
27
+ it {
28
+ allow(subject).to receive(:request).and_return(request)
29
+ expect(subject.uid).to eq('organizationid')
30
+ }
31
+ end
32
+
33
+ context '#raw_info' do
34
+ it {
35
+ allow(subject).to receive(:request).and_return(request)
36
+ expect(subject.raw_info).to eq({ 'dd_org_name' => 'orgname', 'dd_oid' => 'organizationid', 'site' => 'https://app.datadoghq.com' })
37
+ }
38
+ end
39
+
40
+ describe '#callback_url' do
41
+ it 'is a combination of host, script name, and callback path' do
42
+ allow(subject).to receive(:full_host).and_return('https://example.com')
43
+ allow(subject).to receive(:script_name).and_return('/sub_uri')
44
+ expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/datadog/callback')
45
+ end
46
+ end
47
+
48
+ describe '#client' do
49
+ it 'adjusts based on the site' do
50
+
51
+ end
52
+
53
+ it 'defaults do the specified site' do
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require "rspec"
3
+ require "omniauth"
4
+ require "omniauth-datadog"
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+
10
+ # Disable RSpec exposing methods globally on `Module` and `main`
11
+ config.disable_monkey_patching!
12
+
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-datadog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vantage Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: OmniAuth OAUTH2 Strategy for Datadog.
70
+ email:
71
+ - support@vantage.sh
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".github/workflows/main.yml"
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - ".rubocop.yml"
82
+ - Gemfile
83
+ - Gemfile.lock
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/setup
89
+ - lib/omniauth-datadog.rb
90
+ - lib/omniauth-datadog/version.rb
91
+ - lib/omniauth/strategies/datadog.rb
92
+ - omniauth-datadog.gemspec
93
+ - spec/omniauth/datadog_spec.rb
94
+ - spec/spec_helper.rb
95
+ homepage: https://github.com/vantage-sh/omniauth-datadog
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ homepage_uri: https://github.com/vantage-sh/omniauth-datadog
100
+ source_code_uri: https://github.com/vantage-sh/omniauth-datadog
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubygems_version: 3.3.7
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: OmniAuth OAUTH2 Strategy for Datadog.
120
+ test_files:
121
+ - spec/omniauth/datadog_spec.rb
122
+ - spec/spec_helper.rb