gollum-auth 0.2.0 → 0.3.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 +14 -9
- data/lib/gollum/auth.rb +4 -3
- data/lib/gollum/auth/request.rb +15 -0
- data/lib/gollum/auth/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7f60571c4203805ec7b26185234617736a60764
|
|
4
|
+
data.tar.gz: 0467e62c694fc7c8680145302abd5227e9ac52d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5fde9348967c6b9b1d657124795873ca80c077868e10548a755ac073df12056b7e368ba44b90b339c037b67a41d26d9085750647ac641d986c3ef166f0810fc
|
|
7
|
+
data.tar.gz: 744eadd845807e179ac0ff69695a167938f82efd109325f0cfdac2daee6126e6d1ebaa2adf703bcf9fc3a7b3efda3f91729addec94760ceed80985140aedc7cc
|
data/README.md
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
[](https://badge.fury.io/rb/gollum-auth)
|
|
4
4
|
[](https://travis-ci.org/bjoernalbers/gollum-auth)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
[Gollum](https://github.com/gollum/gollum)
|
|
7
|
+
is an excellent Wiki-software.
|
|
8
|
+
But it does not include user authentication (on purpose).
|
|
9
|
+
|
|
10
|
+
`Gollum::Auth` is a Rack-Middleware that add
|
|
7
11
|
[HTTP Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication)
|
|
8
|
-
to
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
edit / delete / rename / revert pages).
|
|
12
|
-
Read-only access is permitted by default.
|
|
12
|
+
to gollum.
|
|
13
|
+
With this only authenticated users have access to your wiki.
|
|
14
|
+
Optionally you can allow readonly-access for unauthenticated guests.
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
@@ -43,7 +45,7 @@ require 'gollum/auth' # Don't forget to load the gem!
|
|
|
43
45
|
require 'gollum/app'
|
|
44
46
|
|
|
45
47
|
# Define list of authorized users where each must have a "name", "password"
|
|
46
|
-
and "email":
|
|
48
|
+
# and "email":
|
|
47
49
|
users = YAML.load %q{
|
|
48
50
|
---
|
|
49
51
|
- name: Rick Sanchez
|
|
@@ -54,9 +56,12 @@ users = YAML.load %q{
|
|
|
54
56
|
email: morty@example.com
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
# Allow
|
|
59
|
+
# Allow unauthenticated users to read the wiki (disabled by default).
|
|
60
|
+
options = { allow_guests: true }
|
|
61
|
+
|
|
62
|
+
# Allow only authenticated users to change the wiki.
|
|
58
63
|
# (NOTE: This must be loaded *before* Precious::App!)
|
|
59
|
-
use Gollum::Auth, users
|
|
64
|
+
use Gollum::Auth, users, options
|
|
60
65
|
|
|
61
66
|
# That's it. The rest is for gollum only.
|
|
62
67
|
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
|
data/lib/gollum/auth.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'rack'
|
|
2
2
|
require 'active_model'
|
|
3
3
|
require 'gollum/auth/version'
|
|
4
|
+
require 'gollum/auth/request'
|
|
4
5
|
require 'gollum/auth/user'
|
|
5
6
|
|
|
6
7
|
module Gollum
|
|
@@ -10,14 +11,14 @@ module Gollum
|
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
class App
|
|
13
|
-
def initialize(app, users)
|
|
14
|
+
def initialize(app, users, opts = { })
|
|
14
15
|
@app = app
|
|
15
16
|
users.each { |args| User.new(args).save! }
|
|
17
|
+
@opts = { allow_guests: false }.merge(opts)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def call(env)
|
|
19
|
-
|
|
20
|
-
if request.path_info =~ /^\/(create|edit|delete|rename|revert|upload)(\/.*)?$/
|
|
21
|
+
if Request.new(env).needs_authentication?(@opts[:allow_guests])
|
|
21
22
|
auth = Rack::Auth::Basic::Request.new(env)
|
|
22
23
|
unless auth.provided? && auth.basic? && valid?(auth.credentials)
|
|
23
24
|
return [
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Gollum::Auth
|
|
2
|
+
class Request < Rack::Request
|
|
3
|
+
def needs_authentication?(allow_guests)
|
|
4
|
+
!allow_guests || is_change_request?
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
# Returns true if the request includes a path that would result in a change
|
|
10
|
+
# of the wiki.
|
|
11
|
+
def is_change_request?
|
|
12
|
+
!!(path_info =~ /^\/(create|edit|delete|rename|revert|upload)(\/.*)?$/)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
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.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Björn Albers
|
|
@@ -142,6 +142,7 @@ files:
|
|
|
142
142
|
- bin/setup
|
|
143
143
|
- gollum-auth.gemspec
|
|
144
144
|
- lib/gollum/auth.rb
|
|
145
|
+
- lib/gollum/auth/request.rb
|
|
145
146
|
- lib/gollum/auth/user.rb
|
|
146
147
|
- lib/gollum/auth/version.rb
|
|
147
148
|
homepage: https://github.com/bjoernalbers/gollum-auth
|
|
@@ -167,5 +168,5 @@ rubyforge_project:
|
|
|
167
168
|
rubygems_version: 2.6.10
|
|
168
169
|
signing_key:
|
|
169
170
|
specification_version: 4
|
|
170
|
-
summary: gollum-auth-0.
|
|
171
|
+
summary: gollum-auth-0.3.0
|
|
171
172
|
test_files: []
|