postmark-inbound 0.0.3 → 0.1.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 +4 -4
- data/README.md +3 -2
- data/lib/postmark-inbound/config.rb +2 -2
- data/lib/postmark-inbound/server.rb +4 -11
- data/lib/postmark-inbound/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 034aa428798a3824eddbccfcc91f128d32d09983
|
4
|
+
data.tar.gz: 0340b574dc1ef7d314b86417e9c9a6c9f5b9d3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb30b5de2aa8042ee269c0dd88caf501132710e63a7cbfb7e0b25adad0fdd4c33016ca67704713b85656a0980575127041899872a2497f5650added9845c1451
|
7
|
+
data.tar.gz: e7be9a60f997880660ad087ca3bb360f7c76f2b0cede8fc4acd956ac39ea78002dd24f9385e48bc38cbc6eed7e55f8eacd1c0be60b629e6c56142b4340764789
|
data/README.md
CHANGED
@@ -30,8 +30,9 @@ PINS.logger.level = Logger::DEBUG
|
|
30
30
|
PINS::Config.setup do |c|
|
31
31
|
# User custom data
|
32
32
|
c.user = {my_data1: 'Something', my_data2: 'Somethingelse'}
|
33
|
-
#
|
34
|
-
|
33
|
+
# For security, basic auth is required.
|
34
|
+
# Set accepted passwords; username is ignored
|
35
|
+
c.passwords = [
|
35
36
|
'someSTRING1234',
|
36
37
|
'OTHERstring987'
|
37
38
|
]
|
@@ -26,12 +26,12 @@ module PINS
|
|
26
26
|
end
|
27
27
|
|
28
28
|
attr_accessor :user
|
29
|
-
attr_accessor :
|
29
|
+
attr_accessor :passwords
|
30
30
|
attr_accessor :dump_errors
|
31
31
|
attr_accessor :logging
|
32
32
|
|
33
33
|
def initialize
|
34
|
-
@
|
34
|
+
@passwords = []
|
35
35
|
@dump_errors = false
|
36
36
|
@logging = false
|
37
37
|
end
|
@@ -6,6 +6,10 @@ module PINS
|
|
6
6
|
# The Sinatra server
|
7
7
|
class Server < Sinatra::Base
|
8
8
|
|
9
|
+
use Rack::Auth::Basic, "Restricted Area" do |username, password|
|
10
|
+
Config.shared.passwords.include?(password)
|
11
|
+
end
|
12
|
+
|
9
13
|
helpers Helper
|
10
14
|
|
11
15
|
configure do
|
@@ -17,11 +21,6 @@ module PINS
|
|
17
21
|
PINS.logger.info('Sinatra server configured.')
|
18
22
|
end
|
19
23
|
|
20
|
-
before do
|
21
|
-
tokens = Config.shared.auth_tokens
|
22
|
-
halt 401 unless tokens.empty? || tokens.include?(params[:auth])
|
23
|
-
end
|
24
|
-
|
25
24
|
post '/' do
|
26
25
|
PINS.logger.info('Incoming request received.')
|
27
26
|
PINS.logger.debug("Body size: #{request.content_length} bytes")
|
@@ -36,12 +35,6 @@ module PINS
|
|
36
35
|
json_with_object({message: 'Huh, nothing here.'})
|
37
36
|
end
|
38
37
|
|
39
|
-
error 401 do
|
40
|
-
PINS.logger.info(params[:auth] ? 'Invalid auth token provided.' : 'Missing auth token.')
|
41
|
-
PINS.logger.debug("Provided auth token: #{params[:auth]}") if params[:auth]
|
42
|
-
json_with_object({message: 'Oops, need a valid auth.'})
|
43
|
-
end
|
44
|
-
|
45
38
|
error do
|
46
39
|
status 500
|
47
40
|
err = env['sinatra.error']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark-inbound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken J.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kajiki
|