Skip to content

Commit 070d844

Browse files
committed
Init
0 parents  commit 070d844

18 files changed

+389
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -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

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.rubocop.yml

+13
Original file line numberDiff line numberDiff line change
@@ -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

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [Unreleased]
2+
3+
## [0.1.0] - 2023-08-30
4+
5+
- Initial release

Gemfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# Specify your gem's dependencies in omniauth-monday.gemspec
6+
gemspec
7+
8+
gem "rake", "~> 13.0"
9+
10+
gem "rspec", "~> 3.0"
11+
12+
gem "rubocop", "~> 1.21"

Gemfile.lock

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
PATH
2+
remote: .
3+
specs:
4+
omniauth-monday (0.1.0)
5+
graphql-client
6+
omniauth (~> 2.0)
7+
omniauth-oauth2 (~> 1.7)
8+
9+
GEM
10+
remote: https://rubygems.org/
11+
specs:
12+
activesupport (7.0.7.2)
13+
concurrent-ruby (~> 1.0, >= 1.0.2)
14+
i18n (>= 1.6, < 2)
15+
minitest (>= 5.1)
16+
tzinfo (~> 2.0)
17+
ast (2.4.2)
18+
base64 (0.1.1)
19+
concurrent-ruby (1.2.2)
20+
diff-lcs (1.5.0)
21+
faraday (2.7.10)
22+
faraday-net_http (>= 2.0, < 3.1)
23+
ruby2_keywords (>= 0.0.4)
24+
faraday-net_http (3.0.2)
25+
graphql (2.1.0)
26+
graphql-client (0.18.0)
27+
activesupport (>= 3.0)
28+
graphql
29+
hashie (5.0.0)
30+
i18n (1.14.1)
31+
concurrent-ruby (~> 1.0)
32+
json (2.6.3)
33+
jwt (2.7.1)
34+
language_server-protocol (3.17.0.3)
35+
minitest (5.19.0)
36+
multi_xml (0.6.0)
37+
oauth2 (2.0.9)
38+
faraday (>= 0.17.3, < 3.0)
39+
jwt (>= 1.0, < 3.0)
40+
multi_xml (~> 0.5)
41+
rack (>= 1.2, < 4)
42+
snaky_hash (~> 2.0)
43+
version_gem (~> 1.1)
44+
omniauth (2.1.1)
45+
hashie (>= 3.4.6)
46+
rack (>= 2.2.3)
47+
rack-protection
48+
omniauth-oauth2 (1.8.0)
49+
oauth2 (>= 1.4, < 3)
50+
omniauth (~> 2.0)
51+
parallel (1.23.0)
52+
parser (3.2.2.3)
53+
ast (~> 2.4.1)
54+
racc
55+
racc (1.7.1)
56+
rack (3.0.8)
57+
rack-protection (3.0.6)
58+
rack
59+
rainbow (3.1.1)
60+
rake (13.0.6)
61+
regexp_parser (2.8.1)
62+
rexml (3.2.6)
63+
rspec (3.12.0)
64+
rspec-core (~> 3.12.0)
65+
rspec-expectations (~> 3.12.0)
66+
rspec-mocks (~> 3.12.0)
67+
rspec-core (3.12.2)
68+
rspec-support (~> 3.12.0)
69+
rspec-expectations (3.12.3)
70+
diff-lcs (>= 1.2.0, < 2.0)
71+
rspec-support (~> 3.12.0)
72+
rspec-mocks (3.12.6)
73+
diff-lcs (>= 1.2.0, < 2.0)
74+
rspec-support (~> 3.12.0)
75+
rspec-support (3.12.1)
76+
rubocop (1.56.2)
77+
base64 (~> 0.1.1)
78+
json (~> 2.3)
79+
language_server-protocol (>= 3.17.0)
80+
parallel (~> 1.10)
81+
parser (>= 3.2.2.3)
82+
rainbow (>= 2.2.2, < 4.0)
83+
regexp_parser (>= 1.8, < 3.0)
84+
rexml (>= 3.2.5, < 4.0)
85+
rubocop-ast (>= 1.28.1, < 2.0)
86+
ruby-progressbar (~> 1.7)
87+
unicode-display_width (>= 2.4.0, < 3.0)
88+
rubocop-ast (1.29.0)
89+
parser (>= 3.2.1.0)
90+
ruby-progressbar (1.13.0)
91+
ruby2_keywords (0.0.5)
92+
snaky_hash (2.0.1)
93+
hashie
94+
version_gem (~> 1.1, >= 1.1.1)
95+
tzinfo (2.0.6)
96+
concurrent-ruby (~> 1.0)
97+
unicode-display_width (2.4.2)
98+
version_gem (1.1.3)
99+
100+
PLATFORMS
101+
x86_64-darwin-21
102+
103+
DEPENDENCIES
104+
omniauth-monday!
105+
rake (~> 13.0)
106+
rspec (~> 3.0)
107+
rubocop (~> 1.21)
108+
109+
BUNDLED WITH
110+
2.3.8

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 Rob Race
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.

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Omniauth::Monday
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/monday`. 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+
Add this line to your application's Gemfile:
10+
11+
```ruby
12+
gem 'omniauth-monday'
13+
```
14+
15+
And then execute:
16+
17+
$ bundle install
18+
19+
Or install it yourself as:
20+
21+
$ gem install omniauth-monday
22+
23+
## Usage
24+
25+
TODO: Write usage instructions here
26+
27+
## Development
28+
29+
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.
30+
31+
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).
32+
33+
## Contributing
34+
35+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-monday.
36+
37+
## License
38+
39+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
require "rubocop/rake_task"
9+
10+
RuboCop::RakeTask.new
11+
12+
task default: %i[spec rubocop]

bin/console

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "omniauth/monday"
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__)

bin/setup

+8
Original file line numberDiff line numberDiff line change
@@ -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

lib/omniauth-monday/version.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
module Omniauth
4+
module Monday
5+
VERSION = "0.1.0"
6+
end
7+
end

lib/omniauth/omniauth-monday.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "omniauth-monday/version"
2+
require "omniauth/strategies/monday"

lib/omniauth/strategies/monday.rb

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
require "omniauth-oauth2"
2+
require "graphql/client"
3+
require "graphql/client/http"
4+
5+
module OmniAuth
6+
module Strategies
7+
class Monday < OmniAuth::Strategies::OAuth2
8+
option :client_options, {
9+
site: "https://api.monday.com/v2",
10+
authorize_url: "https://auth.monday.com/oauth2/authorize",
11+
token_url: "https://auth.monday.com/oauth2/token",
12+
response_type: "code"
13+
}
14+
15+
def request_phase
16+
super
17+
end
18+
19+
def authorize_params
20+
super.tap do |params|
21+
%w[client_options].each do |v|
22+
if request.params[v]
23+
params[v.to_sym] = request.params[v]
24+
end
25+
end
26+
end
27+
end
28+
29+
uid { me["id"] }
30+
31+
extra do
32+
{ raw_info: raw_info, me: me }
33+
end
34+
35+
def raw_info
36+
@raw_info ||= {}
37+
end
38+
39+
def me
40+
@me ||= begin
41+
http = GraphQL::Client::HTTP.new(options.client_options.site) do |obj|
42+
def headers(context)
43+
{"Authorization" => "Bearer #{context[:token]}"}
44+
end
45+
end
46+
schema = GraphQL::Client.load_schema(http)
47+
client = GraphQL::Client.new(schema: schema, execute: http)
48+
client.allow_dynamic_queries = true
49+
50+
gql = client.parse <<~GRAPHQL
51+
query {
52+
me {
53+
email
54+
name
55+
id
56+
}
57+
}
58+
GRAPHQL
59+
response = client.query(gql, context: {token: access_token.token})
60+
response.data.to_h
61+
end
62+
end
63+
64+
def callback_url
65+
full_host + script_name + callback_path
66+
end
67+
end
68+
end
69+
end
70+
71+
OmniAuth.config.add_camelization "monday", "Monday"

omniauth-monday.gemspec

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
require File.expand_path('../lib/omniauth-monday/version', __FILE__)
4+
5+
Gem::Specification.new do |gem|
6+
gem.name = "omniauth-monday"
7+
gem.version = Omniauth::Monday::VERSION
8+
gem.authors = ["Rob Race"]
9+
gem.email = ["[email protected]"]
10+
11+
gem.summary = %q{Official OmniAuth strategy for Monday.com.}
12+
gem.description = %q{Official OmniAuth strategy for Monday.com.}
13+
gem.homepage = "https://github.com/rob-race/omniauth-monday"
14+
gem.license = "MIT"
15+
gem.required_ruby_version = ">= 2.6.0"
16+
17+
gem.metadata["homepage_uri"] = gem.homepage
18+
19+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20+
gem.files = `git ls-files`.split("\n")
21+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22+
gem.name = "omniauth-monday"
23+
gem.require_paths = ["lib"]
24+
25+
gem.add_dependency 'omniauth', '~> 2.0'
26+
gem.add_dependency 'omniauth-oauth2', '~> 1.7'
27+
gem.add_dependency 'graphql-client'
28+
end

sig/omniauth/monday.rbs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Omniauth
2+
module Monday
3+
VERSION: String
4+
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
5+
end
6+
end

spec/omniauth/monday_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe Omniauth::Monday do
4+
it "has a version number" do
5+
expect(Omniauth::Monday::VERSION).not_to be nil
6+
end
7+
8+
it "does something useful" do
9+
expect(false).to eq(true)
10+
end
11+
end

0 commit comments

Comments
 (0)