shopify-graphql_proxy 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
+ SHA1:
3
+ metadata.gz: 63eb52573ec696136c330d46e6366b08851a0fa0
4
+ data.tar.gz: 0a072590efaee1179a3656e36edc9ad8941a5165
5
+ SHA512:
6
+ metadata.gz: 6db9250610bd658d30387181eed6b22be8f77ccefdc4ffffe7d9ab241849b03ff5d0ab4425496404266392a4e9918a54a5977fa011f093219cbbd7b06b375797
7
+ data.tar.gz: ba7d4da8592744e36f05816077700c817947caa2921e69d2f7f5223cdc4af4b0319032435457a0cc1140f45a61db85f7aa3808bd7c989540b26748cc8032843e
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in shopify-graphql_proxy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 imontalvomiguel
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/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,35 @@
1
+ require "rack-proxy"
2
+
3
+ module Shopify
4
+ class GraphQLProxy < Rack::Proxy
5
+ PROXY_BASE_PATH = "/graphql"
6
+ GRAPHQL_PATH = "/admin/api/graphql.json"
7
+ VERSION = "0.1.0"
8
+
9
+ def perform_request(env)
10
+ request = Rack::Request.new(env)
11
+
12
+ if request.path_info =~ %r{^#{PROXY_BASE_PATH}}
13
+ unless request.request_method == "POST"
14
+ return @app.call(env)
15
+ end
16
+
17
+ unless request.session.key?(:shopify)
18
+ return ["403", {"Content-Type" => "text/plain"}, ["Unauthorized"]]
19
+ end
20
+
21
+ backend = URI("https://#{request.session[:shopify][:shop]}#{GRAPHQL_PATH}")
22
+
23
+ env["HTTP_HOST"] = backend.host
24
+ env["PATH_INFO"] = backend.path
25
+ env["HTTP_X_SHOPIFY_ACCESS_TOKEN"] = request.session[:shopify][:token]
26
+ env["SCRIPT_NAME"] = ""
27
+ env["HTTP_COOKIE"] = nil
28
+
29
+ super(env)
30
+ else
31
+ @app.call(env)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "shopify-graphql_proxy"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["montalvomiguelo"]
9
+ spec.email = ["me@montalvomiguelo.com"]
10
+
11
+ spec.summary = %q{Securely proxying graphql requests from our app to shopify}
12
+ spec.description = %q{Securely proxying graphql requests from our app to shopify}
13
+ spec.homepage = "https://github.com/montalvomiguelo/shopify-graphql_proxy"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f =~ %r{^(test|spec|features)/}
18
+ end
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.15"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
24
+ spec.add_development_dependency "rack-test", "~> 1.0"
25
+ spec.add_dependency "rack-proxy", "~> 0.6.4"
26
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shopify-graphql_proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - montalvomiguelo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-24 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: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-proxy
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.4
83
+ description: Securely proxying graphql requests from our app to shopify
84
+ email:
85
+ - me@montalvomiguelo.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - Rakefile
94
+ - lib/shopify/graphql_proxy.rb
95
+ - shopify-graphql_proxy.gemspec
96
+ homepage: https://github.com/montalvomiguelo/shopify-graphql_proxy
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.6.13
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Securely proxying graphql requests from our app to shopify
120
+ test_files: []