dandelion_s1 0.3.0 → 0.4.1
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/dandelion_s1.rb +86 -63
- data.tar.gz.sig +0 -0
- metadata +41 -36
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc83d81d5216867b5d224c4f645f3258b91647fb5c9289720ebb1a1ad90b3e2a
|
4
|
+
data.tar.gz: 6830244e9702bdc2301b110d09fb91f5db8c4b661074a9cc8cc3da3f95a771cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b3b69f1bd3744946257f3f97923961a141f0590166b7e0f77600b8ecaa1ea2a23d7b86610351242abb2399825e435bebdfd877f655a1182ced01ecd9a95c8d1
|
7
|
+
data.tar.gz: e7a22834b7b7e86b35d89cce16fda4c36f35072535d3c0b03185ef743bd2554c76f16efcbbc3db030191966833559c12ed2ec1c6c99eed045bf74f635680f61a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dandelion_s1.rb
CHANGED
@@ -8,45 +8,51 @@ require 'simple-config'
|
|
8
8
|
|
9
9
|
|
10
10
|
class DandelionS1 < RackRscript
|
11
|
+
include RXFHelperModule
|
11
12
|
|
12
13
|
def initialize(opts={})
|
13
14
|
|
14
|
-
h = {root: 'www', static: []}.merge(opts)
|
15
|
-
|
15
|
+
h = {root: 'www', static: [], passwords: {'user' => 'us3r'}}.merge(opts)
|
16
|
+
|
17
|
+
@passwords = h[:passwords]
|
16
18
|
access_list = h[:access]
|
17
|
-
@app_root = Dir.pwd
|
18
19
|
|
19
20
|
#@access_list = {'/do/r/hello3' => 'user'}
|
20
|
-
|
21
|
+
|
21
22
|
if access_list then
|
22
|
-
|
23
|
+
|
23
24
|
h2 = SimpleConfig.new(access_list).to_h
|
24
25
|
conf_access = h2[:body] || h2
|
25
26
|
@access_list = conf_access.inject({}) \
|
26
27
|
{|r,x| k,v = x; r.merge(k.to_s => v.split)}
|
27
|
-
|
28
|
+
|
28
29
|
end
|
29
|
-
|
30
|
-
h3 = %i(log pkg_src rsc_host
|
30
|
+
|
31
|
+
h3 = %i(log pkg_src rsc_host rsc root static debug)\
|
31
32
|
.inject({}) {|r,x| r.merge(x => h[x])}
|
32
|
-
|
33
|
-
super(h3)
|
34
|
-
|
33
|
+
|
34
|
+
super(**h3)
|
35
|
+
@log.debug '@access_list: ' + @access_list.inspect if @log
|
36
|
+
@log.debug 'end of initialize' if @log
|
37
|
+
|
35
38
|
end
|
36
39
|
|
37
40
|
def call(e)
|
38
41
|
|
39
42
|
request = e['REQUEST_PATH']
|
40
|
-
|
43
|
+
@log.debug 'request: ' + request.inspect if @log
|
44
|
+
|
41
45
|
return super(e) if request == '/login'
|
42
46
|
r = @access_list.detect {|k,v| request =~ Regexp.new(k)} if @access_list
|
43
47
|
private_user = r ? r.last : nil
|
44
|
-
|
48
|
+
|
45
49
|
req = Rack::Request.new(e)
|
46
50
|
user = req.session[:username]
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
|
52
|
+
@log.debug 'user: ' + user.inspect if @log
|
53
|
+
#@log.debug '@e: ' + e.inspect if @log
|
54
|
+
return jumpto '/login2?referer=' + e['PATH_INFO'] unless user
|
55
|
+
|
50
56
|
if private_user.nil? then
|
51
57
|
super(e)
|
52
58
|
elsif (private_user.is_a? String and private_user == user) \
|
@@ -57,74 +63,91 @@ class DandelionS1 < RackRscript
|
|
57
63
|
end
|
58
64
|
|
59
65
|
end
|
60
|
-
|
66
|
+
|
61
67
|
protected
|
62
|
-
|
63
|
-
def default_routes(env, params)
|
64
|
-
|
65
|
-
get '/login' do
|
66
|
-
|
67
|
-
s=<<EOF
|
68
|
-
login
|
69
|
-
username: [ ]
|
70
|
-
password: [ ]
|
71
68
|
|
72
|
-
|
73
|
-
|
69
|
+
def default_routes(env, params)
|
70
|
+
|
71
|
+
log = @log
|
72
|
+
|
73
|
+
get '/login2/*' do
|
74
|
+
params[:splat].inspect
|
75
|
+
redirect '/login' + params[:splat].first
|
76
|
+
end
|
77
|
+
|
78
|
+
get '/login/*' do
|
79
|
+
url = params[:splat].any? ? params[:splat][0][/(?<=referer=).*/] : '/'
|
80
|
+
login_form(referer: url)
|
81
|
+
end
|
74
82
|
|
75
|
-
Martile.new(s).to_html
|
76
|
-
end
|
77
|
-
|
78
83
|
post '/login' do
|
79
|
-
|
84
|
+
|
80
85
|
h = @req.params
|
81
|
-
@req.session[:username] = h['username']
|
82
86
|
|
83
|
-
|
84
|
-
|
87
|
+
if @passwords[h['username']] == h['password'] then
|
88
|
+
|
89
|
+
@req.session[:username] = h['username']
|
90
|
+
#'you are now logged in as ' + h['username']
|
91
|
+
redirect h['referer']
|
92
|
+
|
93
|
+
else
|
94
|
+
|
95
|
+
login_form('Invalid username or password, try again.',401)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
85
100
|
end
|
86
|
-
|
101
|
+
|
87
102
|
get '/logout' do
|
88
|
-
|
103
|
+
|
89
104
|
@req.session.clear
|
90
105
|
'you are now logged out'
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
get '/session' do
|
95
|
-
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
#get '/session' do
|
110
|
+
|
96
111
|
#@req.session.expires
|
97
112
|
#@req.session.options[:expire_after] = 1
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
113
|
+
#@req.session.options.inspect
|
114
|
+
|
115
|
+
#end
|
116
|
+
|
102
117
|
get '/user' do
|
103
|
-
|
118
|
+
|
104
119
|
if @req.session[:username] then
|
105
120
|
'You are ' + @req.session[:username]
|
106
121
|
else
|
107
122
|
'you need to log in to view this page'
|
108
|
-
end
|
109
|
-
|
123
|
+
end
|
124
|
+
|
110
125
|
end
|
111
126
|
|
112
127
|
get '/unauthorised' do
|
113
|
-
'unauthorised user'
|
128
|
+
['unauthorised user', 'text/plain', 403]
|
114
129
|
end
|
115
|
-
|
116
|
-
super(env, params)
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
def jumpto(request)
|
123
|
-
|
124
|
-
content, content_type, status_code = run_route(request)
|
125
|
-
content_type ||= 'text/html'
|
126
|
-
[status_code=401, {"Content-Type" => content_type}, [content]]
|
127
|
-
|
130
|
+
|
131
|
+
super(env, params)
|
132
|
+
|
128
133
|
end
|
129
134
|
|
135
|
+
def login_form(msg='Log in to this site.', http_code=200, referer: '/')
|
136
|
+
|
137
|
+
s=<<EOF
|
138
|
+
p #{msg}
|
139
|
+
|
140
|
+
login
|
141
|
+
username: [ ]
|
142
|
+
password: [ ]
|
143
|
+
[! referer: #{referer}
|
144
|
+
]
|
145
|
+
[login](/login)
|
146
|
+
EOF
|
147
|
+
|
148
|
+
[Martile.new(s).to_s, 'text/slim', http_code]
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
|
130
153
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dandelion_s1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAMWGLNvh2P5idDQH6p+wxxVKnt/b2fDjXlAx8/A8Q
|
29
|
+
3q+6iEM1rEvmNsnYvagbyDczPEhvoxuWvVUL0huwa99R4nX5o4yqr4IOR6NVZ724
|
30
|
+
tiC022XXJ0ysp2jIlttnzKeYtadjPecS8MXy2XiIpHqNpAfRfxu3XHz6ZPDs2Ein
|
31
|
+
76MsY6p7rsKjhd6NfzEzWrudixdPXHEDRsWhvc4D8yJ8sXRRlsqvYyJzWPAxjYDP
|
32
|
+
dGYM0uAJz9SVDPY+Vtc5SxUSjcxum8Q9AxhIyRhN6fELUh/aWKXnCX6oxLLvtsNu
|
33
|
+
woIuTfN3+nievIwQikkOMmmOHoKClutOf/QvliSCEBWgPEYNitoCAbt5kde/pLqm
|
34
|
+
gHDzDElZg+1jI3TgwZ+kIKwt7Vun9eZH2g8dc31fjlfxzKBRnOh5p7CoxbW4rx7M
|
35
|
+
JtmSOhu/qtu75iQs8PmwtvhDACcdpf0Q5VGHeyLvKq5LqZMqX9BK9BOD41uV9rt/
|
36
|
+
k7EFkjCAj62C0O4oFjSMVJQW
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: rack-rscript
|
@@ -38,62 +43,62 @@ dependencies:
|
|
38
43
|
requirements:
|
39
44
|
- - "~>"
|
40
45
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
46
|
+
version: '1.3'
|
42
47
|
- - ">="
|
43
48
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.1
|
49
|
+
version: 1.3.1
|
45
50
|
type: :runtime
|
46
51
|
prerelease: false
|
47
52
|
version_requirements: !ruby/object:Gem::Requirement
|
48
53
|
requirements:
|
49
54
|
- - "~>"
|
50
55
|
- !ruby/object:Gem::Version
|
51
|
-
version: '1.
|
56
|
+
version: '1.3'
|
52
57
|
- - ">="
|
53
58
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.1
|
59
|
+
version: 1.3.1
|
55
60
|
- !ruby/object:Gem::Dependency
|
56
61
|
name: simple-config
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
58
63
|
requirements:
|
59
64
|
- - "~>"
|
60
65
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
66
|
+
version: '0.7'
|
62
67
|
- - ">="
|
63
68
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
69
|
+
version: 0.7.1
|
65
70
|
type: :runtime
|
66
71
|
prerelease: false
|
67
72
|
version_requirements: !ruby/object:Gem::Requirement
|
68
73
|
requirements:
|
69
74
|
- - "~>"
|
70
75
|
- !ruby/object:Gem::Version
|
71
|
-
version: '0.
|
76
|
+
version: '0.7'
|
72
77
|
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
79
|
+
version: 0.7.1
|
75
80
|
- !ruby/object:Gem::Dependency
|
76
81
|
name: martile
|
77
82
|
requirement: !ruby/object:Gem::Requirement
|
78
83
|
requirements:
|
79
84
|
- - "~>"
|
80
85
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
86
|
+
version: '1.4'
|
82
87
|
- - ">="
|
83
88
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
89
|
+
version: 1.4.6
|
85
90
|
type: :runtime
|
86
91
|
prerelease: false
|
87
92
|
version_requirements: !ruby/object:Gem::Requirement
|
88
93
|
requirements:
|
89
94
|
- - "~>"
|
90
95
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
96
|
+
version: '1.4'
|
92
97
|
- - ">="
|
93
98
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
99
|
+
version: 1.4.6
|
95
100
|
description:
|
96
|
-
email:
|
101
|
+
email: digital.robertson@gmail.com
|
97
102
|
executables: []
|
98
103
|
extensions: []
|
99
104
|
extra_rdoc_files: []
|
@@ -111,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
116
|
requirements:
|
112
117
|
- - ">="
|
113
118
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
119
|
+
version: 3.0.2
|
115
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
121
|
requirements:
|
117
122
|
- - ">="
|
@@ -119,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
124
|
version: '0'
|
120
125
|
requirements: []
|
121
126
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.7.10
|
123
128
|
signing_key:
|
124
129
|
specification_version: 4
|
125
130
|
summary: A kind of Rack-Rscript web server which facilitates static files, cookie
|
metadata.gz.sig
CHANGED
Binary file
|