gollum-auth 0.6.2 → 0.7.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 +2 -1
- data/gollum-auth.gemspec +1 -1
- data/lib/gollum/auth.rb +2 -2
- data/lib/gollum/auth/request.rb +11 -6
- data/lib/gollum/auth/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ffe32ffcc69a484479b80d7ab04e63c25cfcfa8
|
|
4
|
+
data.tar.gz: 67fcf09d1b7823c3a6c3dda80270bc4ac84f6825
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 = {
|
|
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!)
|
data/gollum-auth.gemspec
CHANGED
|
@@ -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'
|
|
25
|
+
spec.add_dependency 'rack'
|
|
26
26
|
spec.add_dependency 'activemodel', '~> 4.2'
|
|
27
27
|
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
data/lib/gollum/auth.rb
CHANGED
|
@@ -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 = {
|
|
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.
|
|
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)
|
data/lib/gollum/auth/request.rb
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
module Gollum::Auth
|
|
2
2
|
class Request < Rack::Request
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
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
|
data/lib/gollum/auth/version.rb
CHANGED
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.
|
|
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: '
|
|
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: '
|
|
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.
|
|
171
|
+
summary: gollum-auth-0.7.0
|
|
172
172
|
test_files: []
|