gollum-auth 0.3.1 → 0.4.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: 79549a6f6d86794c1194402a9ab10ebbc85df10c
4
- data.tar.gz: 3dd9a0dbf564ba2c7fa2199ddb25b6d359c47484
3
+ metadata.gz: 5867d2b55705e2b346060eaf138626e937d4862e
4
+ data.tar.gz: af8d05dd55933ecf3bc4a87214d41fce69c6e3d7
5
5
  SHA512:
6
- metadata.gz: df29fc60ebe46701523224574238ed6e60cafe1d496fa6a8d9351353922dc2a4486fdce2ba5637c73117fbbaab6bad4acbacaef17c10bc67b0e22e4753a70d7e
7
- data.tar.gz: f69251cf1123e04d47727516da68d9135c4d4aacdc507e400f4014ae504c29d27612c44803ea61312c2cc0250680a473807bf84b059d5f8a052408fd6bc25019
6
+ metadata.gz: e17eb31adfcc920b856c6bd9f79d02b297954eac6cbf70075dcf5ef91a7dca9d5eb1f15844bdd654351fd2ffd9fd68b5c95900b0848da628cc42142ddcdd345f
7
+ data.tar.gz: a43bdaf6d61526b431fbfb3da7b27a69fae027ba81ece03298a3006e1f3be1b4d400f2bd5b14edbba617c5417fee6de703ca903d39286bd2ae8ee87fd1bb14b5
data/README.md CHANGED
@@ -11,6 +11,8 @@ But it does not include user authentication (on purpose).
11
11
  [HTTP Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication)
12
12
  to gollum so that only authenticated users have access to your wiki.
13
13
  Optionally you can allow readonly-access for unauthenticated guests.
14
+ Also the current user's name and e-mail are passed to gollum (via session key
15
+ `gollum.author`) to see who changed what.
14
16
 
15
17
 
16
18
  ## Installation
data/lib/gollum/auth.rb CHANGED
@@ -18,9 +18,13 @@ module Gollum
18
18
  end
19
19
 
20
20
  def call(env)
21
- if Request.new(env).needs_authentication?(@opts[:allow_guests])
21
+ request = Request.new(env)
22
+ if request.needs_authentication?(@opts[:allow_guests])
22
23
  auth = Rack::Auth::Basic::Request.new(env)
23
- unless auth.provided? && auth.basic? && valid?(auth.credentials)
24
+ if auth.provided? && auth.basic? && valid?(auth.credentials)
25
+ user = User.find(auth.credentials.first)
26
+ request.store_author_in_session(user)
27
+ else
24
28
  return [
25
29
  401,
26
30
  { 'Content-Type' => 'text/plain', 'WWW-Authenticate' => 'Basic realm="Gollum Wiki"' },
@@ -4,6 +4,10 @@ module Gollum::Auth
4
4
  !allow_guests || is_change_request?
5
5
  end
6
6
 
7
+ def store_author_in_session(user)
8
+ session['gollum.author'] = { name: user.name, email: user.email }
9
+ end
10
+
7
11
  private
8
12
 
9
13
  # Returns true if the request includes a path that would result in a change
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module Auth
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Björn Albers
@@ -168,5 +168,5 @@ rubyforge_project:
168
168
  rubygems_version: 2.6.10
169
169
  signing_key:
170
170
  specification_version: 4
171
- summary: gollum-auth-0.3.1
171
+ summary: gollum-auth-0.4.0
172
172
  test_files: []