redmine-http_basic_authentication 0.0.1
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 +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/app/views/http_basic_authentication/_settings.html.erb +5 -0
- data/app/views/http_basic_authentication/logout.html.erb +7 -0
- data/config/locales/en.yml +5 -0
- data/lib/http_basic_authentication/engine.rb +10 -0
- data/lib/http_basic_authentication/infos.rb +14 -0
- data/lib/http_basic_authentication/patches.rb +19 -0
- data/lib/http_basic_authentication/patches/account_controller_patch.rb +55 -0
- data/lib/http_basic_authentication/patches/application_controller_patch.rb +46 -0
- data/lib/http_basic_authentication/redmine_plugin.rb +33 -0
- data/lib/http_basic_authentication/version.rb +3 -0
- data/lib/redmine-http_basic_authentication.rb +8 -0
- data/redmine-http_basic_authentication.gemspec +27 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 738727b792aebdcd321157a17af5444c1d8153fe
|
4
|
+
data.tar.gz: c2410be7c12b433d36ed424c2c5bd4866fa88e11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 722c264a48923851d77ab50ec42a3c9a2f1f81983a87aea2f1f13238f3e9b38c8617d19683094f5ce581139ff8febf3fcdb38420d7b6ea3285a064f14f13c4f2
|
7
|
+
data.tar.gz: c10593257a1619e169324c708cea3c814076b29102617d33188420b1b692d82b423fca609ca687c9f5d5b62a5faddfed762c8f4e7f1de32a7da0e598349dc083
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jonas Thiel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# redmine-http_basic_authentication
|
2
|
+
|
3
|
+
Use HTTP Basic Authentication for login and IMPLICIT registration for your Redmine application
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Ensure you have a `Gemfile.local` file in your Redmine installation. Add to your `Gemfile.local`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "redmine-http_basic_authentication"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Restart the Redmine application
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
No further steps needed
|
24
|
+
|
25
|
+
## Testing
|
26
|
+
|
27
|
+
No automatic tests, sir! But this Redmine plugin is used in production.
|
28
|
+
|
29
|
+
## TODO
|
30
|
+
|
31
|
+
* Find a way to test this Redmine plugin
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/redmine-http_basic_authentication/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
en:
|
2
|
+
http_basic_authentication_email_suffix: "Email domain suffix"
|
3
|
+
http_basic_authentication_email_suffix_hint: "e.g. @neopoly.de"
|
4
|
+
http_basic_authentication_logout_title: "Logout"
|
5
|
+
http_basic_authentication_logout_message: "To end your session just close your browser!"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module HttpBasicAuthentication
|
2
|
+
# Module to share global gem / plugin information between
|
3
|
+
# the gem's specification and the Redmine plugin specification
|
4
|
+
module Infos
|
5
|
+
NAME = "redmine-http_basic_authentication"
|
6
|
+
DESCRIPTION = "Use HTTP Basic Authentication for login and" \
|
7
|
+
" IMPLICIT registration!"
|
8
|
+
LICENSE = "MIT"
|
9
|
+
URL = "https://github.com/neopoly/redmine-http_basic_authentication"
|
10
|
+
AUTHORS = {
|
11
|
+
"Jonas Thiel" => "jt@neopoly.de"
|
12
|
+
}.freeze
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "http_basic_authentication/patches/application_controller_patch"
|
2
|
+
require "http_basic_authentication/patches/account_controller_patch"
|
3
|
+
|
4
|
+
module HttpBasicAuthentication
|
5
|
+
# This module holds all patches of a default Redmine application
|
6
|
+
module Patches
|
7
|
+
# Apply all patches
|
8
|
+
def self.apply!
|
9
|
+
apply_to(::ApplicationController, ApplicationControllerPatch)
|
10
|
+
apply_to(::AccountController, AccountControllerPatch)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.apply_to(target, mod)
|
16
|
+
target.send(:include, mod)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module HttpBasicAuthentication
|
2
|
+
module Patches
|
3
|
+
# This module overwrites the default behavior of the AccountController
|
4
|
+
# by disabling most of its methods as they make no sense in combination
|
5
|
+
# with the implicit user generation used by this plugin
|
6
|
+
module AccountControllerPatch
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
alias_method_chain :login, :http_basic
|
11
|
+
alias_method_chain :logout, :http_basic
|
12
|
+
alias_method_chain :lost_password, :http_basic
|
13
|
+
alias_method_chain :register, :http_basic
|
14
|
+
alias_method_chain :activate, :http_basic
|
15
|
+
alias_method_chain :activation_email, :http_basic
|
16
|
+
end
|
17
|
+
|
18
|
+
def login_with_http_basic
|
19
|
+
not_available!
|
20
|
+
end
|
21
|
+
|
22
|
+
# If the user was fully logged in only present a simple text
|
23
|
+
# stating to logout by closing the browser
|
24
|
+
def logout_with_http_basic
|
25
|
+
if User.current.anonymous?
|
26
|
+
redirect_to home_url
|
27
|
+
elsif request.post?
|
28
|
+
render "http_basic_authentication/logout"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def lost_password_with_http_basic
|
33
|
+
not_available!
|
34
|
+
end
|
35
|
+
|
36
|
+
def register_with_http_basic
|
37
|
+
not_available!
|
38
|
+
end
|
39
|
+
|
40
|
+
def activate_with_http_basic
|
41
|
+
not_available!
|
42
|
+
end
|
43
|
+
|
44
|
+
def activation_email_with_http_basic
|
45
|
+
not_available!
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def not_available!
|
51
|
+
render text: "Method Not Allowed", status: 405
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module HttpBasicAuthentication
|
2
|
+
module Patches
|
3
|
+
# This module patches the default authentication system
|
4
|
+
# by using HTTP Basic Authorization headers fields to login
|
5
|
+
# users or create them if necessary.
|
6
|
+
module ApplicationControllerPatch
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
alias_method_chain :try_to_autologin, :http_basic
|
11
|
+
end
|
12
|
+
|
13
|
+
# We hijack the autologin method as this the HTTP Basic authorization
|
14
|
+
# is a kind of auto login system which created users on the fly.
|
15
|
+
def try_to_autologin_with_http_basic
|
16
|
+
if http_authorization?
|
17
|
+
authenticate_with_http_basic do |username, _password|
|
18
|
+
logger.info "Successful authentication for '#{username}'" \
|
19
|
+
"from #{request.remote_ip} at #{Time.now.utc}"
|
20
|
+
self.logged_user = User.find_by_login(username) ||
|
21
|
+
create_http_authorization_user(username)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
try_to_autologin_without_http_basic
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def http_authorization?
|
31
|
+
request.authorization.present?
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_http_authorization_user(username)
|
35
|
+
email = "#{username}#{email_suffix}"
|
36
|
+
user = User.new(mail: email, firstname: username, lastname: username)
|
37
|
+
user.login = username
|
38
|
+
user.save!
|
39
|
+
end
|
40
|
+
|
41
|
+
def email_suffix
|
42
|
+
Setting.plugin_http_basic_authorization["email_suffix"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "http_basic_authentication/patches"
|
2
|
+
|
3
|
+
module HttpBasicAuthentication
|
4
|
+
# Registers this gems a Redmine plugin and applies the needed patches
|
5
|
+
class RedminePlugin
|
6
|
+
include HttpBasicAuthentication::Infos
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
register!
|
10
|
+
boot!
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def register!
|
16
|
+
Redmine::Plugin.register :http_basic_authentication do
|
17
|
+
name NAME
|
18
|
+
author AUTHORS.keys.join(", ")
|
19
|
+
description DESCRIPTION
|
20
|
+
version VERSION
|
21
|
+
url URL
|
22
|
+
author_url URL
|
23
|
+
|
24
|
+
settings default: { "email_suffix" => "@neopoly.de" },
|
25
|
+
partial: "http_basic_authentication/settings"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def boot!
|
30
|
+
Patches.apply!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "http_basic_authentication/version"
|
5
|
+
require "http_basic_authentication/infos"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "redmine-http_basic_authentication"
|
9
|
+
spec.version = HttpBasicAuthentication::VERSION
|
10
|
+
spec.authors = HttpBasicAuthentication::Infos::AUTHORS.keys
|
11
|
+
spec.email = HttpBasicAuthentication::Infos::AUTHORS.values
|
12
|
+
spec.summary = HttpBasicAuthentication::Infos::DESCRIPTION
|
13
|
+
spec.description = HttpBasicAuthentication::Infos::DESCRIPTION
|
14
|
+
spec.homepage = HttpBasicAuthentication::Infos::URL
|
15
|
+
spec.license = HttpBasicAuthentication::Infos::LICENSE
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "rails", "~> 4.2.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rubocop"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redmine-http_basic_authentication
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonas Thiel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Use HTTP Basic Authentication for login and IMPLICIT registration!
|
70
|
+
email:
|
71
|
+
- jt@neopoly.de
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- app/views/http_basic_authentication/_settings.html.erb
|
83
|
+
- app/views/http_basic_authentication/logout.html.erb
|
84
|
+
- config/locales/en.yml
|
85
|
+
- lib/http_basic_authentication/engine.rb
|
86
|
+
- lib/http_basic_authentication/infos.rb
|
87
|
+
- lib/http_basic_authentication/patches.rb
|
88
|
+
- lib/http_basic_authentication/patches/account_controller_patch.rb
|
89
|
+
- lib/http_basic_authentication/patches/application_controller_patch.rb
|
90
|
+
- lib/http_basic_authentication/redmine_plugin.rb
|
91
|
+
- lib/http_basic_authentication/version.rb
|
92
|
+
- lib/redmine-http_basic_authentication.rb
|
93
|
+
- redmine-http_basic_authentication.gemspec
|
94
|
+
homepage: https://github.com/neopoly/redmine-http_basic_authentication
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.6
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Use HTTP Basic Authentication for login and IMPLICIT registration!
|
118
|
+
test_files: []
|
119
|
+
has_rdoc:
|