serverless_hub 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: e6cde32b9ba47b7a7336cd41e3bfdfeb438e888ae1bd34c0500237e42a4cb313
4
+ data.tar.gz: 8319c22ad1ccae18265d3f9002308b313154018c097074664a290dfe691bb112
5
+ SHA512:
6
+ metadata.gz: cf801fdf4d86d1629aa46b9f96dde27488ee7b6f3672813a66d5e5bd7659a0c4369bf59b3b58b211c93c46b340a908001c02acfa2f19c8048dbe2641f4eec2a5
7
+ data.tar.gz: 26b988e0d8faa83b33cf7d4463920aab18fb2e31d9802bf5e5990517b96e51e3908da64d05a3403a42a7b181a739f5dd9d49d324d937682ef7faf8becea3044a
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/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ s-hub
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.5.0
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.16.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in serverless_hub.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,188 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ serverless_hub (0.1.0)
5
+ json-jwt (~> 1.10.0)
6
+ jwt (~> 2.1.0)
7
+ lamby (~> 1.0.1)
8
+ rest-client (~> 2.0, >= 2.0.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (6.0.0)
14
+ actionpack (= 6.0.0)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (6.0.0)
18
+ actionpack (= 6.0.0)
19
+ activejob (= 6.0.0)
20
+ activerecord (= 6.0.0)
21
+ activestorage (= 6.0.0)
22
+ activesupport (= 6.0.0)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.0.0)
25
+ actionpack (= 6.0.0)
26
+ actionview (= 6.0.0)
27
+ activejob (= 6.0.0)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.0.0)
31
+ actionview (= 6.0.0)
32
+ activesupport (= 6.0.0)
33
+ rack (~> 2.0)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.0.0)
38
+ actionpack (= 6.0.0)
39
+ activerecord (= 6.0.0)
40
+ activestorage (= 6.0.0)
41
+ activesupport (= 6.0.0)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.0.0)
44
+ activesupport (= 6.0.0)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.0.0)
50
+ activesupport (= 6.0.0)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.0.0)
53
+ activesupport (= 6.0.0)
54
+ activerecord (6.0.0)
55
+ activemodel (= 6.0.0)
56
+ activesupport (= 6.0.0)
57
+ activestorage (6.0.0)
58
+ actionpack (= 6.0.0)
59
+ activejob (= 6.0.0)
60
+ activerecord (= 6.0.0)
61
+ marcel (~> 0.3.1)
62
+ activesupport (6.0.0)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 0.7, < 2)
65
+ minitest (~> 5.1)
66
+ tzinfo (~> 1.1)
67
+ zeitwerk (~> 2.1, >= 2.1.8)
68
+ aes_key_wrap (1.0.1)
69
+ bindata (2.4.4)
70
+ builder (3.2.3)
71
+ concurrent-ruby (1.1.5)
72
+ crass (1.0.4)
73
+ diff-lcs (1.3)
74
+ domain_name (0.5.20190701)
75
+ unf (>= 0.0.5, < 1.0.0)
76
+ erubi (1.9.0)
77
+ globalid (0.4.2)
78
+ activesupport (>= 4.2.0)
79
+ http-accept (1.7.0)
80
+ http-cookie (1.0.3)
81
+ domain_name (~> 0.5)
82
+ i18n (1.7.0)
83
+ concurrent-ruby (~> 1.0)
84
+ json-jwt (1.10.2)
85
+ activesupport (>= 4.2)
86
+ aes_key_wrap
87
+ bindata
88
+ jwt (2.1.0)
89
+ lamby (1.0.1)
90
+ rack
91
+ rails
92
+ loofah (2.3.0)
93
+ crass (~> 1.0.2)
94
+ nokogiri (>= 1.5.9)
95
+ mail (2.7.1)
96
+ mini_mime (>= 0.1.1)
97
+ marcel (0.3.3)
98
+ mimemagic (~> 0.3.2)
99
+ method_source (0.9.2)
100
+ mime-types (3.3)
101
+ mime-types-data (~> 3.2015)
102
+ mime-types-data (3.2019.1009)
103
+ mimemagic (0.3.3)
104
+ mini_mime (1.0.2)
105
+ mini_portile2 (2.4.0)
106
+ minitest (5.12.2)
107
+ netrc (0.11.0)
108
+ nio4r (2.5.2)
109
+ nokogiri (1.10.4)
110
+ mini_portile2 (~> 2.4.0)
111
+ rack (2.0.7)
112
+ rack-test (1.1.0)
113
+ rack (>= 1.0, < 3)
114
+ rails (6.0.0)
115
+ actioncable (= 6.0.0)
116
+ actionmailbox (= 6.0.0)
117
+ actionmailer (= 6.0.0)
118
+ actionpack (= 6.0.0)
119
+ actiontext (= 6.0.0)
120
+ actionview (= 6.0.0)
121
+ activejob (= 6.0.0)
122
+ activemodel (= 6.0.0)
123
+ activerecord (= 6.0.0)
124
+ activestorage (= 6.0.0)
125
+ activesupport (= 6.0.0)
126
+ bundler (>= 1.3.0)
127
+ railties (= 6.0.0)
128
+ sprockets-rails (>= 2.0.0)
129
+ rails-dom-testing (2.0.3)
130
+ activesupport (>= 4.2.0)
131
+ nokogiri (>= 1.6)
132
+ rails-html-sanitizer (1.3.0)
133
+ loofah (~> 2.3)
134
+ railties (6.0.0)
135
+ actionpack (= 6.0.0)
136
+ activesupport (= 6.0.0)
137
+ method_source
138
+ rake (>= 0.8.7)
139
+ thor (>= 0.20.3, < 2.0)
140
+ rake (10.5.0)
141
+ rest-client (2.1.0)
142
+ http-accept (>= 1.7.0, < 2.0)
143
+ http-cookie (>= 1.0.2, < 2.0)
144
+ mime-types (>= 1.16, < 4.0)
145
+ netrc (~> 0.8)
146
+ rspec (3.9.0)
147
+ rspec-core (~> 3.9.0)
148
+ rspec-expectations (~> 3.9.0)
149
+ rspec-mocks (~> 3.9.0)
150
+ rspec-core (3.9.0)
151
+ rspec-support (~> 3.9.0)
152
+ rspec-expectations (3.9.0)
153
+ diff-lcs (>= 1.2.0, < 2.0)
154
+ rspec-support (~> 3.9.0)
155
+ rspec-mocks (3.9.0)
156
+ diff-lcs (>= 1.2.0, < 2.0)
157
+ rspec-support (~> 3.9.0)
158
+ rspec-support (3.9.0)
159
+ sprockets (4.0.0)
160
+ concurrent-ruby (~> 1.0)
161
+ rack (> 1, < 3)
162
+ sprockets-rails (3.2.1)
163
+ actionpack (>= 4.0)
164
+ activesupport (>= 4.0)
165
+ sprockets (>= 3.0.0)
166
+ thor (0.20.3)
167
+ thread_safe (0.3.6)
168
+ tzinfo (1.2.5)
169
+ thread_safe (~> 0.1)
170
+ unf (0.1.4)
171
+ unf_ext
172
+ unf_ext (0.0.7.6)
173
+ websocket-driver (0.7.1)
174
+ websocket-extensions (>= 0.1.0)
175
+ websocket-extensions (0.1.4)
176
+ zeitwerk (2.2.0)
177
+
178
+ PLATFORMS
179
+ ruby
180
+
181
+ DEPENDENCIES
182
+ bundler (~> 2.0.2)
183
+ rake (~> 10.0)
184
+ rspec (~> 3.0)
185
+ serverless_hub!
186
+
187
+ BUNDLED WITH
188
+ 2.0.2
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ServerlessHub
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/serverless_hub`. 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 'serverless_hub'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install serverless_hub
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]/serverless_hub.
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 "serverless_hub"
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
@@ -0,0 +1,7 @@
1
+ require "serverless_hub/version"
2
+ require "serverless_hub/authorizer"
3
+ require "serverless_hub/handler"
4
+
5
+ module ServerlessHub
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,63 @@
1
+ require 'jwt'
2
+ require 'json/jwt'
3
+ require "rest-client"
4
+
5
+ module ServerlessHub
6
+ class AuthorizerTokenDecoder
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if env["HTTP_AUTHORIZATION"]
13
+ tokens = decoded_token(env["HTTP_AUTHORIZATION"])
14
+
15
+ if tokens.present?
16
+ claims = tokens[0]
17
+
18
+ env["lambda.event"]["requestContext"]["authorizer"] = {
19
+ "principalId" => claims["sub"],
20
+ "claims" => claims
21
+ }
22
+ end
23
+ end
24
+
25
+ return @app.call(env)
26
+ end
27
+
28
+ def self.jwks
29
+ RestClient.get(ENV["JWKS_URL"] || '')
30
+ end
31
+
32
+ private
33
+ def decoded_token(token)
34
+ if token.present? && token.starts_with?("Bearer ")
35
+ token = token[7, token.length]
36
+ end
37
+
38
+ JWT.decode token, jwk_set.first.to_key, true, { algorithm: 'RS256' } rescue ""
39
+ end
40
+
41
+ def jwk_set
42
+ @jwk_set ||= JSON::JWK::Set.new(
43
+ JSON.parse(
44
+ AuthorizerTokenDecoder.jwks
45
+ )
46
+ )
47
+ end
48
+ end
49
+
50
+ class Authorizer
51
+ def initialize(app)
52
+ @app = app
53
+ end
54
+
55
+ def call(env)
56
+ if env["lambda.event"] && env["lambda.event"]["requestContext"]
57
+ env["authorizer"] = env["lambda.event"]["requestContext"]["authorizer"]
58
+ end
59
+
60
+ return @app.call(env)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails'
2
+ require 'lamby'
3
+
4
+ module ServerlessHub
5
+ module Handler
6
+ $app ||= Rack::Builder.new do
7
+ app = Proc.new do |env|
8
+ ['200', {'Content-Type' => 'text/html'}, ['A barebones rack app.']]
9
+ end
10
+ run app
11
+ end.to_app
12
+
13
+ def self.call(event:, context:)
14
+ return "Warm Up" if event["source"] == "serverless-plugin-warmup"
15
+
16
+ Lamby.handler $app, event, context
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module ServerlessHub
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "serverless_hub/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "serverless_hub"
8
+ spec.version = ServerlessHub::VERSION
9
+ spec.authors = ["Will"]
10
+ spec.email = ["will@devhub.co"]
11
+
12
+ spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "https://goolge.com.au"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://goolge.com.au"
23
+ spec.metadata["changelog_uri"] = "https://goolge.com.au"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.0.2"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+
42
+ spec.add_runtime_dependency "json-jwt", "~> 1.10.0"
43
+ spec.add_runtime_dependency "jwt", "~> 2.1.0"
44
+ spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
45
+ spec.add_runtime_dependency 'lamby', '~> 1.0.1'
46
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: serverless_hub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Will
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json-jwt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.10.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.10.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: jwt
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '2.0'
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 2.0.0
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: lamby
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.1
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.0.1
117
+ description: Write a longer description or delete this line.
118
+ email:
119
+ - will@devhub.co
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitignore"
125
+ - ".rspec"
126
+ - ".ruby-gemset"
127
+ - ".ruby-version"
128
+ - ".travis.yml"
129
+ - Gemfile
130
+ - Gemfile.lock
131
+ - README.md
132
+ - Rakefile
133
+ - bin/console
134
+ - bin/setup
135
+ - lib/serverless_hub.rb
136
+ - lib/serverless_hub/authorizer.rb
137
+ - lib/serverless_hub/handler.rb
138
+ - lib/serverless_hub/version.rb
139
+ - serverless_hub.gemspec
140
+ homepage: https://goolge.com.au
141
+ licenses: []
142
+ metadata:
143
+ homepage_uri: https://goolge.com.au
144
+ source_code_uri: https://goolge.com.au
145
+ changelog_uri: https://goolge.com.au
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.7.9
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Write a short summary, because RubyGems requires one.
166
+ test_files: []