twproxy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d76c0ff8f096bc96a9a2bb037879a31fd08f958f
4
- data.tar.gz: e56c25cac077859244f4e062af7edcc59df27b4c
3
+ metadata.gz: 5a8cb551420006f80bcc98c12200e84d9f7085cf
4
+ data.tar.gz: bec1947030cd4592e8a1cc0f8c6fb113ca813ddf
5
5
  SHA512:
6
- metadata.gz: fe6b63a884f567df715720db6b1ee556b91ae947e0e22def49b3911c70a2dee0851054a73478e8392a45fc3785ac8e5db466968101bb09afb3f8c48c7276c08e
7
- data.tar.gz: ba4b836a56c8316719a53a456e6bf59c3f468e681337e7289e4aae42fec1254a950def4d3d1b7dbb65ccacf10950ecc35b50778e59336be47ab37607a9f38a4e
6
+ metadata.gz: 98adf42d1334bf25d3e4ed54966e5809da71c9eb1f0aa0177eb7f58f2b49e4ab315a0c7fb64fa0119d11754fb9b331c3179525baecf0987b20bfc40395b8405b
7
+ data.tar.gz: ac8a40a11e351c416adb8c93430cc594faccfe9cca6a81fc04a01bc2db068f143e30edb9af8fdbd5d18b1c17e74b467f28cd10f08aa09227817871f4414c1875
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "sinatra"
4
- gem "haml"
5
- gem "rotp"
3
+ gem 'sinatra', '~> 2.0'
4
+ gem 'haml', '~> 5.0'
5
+ gem 'rotp', '~> 2.1'
6
6
 
data/README.md CHANGED
@@ -26,6 +26,7 @@ Usage: twproxy [options]
26
26
  -b, --bind HOSTNAME Specify hostname to bind to. Defaults to 127.0.0.1.
27
27
  -s, --enable-ssl Ensures cookies are marked as secure.
28
28
  -d, --destination URL Specify the url of the TiddlyWiki server. Defaults to http://localhost:8080.
29
+ -x, --path-prefix PATH_PREFIX Specify the path prefix of the TiddlyWiki server (according to [path-prefix](http://tiddlywiki.com/#Using%20a%20custom%20path%20prefix%20with%20the%20client-server%20edition). Defaults to "/".
29
30
  -g CLEARTEXT, Generates a SHA1 hashed password
30
31
  --generate-password
31
32
  -u, --username USER Sets the username. Defaults to user.
@@ -52,8 +53,12 @@ protecting it with a username of `stevenleeg` and a password of `helloWorld`:
52
53
  $ twproxy -u stevenleeg -P 5395ebfd174b0a5617e6f409dfbb3e064e3fdf0a -d http://localhost:8080/
53
54
  ```
54
55
 
55
- If all goes well you can now navigate to `http://localhost:8888` and see a
56
- prompt for your username and password.
56
+ In this case the `-u stevenleeg` specifies the username, `-P [...]` specifies
57
+ the _hash_ of our desired password, and the `-d http://localhost:8080`
58
+ specifies the URL of the tiddlywiki that we are looking to protect. If all goes
59
+ well you can now navigate to `http://localhost:8888` (`8888` is the default
60
+ port twproxy runs on unless you specify a different one with the `-p` argument)
61
+ and see a prompt for your username and password.
57
62
 
58
63
  That's all there is to it! Twproxy is set up and ready to go for basic usage,
59
64
  however if you're paranoid I'd recommend further securing your wiki with SSL
data/bin/twproxy CHANGED
@@ -20,6 +20,9 @@ OptionParser.new do |opts|
20
20
  opts.on("-d", "--destination URL", "Specify the url of the TiddlyWiki server. Defaults to http://localhost:8080.") do |url|
21
21
  options[:url] = url
22
22
  end
23
+ opts.on("-x", "--path-prefix PATH_PREFIX", "Specify the path prefix of the TiddlyWiki server, if existing. Defaults to /.") do |path_prefix|
24
+ options[:path_prefix] = path_prefix
25
+ end
23
26
  opts.on("-g", "--generate-password CLEARTEXT", "Generates a SHA1 hashed password") do |pass|
24
27
  puts Digest::SHA1.hexdigest(pass)
25
28
  exit
@@ -44,11 +47,11 @@ TWProxy.set :bind, options[:bind] || "127.0.0.1"
44
47
  TWProxy.set :port, options[:port] || 8888
45
48
  TWProxy.set :enable_ssl, options[:enable_ssl] || false
46
49
  TWProxy.set :url, options[:url] || "http://localhost:8080" || ENV['WIKI_URL']
50
+ TWProxy.set :path_prefix, options[:path_prefix] || "/"
47
51
  TWProxy.set :username, options[:username] || ENV['WIKI_USER'] || "user"
48
52
  # Default password is test
49
- TWProxy.set :password,
50
- options[:password] || ENV['WIKI_PASS'] || "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"
53
+ TWProxy.set :password,
54
+ options[:password] || ENV['WIKI_PASS'] || "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"
51
55
  TWProxy.set :auth, options[:auth] || ENV['WIKI_AUTH']
52
56
 
53
- TWProxy.run!
54
-
57
+ TWProxy.run!
data/lib/twproxy/proxy.rb CHANGED
@@ -49,12 +49,12 @@ class TWProxy < Sinatra::Base
49
49
  token = Digest::SHA1.hexdigest(
50
50
  "#{params["user"]}#{hashed_pass}#{settings.auth}"
51
51
  )
52
- response.set_cookie("auth", value: token,
53
- secure: settings.enable_ssl,
52
+ response.set_cookie("auth", value: token,
53
+ secure: settings.enable_ssl,
54
54
  expires: (Date.today >> 1).to_time,
55
55
  httponly: true)
56
56
 
57
- redirect "/"
57
+ redirect "#{settings.path_prefix}"
58
58
  else
59
59
  @error = "Invalid username/password"
60
60
  haml :login
@@ -90,7 +90,7 @@ class TWProxy < Sinatra::Base
90
90
  resp = http.request(req)
91
91
 
92
92
  status resp.code
93
- headers({"Etag" => resp["Etag"]})
93
+ headers({"Etag" => resp["Etag"]}) unless resp["Etag"].nil?
94
94
  resp.body
95
95
  end
96
96
 
data/twproxy.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "twproxy"
3
- s.version = "0.0.1"
4
- s.date = "2016-04-09"
3
+ s.version = "0.0.2"
4
+ s.date = "2020-03-22"
5
5
  s.summary = "TiddlyWiki Proxy"
6
6
  s.description = "An authenticated proxy for TiddlyWiki"
7
7
  s.authors = ["Steve Gattuso"]
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.license = "MIT"
12
12
  s.executables << 'twproxy'
13
13
 
14
- s.add_dependency 'sinatra', '~> 1.4'
15
- s.add_dependency 'haml', '~> 4.0'
14
+ s.add_dependency 'sinatra', '~> 2.0'
15
+ s.add_dependency 'haml', '~> 5.0'
16
16
  s.add_dependency 'rotp', '~> 2.1'
17
17
  end
18
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Gattuso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-09 00:00:00.000000000 Z
11
+ date: 2020-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.4'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.4'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '5.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rotp
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.6.3
90
+ rubygems_version: 2.6.13
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: TiddlyWiki Proxy