alephbet 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c971b8cb75c095dbde099fb3f59dd83e420cc48e9b6a1172e61587b2ea8a9dc1
|
4
|
+
data.tar.gz: 472e4e0b7cbd85a235f99fb6388a45ff714246e82633929d1d4d8d012e09e448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587b7c4291025cc0414480c7cdc3b7a4f1ee16bf56733cdffe8ff8f9de998b6def238d30894532fc1e5682ea8e80810b098b839affb6bab345d82b6cd7522fe8
|
7
|
+
data.tar.gz: e56b686c9cc246b72493cf2ebda60ad3b5122c4c328169f6f96949de8980b2f702e6eacf9ff5889656026f80c49039d816c8b6ffb9a0a976a996ace13f3aa6ec
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Alephbet
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
-
protect_from_forgery with
|
3
|
+
protect_from_forgery :with => :exception
|
4
|
+
before_action :cors_headers, :if => -> { Alephbet.enable_cors }
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def cors_headers
|
9
|
+
response.headers["Access-Control-Allow-Origin"] = Alephbet.cors_allow_origin
|
10
|
+
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
|
11
|
+
response.headers["Access-Control-Allow-Headers"] = Alephbet.cors_allow_headers
|
12
|
+
response.headers["Access-Control-Max-Age"] = "1728000"
|
13
|
+
end
|
4
14
|
end
|
5
15
|
end
|
@@ -4,7 +4,6 @@ module Alephbet
|
|
4
4
|
|
5
5
|
# acts a browser-friendly API endpoint
|
6
6
|
skip_before_action :verify_authenticity_token
|
7
|
-
before_action :cors_headers
|
8
7
|
before_action :check_api_key, :except => :cors_preflight_check
|
9
8
|
|
10
9
|
def experiments
|
@@ -82,12 +81,5 @@ module Alephbet
|
|
82
81
|
def permitted_params
|
83
82
|
params.permit(PARAMS)
|
84
83
|
end
|
85
|
-
|
86
|
-
def cors_headers
|
87
|
-
response.headers["Access-Control-Allow-Origin"] = Alephbet.cors_allow_origin
|
88
|
-
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
|
89
|
-
response.headers["Access-Control-Allow-Headers"] = Alephbet.cors_allow_headers
|
90
|
-
response.headers["Access-Control-Max-Age"] = "1728000"
|
91
|
-
end
|
92
84
|
end
|
93
85
|
end
|
data/lib/alephbet.rb
CHANGED
@@ -2,11 +2,12 @@ require "alephbet/engine"
|
|
2
2
|
|
3
3
|
module Alephbet
|
4
4
|
class << self
|
5
|
-
attr_accessor :api_key, :cors_allow_origin, :cors_allow_headers
|
5
|
+
attr_accessor :api_key, :enable_cors, :cors_allow_origin, :cors_allow_headers
|
6
6
|
|
7
7
|
def setup
|
8
8
|
# fallback api_key if none specified
|
9
9
|
self.api_key = SecureRandom.uuid
|
10
|
+
self.enable_cors = true
|
10
11
|
self.cors_allow_origin = "*"
|
11
12
|
self.cors_allow_headers = "*"
|
12
13
|
yield(self) if block_given?
|
data/lib/alephbet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoav Aner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|