gollum-auth 0.6.2 → 0.7.0

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: 3f11124c0363460f5a500d9826d59a6aef5113d7
4
- data.tar.gz: 8995f52afaeb8882d9bbc25a7b5dc5ea78b77a67
3
+ metadata.gz: 8ffe32ffcc69a484479b80d7ab04e63c25cfcfa8
4
+ data.tar.gz: 67fcf09d1b7823c3a6c3dda80270bc4ac84f6825
5
5
  SHA512:
6
- metadata.gz: 1b86349eec083d811492ba09c7a622e5b04cd25d4c414acb7447ba25f583606dd40695e716e6e454117250ba2ddf4444555dc9d77e291f48561cf845f70635b9
7
- data.tar.gz: 889a48bd66f3f0a92a1868077128e13a710b7d6b21ec9870ff3d560923c7f7ec60d4999f4fe167a22f1c8a999f905f151246471015ee831b1e69641b7a71443d
6
+ metadata.gz: 8ad20010ba4dc43508b272a11d00d1b61aeacbc63593b7c0f1b3e4171eff522af71e0181374cb384bd2d836256ee19aec8e8bc88b77b9c8a238b9a9e66a39054
7
+ data.tar.gz: c9f4e1cb96772a9090e967338b1b64eb48b5d3df60dd5d99ab096bda803c01799e1623e9c368b3fa250ddcb1310ed8a94e2b4de1aa8ecaba4df50ea7fa20c49e
data/README.md CHANGED
@@ -13,6 +13,7 @@ to gollum so that only authenticated users have access to your wiki.
13
13
  Optionally you can allow readonly-access for unauthenticated guests.
14
14
  Also the current user's name and e-mail are passed to gollum (via session key
15
15
  `gollum.author`) to see who changed what.
16
+ It works with Gollum 4 and Gollum 5.
16
17
 
17
18
 
18
19
  ## Installation
@@ -65,7 +66,7 @@ users = YAML.load %q{
65
66
  }
66
67
 
67
68
  # Allow unauthenticated users to read the wiki (disabled by default).
68
- options = { allow_guests: true }
69
+ options = { allow_unauthenticated_readonly: true }
69
70
 
70
71
  # Allow only authenticated users to change the wiki.
71
72
  # (NOTE: This must be loaded *before* Precious::App!)
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency 'rack', '~> 1.6'
25
+ spec.add_dependency 'rack'
26
26
  spec.add_dependency 'activemodel', '~> 4.2'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.14'
@@ -15,12 +15,12 @@ module Gollum
15
15
  def initialize(app, users, opts = { })
16
16
  @app = app
17
17
  users.each { |args| User.new(args).save! }
18
- @opts = { allow_guests: false }.merge(opts)
18
+ @opts = { allow_unauthenticated_readonly: false }.merge(opts)
19
19
  end
20
20
 
21
21
  def call(env)
22
22
  request = Request.new(env)
23
- if request.needs_authentication?(@opts[:allow_guests])
23
+ if request.requires_authentication?(@opts[:allow_unauthenticated_readonly])
24
24
  auth = Rack::Auth::Basic::Request.new(env)
25
25
  if auth.provided? && auth.basic? && user = User.find_by_credentials(auth.credentials)
26
26
  request.store_author_in_session(user)
@@ -1,7 +1,13 @@
1
1
  module Gollum::Auth
2
2
  class Request < Rack::Request
3
- def needs_authentication?(allow_guests)
4
- !allow_guests || is_change_request?
3
+ WRITE_PATH_RE = %r{
4
+ ^/
5
+ (gollum/)? # This path prefix was introduced in Gollum 5
6
+ (create/|edit/|delete/|rename/|revert/|uploadFile$|upload_file$)
7
+ }x
8
+
9
+ def requires_authentication?(allow_unauthenticated_readonly)
10
+ !allow_unauthenticated_readonly || is_write_path?
5
11
  end
6
12
 
7
13
  def store_author_in_session(user)
@@ -10,10 +16,9 @@ module Gollum::Auth
10
16
 
11
17
  private
12
18
 
13
- # Returns true if the request includes a path that would result in a change
14
- # of the wiki.
15
- def is_change_request?
16
- !!(path_info =~ /^\/(create|edit|delete|rename|revert|uploadFile)(\/.*)?$/)
19
+ # Returns true if path is a write path that would change the wiki.
20
+ def is_write_path?
21
+ !!(path_info =~ WRITE_PATH_RE)
17
22
  end
18
23
  end
19
24
  end
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module Auth
3
- VERSION = '0.6.2'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Björn Albers
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '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.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -168,5 +168,5 @@ rubyforge_project:
168
168
  rubygems_version: 2.6.11
169
169
  signing_key:
170
170
  specification_version: 4
171
- summary: gollum-auth-0.6.2
171
+ summary: gollum-auth-0.7.0
172
172
  test_files: []