omniauth-icalia 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: 9236f718ee4e309a40d06e1361007a8918d2f88b2a5066ae1c199b7941b61522
4
+ data.tar.gz: ab8e9ff9d0d7a1207719518a0041da98db50d0cc6aaec41a1169884b4f46875d
5
+ SHA512:
6
+ metadata.gz: 4fabfa0a04f809e36e155d994d25d2c564e82bad98d2880fff14e2ab059b14fd8169bcf3126dbe360d1b529f24bc98b3374cbe6686fa19c9ffce5e963b421816
7
+ data.tar.gz: 757703f1ca14e9430928677c6a34cfcc07345a8ed304baa716f7d4dcb52b67bc2fb5011a04761fc95ecc75c289dae884f005127054604589de10e7d41b8fd310
data/.dockerignore ADDED
@@ -0,0 +1,45 @@
1
+ # Ignore docker and environment files:
2
+ *Dockerfile*
3
+ docker-compose*.yml
4
+ ci-compose.yml
5
+ **/*.env
6
+ .dockerignore
7
+
8
+ # Ignore Git repositories:
9
+ **/.git
10
+
11
+ # Ignore temporary files:
12
+ **/tmp/
13
+
14
+ # Ignore OS artifacts:
15
+ **/.DS_Store
16
+
17
+ # 3: Ignore Development container's Home artifacts:
18
+ # 3.1: Ignore bash / IRB / Byebug history files
19
+ .*_hist*
20
+
21
+ # 3.3: bundler stuff
22
+ .bundle/*
23
+
24
+ # 3.4: Codeclimate stuff:
25
+ .codeclimate.yml
26
+ .csslintrc
27
+ .eslintignore
28
+ .eslintrc
29
+ .rubocop.yml
30
+ coffeelint.json
31
+
32
+ # Ignore test coverage reports:
33
+ coverage/*
34
+
35
+ # Ignore auto-downloadable codeclimate plugin configuration files:
36
+ .rubocop.yml
37
+ .rubocop-rails.yml
38
+ .reek
39
+ .scss-lint.yml
40
+
41
+ examples.txt
42
+
43
+ **/.gem
44
+ /.semaphore
45
+ /tmp
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ # Ignore history files:
2
+ **/.*_hist*
3
+ pry_history
4
+
5
+ # Ignore builds:
6
+ **/icalia-sdk*.gem
7
+
8
+ **/.gem
9
+
10
+ # Ignore rspec state
11
+ **/.rspec_status
12
+ examples.txt
13
+
14
+ # Ignore dotenv files:
15
+ **/*.env
16
+ !**/*example.env
17
+
18
+ .bundle
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Y yo pelándomela con bash...
5
+
6
+ def load_env
7
+ File.read('.env').each_line do |line|
8
+ variable_name, variable_value = line.match(/\A(\w+)=(\S*)/).captures
9
+ next if variable_name.nil?
10
+ ENV[variable_name] = variable_value
11
+ end
12
+ end
13
+
14
+ def main_image
15
+ @main_image ||= @config.dig 'services', @service_name, 'image'
16
+ end
17
+
18
+ def image_repo
19
+ @image_repo ||= image_and_tag(main_image).first
20
+ end
21
+
22
+ def image_and_tag(image)
23
+ image.match(/\A(\S+):(\S*)\z/).captures
24
+ end
25
+
26
+ def pull(image)
27
+ system('docker', 'pull', image, out: $stdout, err: :out)
28
+ end
29
+
30
+ def pull_main_image
31
+ pull main_image
32
+ end
33
+
34
+ def sorted_cache_images
35
+ unsorted_images = @config
36
+ .dig('services', @service_name, 'build', 'cache_from')
37
+ .reject { |image| image == main_image }
38
+ .uniq
39
+
40
+ # With priority:
41
+ sorted_images = []
42
+
43
+ # 1: Testing of commit:
44
+ sorted_images << unsorted_images.detect do |image|
45
+ image == "#{image_repo}:testing-#{ENV['GIT_SHORT_SHA']}"
46
+ end
47
+
48
+ # 2: Builder of branch:
49
+ sorted_images << unsorted_images.detect do |image|
50
+ image == "#{image_repo}:builder-#{ENV['TAG_SAFE_BRANCH']}"
51
+ end
52
+
53
+ # 3: Testing of branch:
54
+ sorted_images << unsorted_images.detect do |image|
55
+ image == "#{image_repo}:testing-#{ENV['TAG_SAFE_BRANCH']}"
56
+ end
57
+
58
+ # 4: Builder of master branch:
59
+ sorted_images << unsorted_images.detect do |image|
60
+ image == "#{image_repo}:builder"
61
+ end
62
+
63
+ # 5: Testing of master branch:
64
+ sorted_images << unsorted_images.detect do |image|
65
+ image == "#{image_repo}:testing"
66
+ end
67
+
68
+ (sorted_images + (unsorted_images - sorted_images))
69
+ .reject { |image| "#{image}" == '' }
70
+ end
71
+
72
+ def pull_cache_images
73
+ repo_image_pulled = false
74
+ sorted_cache_images.each do |image|
75
+ is_repo_image = image.start_with?(image_repo)
76
+ next if is_repo_image && repo_image_pulled
77
+ repo_image_pulled = pull(image) && is_repo_image
78
+ end
79
+ end
80
+
81
+ def push(image)
82
+ system 'docker', 'push', image, out: $stdout, err: :out
83
+ end
84
+
85
+ def tag(source_image, target_image)
86
+ system 'docker', 'tag', source_image, target_image, out: $stdout, err: :out
87
+ end
88
+
89
+ def tag_and_push_branch
90
+ branch_image = main_image
91
+ .gsub(ENV['GIT_SHORT_SHA'], ENV['TAG_SAFE_BRANCH'])
92
+
93
+ branch_image = branch_image[0..-8] if branch_image =~ /:(\w+)-master\z/
94
+
95
+ tag main_image, branch_image
96
+ push branch_image
97
+ end
98
+
99
+ def tag_and_push_latest
100
+ # We'll only tag 'testing', 'builder' or 'latest' if we're on master:
101
+ return unless ENV['TAG_SAFE_BRANCH'] == 'master'
102
+
103
+ latest_image = main_image.gsub(ENV['GIT_SHORT_SHA'], '')
104
+
105
+ if latest_image.end_with?('-')
106
+ # It's either a 'builder' or 'testing' tag:
107
+ latest_image = latest_image[0..-2]
108
+ elsif latest_image.end_with?(':')
109
+ # It's neither a 'builder' or 'testing' tag:
110
+ latest_image = "#{latest_image}latest"
111
+ end
112
+
113
+ tag main_image, latest_image
114
+ push latest_image
115
+ end
116
+
117
+ def push_images
118
+ push main_image
119
+ tag_and_push_branch
120
+ tag_and_push_latest
121
+ end
122
+
123
+ @command = ARGV[0]
124
+ unless %w[download-cache tag-and-push].include?(@command)
125
+ puts "Command '#{@command}' not recognized"
126
+ exit 1
127
+ end
128
+
129
+ @service_name = ARGV[1]
130
+ if "#{@service_name}" == ''
131
+ puts "No service name given"
132
+ exit 1
133
+ end
134
+
135
+ @config ||= begin
136
+ require 'yaml'
137
+ config_str = %x[docker-compose --file docker-compose.yml --file ci-compose.yml config]
138
+ YAML.load config_str
139
+ rescue
140
+ puts config_str
141
+ exit 1
142
+ end
143
+
144
+ if "#{@service_name}" == ''
145
+ puts "No service name given"
146
+ exit 1
147
+ end
148
+
149
+ if @config.dig('services', @service_name).nil?
150
+ puts "No service '#{@service_name}' exists in config"
151
+ exit 1
152
+ end
153
+
154
+ load_env
155
+
156
+ case @command
157
+ when 'download-cache'
158
+ pull_main_image || pull_cache_images
159
+ when 'tag-and-push'
160
+ push_images
161
+ end
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ # Exit immediately if a command exits with a non-zero status:
4
+ set -e
5
+
6
+ CONTEXT_DIR=$(pwd)
7
+
8
+ GIT_SHORT_SHA=${SEMAPHORE_GIT_SHA:0:7}
9
+ BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z)
10
+ TAG_SAFE_BRANCH=$(echo ${SEMAPHORE_GIT_BRANCH} | tr '/' '-')
11
+
12
+ echo "BUILD_DATE=${BUILD_DATE}"
13
+ echo "GIT_SHA=${SEMAPHORE_GIT_SHA}"
14
+ echo "GIT_SHORT_SHA=${GIT_SHORT_SHA}"
15
+ echo "GIT_BRANCH=${SEMAPHORE_GIT_BRANCH}"
16
+ echo "TAG_SAFE_BRANCH=${TAG_SAFE_BRANCH}"
@@ -0,0 +1,62 @@
1
+ version: v1.0
2
+
3
+ name: 'Publishing Pipeline'
4
+
5
+ agent:
6
+ machine:
7
+ type: e1-standard-2
8
+ os_image: ubuntu1804
9
+
10
+ blocks:
11
+ - name: Publish to Rubygems
12
+ task:
13
+ secrets:
14
+ - name: AWS
15
+ - name: ICALIA_RUBYGEMS
16
+ prologue:
17
+ commands:
18
+ - checkout
19
+
20
+ # Correct the permissions on rubygems credentials:
21
+ - chmod 0600 /home/semaphore/.gem/credentials
22
+
23
+ # Add the scripts for CI to the PATH:
24
+ - export PATH=$(pwd)/.semaphore/bin:${PATH}
25
+
26
+ # Generate the dotenv file:
27
+ - generate-dotenv-file > .env
28
+
29
+ # Alias docker-compose commands as 'ci-compose':
30
+ - alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
31
+
32
+ # Log in to AWS ECR:
33
+ - $(aws ecr get-login --no-include-email --region eu-central-1)
34
+
35
+ # Pull the images referenced in the 'cache_from' key:
36
+ - docker-image-manager download-cache libraries
37
+
38
+ jobs:
39
+ - name: Event Core
40
+ commands:
41
+ # Build & publish the gem
42
+ - ci-compose run event_core rake release
43
+
44
+ - name: Event Notification
45
+ commands:
46
+ # Build & publish the gem
47
+ - ci-compose run event_notification rake release
48
+
49
+ - name: Event Webhook
50
+ commands:
51
+ # Build & publish the gem
52
+ - ci-compose run event_webhook rake release
53
+
54
+ - name: Event Meta
55
+ commands:
56
+ # Build & publish the gem
57
+ - ci-compose run event_meta rake release
58
+
59
+ - name: SDK Meta
60
+ commands:
61
+ # Build & publish the gem
62
+ - ci-compose run sdk_meta rake release
@@ -0,0 +1,111 @@
1
+ version: v1.0
2
+
3
+ name: 'Main Pipeline'
4
+
5
+ agent:
6
+ machine:
7
+ type: e1-standard-2
8
+ os_image: ubuntu1804
9
+
10
+ blocks:
11
+ - name: Build Test Image
12
+ task:
13
+ secrets:
14
+ - name: AWS
15
+ prologue:
16
+ commands:
17
+ - checkout
18
+
19
+ # Add the scripts for CI to the PATH:
20
+ - export PATH=$(pwd)/.semaphore/bin:${PATH}
21
+
22
+ # Generate the dotenv file:
23
+ - generate-dotenv-file > .env
24
+
25
+ # Alias docker-compose commands as 'ci-compose':
26
+ - alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
27
+
28
+ # Log in to AWS ECR:
29
+ - $(aws ecr get-login --no-include-email --region eu-central-1)
30
+ jobs:
31
+ - name: Build
32
+ commands:
33
+ # Pull the images referenced in the 'cache_from' key:
34
+ - docker-image-manager download-cache libraries
35
+
36
+ # Build the test image:
37
+ - ci-compose build --pull libraries
38
+
39
+ # Tag & Push test image so we can use it on image cache:
40
+ - docker-image-manager tag-and-push libraries
41
+
42
+ - name: SDK Tests
43
+ task:
44
+ secrets:
45
+ - name: AWS
46
+ prologue:
47
+ commands:
48
+ - checkout
49
+
50
+ # Add the scripts for CI to the PATH:
51
+ - export PATH=$(pwd)/.semaphore/bin:${PATH}
52
+
53
+ # Generate the dotenv file:
54
+ - generate-dotenv-file > .env
55
+
56
+ # Alias docker-compose commands as 'ci-compose':
57
+ - alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
58
+
59
+ # Log in to AWS ECR:
60
+ - $(aws ecr get-login --no-include-email --region eu-central-1)
61
+
62
+ # Pull the images referenced in the 'cache_from' key:
63
+ - docker-image-manager download-cache libraries
64
+ jobs:
65
+ - name: Event Core
66
+ commands:
67
+ # Run the tests
68
+ - ci-compose run event_core rake spec
69
+
70
+ # Build the gem
71
+ - ci-compose run event_core gem build icalia-sdk-event-core
72
+
73
+ - name: Event Notification
74
+ commands:
75
+ # Run the tests
76
+ - ci-compose run event_notification rake spec
77
+
78
+ # Build the gem
79
+ - ci-compose run event_notification gem build icalia-sdk-event-notification
80
+
81
+ - name: Event Webhook
82
+ commands:
83
+ # Run the tests
84
+ - ci-compose run event_webhook rake spec
85
+
86
+ # Build the gem
87
+ - ci-compose run event_webhook gem build icalia-sdk-event-webhook
88
+
89
+ - name: Event Meta
90
+ commands:
91
+ # Run the tests
92
+ - ci-compose run event_meta rake spec
93
+
94
+ # Build the gem
95
+ - ci-compose run event_meta gem build icalia-sdk-event
96
+
97
+ - name: SDK Meta
98
+ commands:
99
+ # Run the tests
100
+ - ci-compose run sdk_meta rake spec
101
+
102
+ # Build the gem
103
+ - ci-compose run sdk_meta gem build icalia-sdk
104
+
105
+ promotions:
106
+ - name: Publish
107
+ pipeline_file: publishing.yml
108
+ auto_promote_on:
109
+ - result: passed
110
+ branch:
111
+ - ^refs\/tags\/v(\d+)\.(\d+)\.(\d+)(\.rc\d+)?$
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 1.17.2
@@ -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 TODO: Write your email address. 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/Dockerfile ADDED
@@ -0,0 +1,22 @@
1
+ FROM ruby:2.6.5-buster AS development
2
+
3
+ WORKDIR /usr/src
4
+
5
+ ENV HOME=/usr/src PATH=/usr/src/bin:$PATH
6
+
7
+ COPY Gemfile Gemfile.lock omniauth-icalia.gemspec /usr/src/
8
+ COPY lib/omniauth-icalia/version.rb /usr/src/lib/omniauth-icalia/
9
+
10
+ RUN bundle install --jobs=4 --retry=3
11
+
12
+ ARG DEVELOPER_UID=1000
13
+
14
+ ARG DEVELOPER_USERNAME=you
15
+
16
+ ENV DEVELOPER_UID=${DEVELOPER_UID}
17
+
18
+ RUN useradd -r -M -u ${DEVELOPER_UID} -d /usr/src -c "Developer User,,," ${DEVELOPER_USERNAME}
19
+
20
+ FROM development AS testing
21
+
22
+ COPY . /usr/src/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem 'pry', '~> 0.12.2'
6
+ gem 'byebug', '~> 11.1', '>= 11.1'
7
+
8
+ # Specify your gem's dependencies in omniauth-icalia.gemspec
9
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,86 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-icalia (0.1.0)
5
+ icalia-sdk-event-core (>= 0.3.3)
6
+ omniauth (~> 1.5)
7
+ omniauth-oauth2 (>= 1.4.0, < 2.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (6.0.2.1)
13
+ activesupport (= 6.0.2.1)
14
+ activesupport (6.0.2.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.2)
20
+ byebug (11.1.1)
21
+ coderay (1.1.2)
22
+ concurrent-ruby (1.1.6)
23
+ diff-lcs (1.3)
24
+ faraday (1.0.0)
25
+ multipart-post (>= 1.2, < 3)
26
+ hashie (3.6.0)
27
+ i18n (1.8.2)
28
+ concurrent-ruby (~> 1.0)
29
+ icalia-sdk-event-core (0.3.3)
30
+ activemodel (>= 5.0)
31
+ jsonapi-deserializable (~> 0.2.0)
32
+ jsonapi-deserializable (0.2.0)
33
+ jwt (2.2.1)
34
+ method_source (0.9.2)
35
+ minitest (5.14.0)
36
+ multi_json (1.14.1)
37
+ multi_xml (0.6.0)
38
+ multipart-post (2.1.1)
39
+ oauth2 (1.4.3)
40
+ faraday (>= 0.8, < 2.0)
41
+ jwt (>= 1.0, < 3.0)
42
+ multi_json (~> 1.3)
43
+ multi_xml (~> 0.5)
44
+ rack (>= 1.2, < 3)
45
+ omniauth (1.9.0)
46
+ hashie (>= 3.4.6, < 3.7.0)
47
+ rack (>= 1.6.2, < 3)
48
+ omniauth-oauth2 (1.6.0)
49
+ oauth2 (~> 1.1)
50
+ omniauth (~> 1.9)
51
+ pry (0.12.2)
52
+ coderay (~> 1.1.0)
53
+ method_source (~> 0.9.0)
54
+ rack (2.2.2)
55
+ rake (10.5.0)
56
+ rspec (3.9.0)
57
+ rspec-core (~> 3.9.0)
58
+ rspec-expectations (~> 3.9.0)
59
+ rspec-mocks (~> 3.9.0)
60
+ rspec-core (3.9.1)
61
+ rspec-support (~> 3.9.1)
62
+ rspec-expectations (3.9.0)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.9.0)
65
+ rspec-mocks (3.9.1)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.9.0)
68
+ rspec-support (3.9.2)
69
+ thread_safe (0.3.6)
70
+ tzinfo (1.2.6)
71
+ thread_safe (~> 0.1)
72
+ zeitwerk (2.2.2)
73
+
74
+ PLATFORMS
75
+ ruby
76
+
77
+ DEPENDENCIES
78
+ bundler (~> 1.17)
79
+ byebug (~> 11.1, >= 11.1)
80
+ omniauth-icalia!
81
+ pry (~> 0.12.2)
82
+ rake (~> 10.0)
83
+ rspec (~> 3.0)
84
+
85
+ BUNDLED WITH
86
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
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,43 @@
1
+ # Omniauth::Icalia
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/icalia`. 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-icalia'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-icalia
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 tags, 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-icalia. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Omniauth::Icalia project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-icalia/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/icalia"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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
data/ci-compose.yml ADDED
@@ -0,0 +1,41 @@
1
+ # We'll use the '3.x spec since it supports the 'cache_from'
2
+ # option:
3
+ version: '3.7'
4
+
5
+ services:
6
+ libraries: &library
7
+ image: 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
8
+ build:
9
+ target: testing
10
+ context: .
11
+ cache_from:
12
+ # Since docker-compose will try to build the unused (at this time) runtime
13
+ # stage, and this project's dev stages and runtime stages start from
14
+ # different images, we need to include the releaseable image here as well
15
+ # - this may change with Docker 19.x:
16
+ - 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
17
+ - 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${TAG_SAFE_BRANCH}
18
+ - 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing
19
+ command: bundle exec rake spec
20
+ volumes:
21
+ - ${HOME}/.gem/credentials:/root/.gem/credentials
22
+
23
+ event_core:
24
+ <<: *library
25
+ working_dir: /usr/src/gems/icalia-sdk-event-core
26
+
27
+ event_notification:
28
+ <<: *library
29
+ working_dir: /usr/src/gems/icalia-sdk-event-notification
30
+
31
+ event_webhook:
32
+ <<: *library
33
+ working_dir: /usr/src/gems/icalia-sdk-event-webhook
34
+
35
+ event_meta:
36
+ <<: *library
37
+ working_dir: /usr/src/gems/icalia-sdk-event
38
+
39
+ sdk_meta:
40
+ <<: *library
41
+ working_dir: /usr/src/gems/icalia-sdk
@@ -0,0 +1,20 @@
1
+ version: '3.7'
2
+
3
+ volumes:
4
+ lib_gem_bundle:
5
+
6
+ services:
7
+ lib:
8
+ image: icalialabs/omniauth-icalia:development
9
+ build:
10
+ context: .
11
+ target: development
12
+ args:
13
+ DEVELOPER_UID: ${UID:-1000}
14
+ DEVELOPER_USERNAME: ${USER:-you}
15
+ command: bundle console
16
+ volumes:
17
+ - .:/usr/src
18
+ - lib_gem_bundle:/usr/local/bundle
19
+ environment:
20
+ BUNDLE_CONSOLE: pry
@@ -0,0 +1,2 @@
1
+ require 'omniauth-icalia/version'
2
+ require 'omniauth/strategies/icalia'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Icalia
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ require 'omniauth-oauth2'
2
+ require 'icalia-sdk-event-core'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Icalia < OmniAuth::Strategies::OAuth2
7
+ INFO_PATH = '/oauth/token/info?include=resource-owner.email-accounts'
8
+
9
+ option :client_options, {
10
+ site: 'https://artanis.icalialabs.com',
11
+ token_url: 'https://artanis.icalialabs.com/oauth/token',
12
+ authorize_url: 'https://artanis.icalialabs.com/oauth/authorize'
13
+ }
14
+
15
+ def request_phase
16
+ super
17
+ end
18
+
19
+ def authorize_params
20
+ super.tap do |params|
21
+ %w[scope 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 { raw_info.resource_owner.id.to_s }
30
+
31
+ info do
32
+ { 'name' => raw_info.resource_owner.name }
33
+ end
34
+
35
+ extra do
36
+ { raw_info: raw_info, scope: scope }
37
+ end
38
+
39
+ def raw_info
40
+ access_token.options[:mode] = :header
41
+ @raw_info ||= fetch_user_info
42
+ end
43
+
44
+ def scope
45
+ access_token['scope']
46
+ end
47
+
48
+ def callback_url
49
+ full_host + script_name + callback_path
50
+ end
51
+
52
+ private
53
+
54
+ def fetch_user_info
55
+ response_body = access_token.get(INFO_PATH).body
56
+ raw_data = ActiveSupport::JSON.decode(response_body)
57
+ ::Icalia::Event::Deserializer.new(raw_data).perform
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-icalia/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.authors = ['Roberto Quintanilla']
8
+ spec.email = ['vov@icalialabs.com']
9
+ spec.description = %q{Official Omniauth Strategy for Icalia.}
10
+ spec.summary = %q{Official Omniauth Strategy for Icalia.}
11
+ spec.homepage = 'https://github.com/IcaliaLabs/omniauth-icalia'
12
+ spec.license = 'MIT'
13
+
14
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ spec.files = `git ls-files`.split("\n")
16
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ spec.name = 'omniauth-icalia'
18
+ spec.require_paths = ['lib']
19
+ spec.version = Omniauth::Icalia::VERSION
20
+
21
+ spec.add_dependency 'omniauth', '~> 1.5'
22
+ spec.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
23
+ spec.add_dependency 'icalia-sdk-event-core', '~> 0.3.3'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.17'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ end
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe OmniAuth::Strategies::Icalia do
4
+ let(:access_token) { instance_double('AccessToken', :options => {}, :[] => 'user') }
5
+ let(:parsed_response) { instance_double('ParsedResponse') }
6
+ let(:response) { instance_double('Response', :parsed => parsed_response) }
7
+
8
+ let(:example_overridden_site) { 'https://example.com' }
9
+ let(:example_overridden_token_url) { 'https://example.com/oauth/token' }
10
+ let(:example_overridden_authorize_url) { 'https://example.com/oauth/authorize' }
11
+
12
+ let(:example_options) { {} }
13
+
14
+ subject do
15
+ OmniAuth::Strategies::Icalia.new 'ICALIA_CLIENT_KEY',
16
+ 'ICALIA_CLIENT_SECRET',
17
+ example_options
18
+ end
19
+
20
+ before :each do
21
+ allow(subject).to receive(:access_token).and_return(access_token)
22
+ end
23
+
24
+ describe 'client options' do
25
+ context 'defaults' do
26
+ it 'site is artanis' do
27
+ expect(subject.options.client_options.site).to eq 'https://artanis.icalialabs.com'
28
+ end
29
+
30
+ it 'authorize url is artanis authorize url' do
31
+ expect(subject.options.client_options.authorize_url).to eq 'https://artanis.icalialabs.com/oauth/authorize'
32
+ end
33
+
34
+ it 'token url is artanis token url' do
35
+ expect(subject.options.client_options.token_url).to eq 'https://artanis.icalialabs.com/oauth/token'
36
+ end
37
+ end
38
+
39
+ context 'overrides' do
40
+ let :example_options do
41
+ {
42
+ client_options: {
43
+ site: example_overridden_site,
44
+ token_url: example_overridden_token_url,
45
+ authorize_url: example_overridden_authorize_url,
46
+ }
47
+ }
48
+ end
49
+
50
+ it 'allows overriding the site' do
51
+ expect(subject.options.client_options.site)
52
+ .to eq example_overridden_site
53
+ end
54
+
55
+ it 'allows overriding the authorize url' do
56
+ expect(subject.options.client_options.authorize_url)
57
+ .to eq example_overridden_authorize_url
58
+ end
59
+
60
+ it 'allows overriding the token url' do
61
+ expect(subject.options.client_options.token_url)
62
+ .to eq example_overridden_token_url
63
+ end
64
+ end
65
+ end
66
+
67
+ describe '#raw_info' do
68
+ it 'should use relative paths' do
69
+ expect(access_token).to receive(:get).with('/oauth/token/info?include=resource-owner.email-accounts').and_return(response)
70
+ expect(subject.raw_info).to eq(parsed_response)
71
+ end
72
+
73
+ it 'should use the header auth mode' do
74
+ expect(access_token).to receive(:get).with('user').and_return(response)
75
+ subject.raw_info
76
+ expect(access_token.options[:mode]).to eq(:header)
77
+ end
78
+ end
79
+
80
+ describe '#info.email' do
81
+ it 'should use any available email' do
82
+ allow(subject).to receive(:raw_info).and_return({})
83
+ allow(subject).to receive(:email).and_return('you@example.com')
84
+ expect(subject.info['email']).to eq('you@example.com')
85
+ end
86
+ end
87
+
88
+ context '#info.urls' do
89
+ it 'should use html_url from raw_info' do
90
+ allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
91
+ expect(subject.info['urls']['icalia']).to eq('http://enterprise/me')
92
+ end
93
+ end
94
+
95
+ context '#extra.scope' do
96
+ it 'returns the scope on the returned access_token' do
97
+ expect(subject.scope).to eq('user')
98
+ end
99
+ end
100
+
101
+ describe '#callback_url' do
102
+ it 'is a combination of host, script name, and callback path' do
103
+ allow(subject).to receive(:full_host).and_return('https://example.com')
104
+ allow(subject).to receive(:script_name).and_return('/sub_uri')
105
+
106
+ expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/icalia/callback')
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'omniauth-icalia'
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = 'examples.txt'
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-icalia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Quintanilla
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.4.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: icalia-sdk-event-core
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.3.3
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.17'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.17'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '10.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '10.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
103
+ description: Official Omniauth Strategy for Icalia.
104
+ email:
105
+ - vov@icalialabs.com
106
+ executables:
107
+ - console
108
+ - setup
109
+ extensions: []
110
+ extra_rdoc_files: []
111
+ files:
112
+ - ".dockerignore"
113
+ - ".gitignore"
114
+ - ".rspec"
115
+ - ".semaphore/bin/docker-image-manager"
116
+ - ".semaphore/bin/generate-dotenv-file"
117
+ - ".semaphore/publishing.yml"
118
+ - ".semaphore/semaphore.yml"
119
+ - ".travis.yml"
120
+ - CODE_OF_CONDUCT.md
121
+ - Dockerfile
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - ci-compose.yml
130
+ - docker-compose.yml
131
+ - lib/omniauth-icalia.rb
132
+ - lib/omniauth-icalia/version.rb
133
+ - lib/omniauth/strategies/icalia.rb
134
+ - omniauth-icalia.gemspec
135
+ - spec/omniauth/strategies/icalia_spec.rb
136
+ - spec/spec_helper.rb
137
+ homepage: https://github.com/IcaliaLabs/omniauth-icalia
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.7.6
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Official Omniauth Strategy for Icalia.
161
+ test_files:
162
+ - spec/omniauth/strategies/icalia_spec.rb
163
+ - spec/spec_helper.rb