├── config ├── routes.rb └── locales │ ├── zh.yml │ ├── ja.yml │ ├── en.yml │ └── de.yml ├── app ├── controllers │ └── env_auth_controller.rb └── views │ └── settings │ └── _redmine_env_auth_settings.html.erb ├── lang ├── zh.yml ├── ja.yml ├── en.yml └── de.yml ├── license ├── init.rb ├── readme.md └── lib └── redmine_env_auth └── env_auth_patch.rb /config/routes.rb: -------------------------------------------------------------------------------- 1 | RedmineApp::Application.routes.draw do 2 | get "env_auth/info", :to => "env_auth#info" 3 | get 'env_auth/logout', :to => "env_auth#logout" 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/env_auth_controller.rb: -------------------------------------------------------------------------------- 1 | class EnvAuthController < ApplicationController 2 | def info 3 | effective = remote_user 4 | variable_name = Setting.plugin_redmine_env_auth["env_variable_name"] 5 | original = request.env[variable_name] 6 | keys = request.env.keys.sort.select {|a| 7 | ["action_dispatch.", "action_controller.", "rack.", "puma."].none? {|b| a.start_with?(b)} 8 | }.join("\n ") 9 | text = [ 10 | "variable name: #{variable_name}", 11 | "original value: #{original.inspect}", 12 | "effective value: #{effective.inspect}" 13 | ].join("\n") 14 | 15 | text = "#{text}\navailable variables:\n #{keys}" 16 | render :plain => text 17 | end 18 | 19 | def logout 20 | if Setting.plugin_redmine_env_auth["external_logout_target"] == "" 21 | redirect_to signout_path 22 | else 23 | redirect_to Setting.plugin_redmine_env_auth["external_logout_target"] 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lang/zh.yml: -------------------------------------------------------------------------------- 1 | zh: 2 | label_allow_other_login_admins: 所有管理员 3 | label_allow_other_login_all: 所有用户 4 | label_allow_other_login: 允许标准登录 5 | label_allow_other_login_none: 已禁用 6 | label_allow_other_login_users: 一些用户(以逗号分隔) 7 | label_default: 默认 8 | label_email_address: 电子邮件地址 9 | label_enabled: 启用 10 | label_env_variable_name: 请求环境变量的名称 11 | label_ldap_checked_auto_registration: 带有LDAP检查的自动注册 12 | label_login_name: 登录名 13 | label_remove_suffix_help: 将从环境变量文本的末尾移除给定的文本 14 | label_remove_suffix: 移除后缀 15 | label_redmine_user_property: Redmine用户属性 16 | label_env_checked_auto_registration: 使用环境变量的自动注册 17 | label_env_variable_firstname: 名字的变量 18 | label_env_variable_lastname: 姓氏的变量 19 | label_env_variable_email: 邮箱的变量 20 | label_env_variable_admins: 管理员登录列表 21 | label_env_variable_admins_description: 以逗号分隔的登录列表,这些登录将被注册为管理员 22 | label_env_variable_new_user_initial_locked: 锁定新注册的账户 23 | label_show_logout_link: 显示登出链接 24 | label_external_logout_target: 登出时重定向的位置 25 | label_external_logout_target_description: 指定一个外部登出服务。如果为空,将使用内部登出路径 -------------------------------------------------------------------------------- /config/locales/zh.yml: -------------------------------------------------------------------------------- 1 | zh: 2 | label_allow_other_login_admins: 所有管理员 3 | label_allow_other_login_all: 所有用户 4 | label_allow_other_login: 允许标准登录 5 | label_allow_other_login_none: 已禁用 6 | label_allow_other_login_users: 一些用户(以逗号分隔) 7 | label_default: 默认 8 | label_email_address: 电子邮件地址 9 | label_enabled: 启用 10 | label_env_variable_name: 请求环境变量的名称 11 | label_ldap_checked_auto_registration: 带有LDAP检查的自动注册 12 | label_login_name: 登录名 13 | label_remove_suffix_help: 将从环境变量文本的末尾移除给定的文本 14 | label_remove_suffix: 移除后缀 15 | label_redmine_user_property: Redmine用户属性 16 | label_env_checked_auto_registration: 使用环境变量的自动注册 17 | label_env_variable_firstname: 名字的变量 18 | label_env_variable_lastname: 姓氏的变量 19 | label_env_variable_email: 邮箱的变量 20 | label_env_variable_admins: 管理员登录列表 21 | label_env_variable_admins_description: 以逗号分隔的登录列表,这些登录将被注册为管理员 22 | label_env_variable_new_user_initial_locked: 锁定新注册的账户 23 | label_show_logout_link: 显示登出链接 24 | label_external_logout_target: 登出时重定向的位置 25 | label_external_logout_target_description: 指定一个外部登出服务。如果为空,将使用内部登出路径 -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Adam Lantos 2 | Copyright (c) 2018 Intera GmbH 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lang/ja.yml: -------------------------------------------------------------------------------- 1 | # Japanese translation by Akiko Takano, tohosaku 2 | ja: 3 | label_allow_other_login_admins: 全てのシステム管理者 4 | label_allow_other_login_all: 全てのユーザー 5 | label_allow_other_login: 通常のログインを許可 6 | label_allow_other_login_none: 許可しない 7 | label_allow_other_login_users: 指定されたユーザーのみ (カンマ区切り) 8 | label_default: デフォルト 9 | label_email_address: メールアドレス 10 | label_enabled: 有効にする 11 | label_env_variable_name: サーバの環境変数名 12 | label_ldap_checked_auto_registration: LDAPの確認に基づく自動登録 13 | label_login_name: ログイン名 14 | label_remove_suffix_help: 入力された文字列は、環境変数の末尾から削除されます。 15 | label_remove_suffix: 削除するサフィックス 16 | label_redmine_user_property: 対応するredmine 側のユーザー情報 17 | label_env_checked_auto_registration: 環境変数による自動登録 18 | label_env_variable_firstname: 名の変数 19 | label_env_variable_lastname: 姓の変数 20 | label_env_variable_email: メールの変数 21 | label_env_variable_admins: 管理者ログインのリスト 22 | label_env_variable_admins_description: 管理者として登録されるログインのカンマ区切りリスト 23 | label_env_variable_new_user_initial_locked: 新規登録アカウントをロック 24 | label_show_logout_link: ログアウトリンクを表示 25 | label_external_logout_target: ログアウト時のリダイレクト先 26 | label_external_logout_target_description: 外部ログアウトサービスを指定します。空の場合、内部のログアウトパスが使用されます。 -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | # Japanese translation by Akiko Takano, tohosaku 2 | ja: 3 | label_allow_other_login_admins: 全てのシステム管理者 4 | label_allow_other_login_all: 全てのユーザー 5 | label_allow_other_login: 通常のログインを許可 6 | label_allow_other_login_none: 許可しない 7 | label_allow_other_login_users: 指定されたユーザーのみ (カンマ区切り) 8 | label_default: デフォルト 9 | label_email_address: メールアドレス 10 | label_enabled: 有効にする 11 | label_env_variable_name: サーバの環境変数名 12 | label_ldap_checked_auto_registration: LDAPの確認に基づく自動登録 13 | label_login_name: ログイン名 14 | label_remove_suffix_help: 入力された文字列は、環境変数の末尾から削除されます。 15 | label_remove_suffix: 削除するサフィックス 16 | label_redmine_user_property: 対応するredmine 側のユーザー情報 17 | label_env_checked_auto_registration: 環境変数による自動登録 18 | label_env_variable_firstname: 名の変数 19 | label_env_variable_lastname: 姓の変数 20 | label_env_variable_email: メールの変数 21 | label_env_variable_admins: 管理者ログインのリスト 22 | label_env_variable_admins_description: 管理者として登録されるログインのカンマ区切りリスト 23 | label_env_variable_new_user_initial_locked: 新規登録アカウントをロック 24 | label_show_logout_link: ログアウトリンクを表示 25 | label_external_logout_target: ログアウト時のリダイレクト先 26 | label_external_logout_target_description: 外部ログアウトサービスを指定します。空の場合、内部のログアウトパスが使用されます。 -------------------------------------------------------------------------------- /lang/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | label_allow_other_login_admins: all admininstrators 3 | label_allow_other_login_all: all users 4 | label_allow_other_login: allow standard login 5 | label_allow_other_login_none: disabled 6 | label_allow_other_login_users: some users (comma separated) 7 | label_default: default 8 | label_email_address: email address 9 | label_enabled: enable 10 | label_env_variable_name: name of request environment variable 11 | label_ldap_checked_auto_registration: automatic registration with ldap check 12 | label_login_name: login name 13 | label_remove_suffix_help: the given text will be removed from the end of the text in the environment variable 14 | label_remove_suffix: remove suffix 15 | label_redmine_user_property: redmine user property 16 | label_env_checked_auto_registration: automatic registration with env variables 17 | label_env_variable_firstname: variable with firstname 18 | label_env_variable_lastname: variable with lastname 19 | label_env_variable_email: variable with email 20 | label_env_variable_admins: list of admin logins 21 | label_env_variable_admins_description: comma separated list of login that will be registered as admins 22 | label_env_variable_new_user_initial_locked: lock newly registered accounts 23 | label_show_logout_link: display logout link 24 | label_external_logout_target: where to redirect on logout 25 | label_external_logout_target_description: specify an external logout service. if empty the internal logout path is used -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | label_allow_other_login_admins: all admininstrators 3 | label_allow_other_login_all: all users 4 | label_allow_other_login: allow standard login 5 | label_allow_other_login_none: disabled 6 | label_allow_other_login_users: some users (comma separated) 7 | label_default: default 8 | label_email_address: email address 9 | label_enabled: enable 10 | label_env_variable_name: name of request environment variable 11 | label_ldap_checked_auto_registration: automatic registration with ldap check 12 | label_login_name: login name 13 | label_remove_suffix_help: the given text will be removed from the end of the text in the environment variable 14 | label_remove_suffix: remove suffix 15 | label_redmine_user_property: redmine user property 16 | label_env_checked_auto_registration: automatic registration with env variables 17 | label_env_variable_firstname: variable with firstname 18 | label_env_variable_lastname: variable with lastname 19 | label_env_variable_email: variable with email 20 | label_env_variable_admins: list of admin logins 21 | label_env_variable_admins_description: comma separated list of login that will be registered as admins 22 | label_env_variable_new_user_initial_locked: lock newly registered accounts 23 | label_show_logout_link: display logout link 24 | label_external_logout_target: where to redirect on logout 25 | label_external_logout_target_description: specify an external logout service. if empty the internal logout path is used -------------------------------------------------------------------------------- /lang/de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | label_allow_other_login_admins: Für Administratoren 3 | label_allow_other_login_all: Für alle Benutzer 4 | label_allow_other_login_none: Deaktiviert 5 | label_allow_other_login: Standardlogin erlauben 6 | label_allow_other_login_users: Für bestimmte Benutzer (Kommagetrennt) 7 | label_default: Vorgabe 8 | label_email_address: E-Mail-Adresse 9 | label_enabled: Plugin verwenden 10 | label_env_variable_name: Name der Umgebungsvariable für die Benutzerdaten 11 | label_ldap_checked_auto_registration: Automatische Registrierung mit LDAP-Abgleich 12 | label_login_name: Loginname 13 | label_remove_suffix_help: Der eingetragene Text wird vom Ende des Texts in der Umgebungsvariable abgeschnitten 14 | label_remove_suffix: Entferne suffix 15 | label_redmine_user_property: Redmine Benutzereigenschaft 16 | label_env_checked_auto_registration: Auto-Registrierung mit Umgebungsvariablen 17 | label_env_variable_firstname: Variable mit Vorname 18 | label_env_variable_lastname: Variable mit Nachname 19 | label_env_variable_email: Variable mit Email-Adresse 20 | label_env_variable_admins: Liste mit Admin-Logins 21 | label_env_variable_admins_description: Kommaseparierte Liste mit Logins, die als Administratoren registriert werden 22 | label_env_variable_new_user_initial_locked: Sperre neu registrierte Konten 23 | label_show_logout_link: Abmelden-Link anzeigen 24 | label_external_logout_target: Ziel für Abmelden-Link 25 | label_external_logout_target_description: hier kann ein externer Abmeldeservice angegeben werden. Wenn leer, Umleitung auf internen logout-Pfad -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | label_allow_other_login_admins: Für Administratoren 3 | label_allow_other_login_all: Für alle Benutzer 4 | label_allow_other_login_none: Deaktiviert 5 | label_allow_other_login: Standardlogin erlauben 6 | label_allow_other_login_users: Für bestimmte Benutzer (Kommagetrennt) 7 | label_default: Vorgabe 8 | label_email_address: E-Mail-Adresse 9 | label_enabled: Plugin verwenden 10 | label_env_variable_name: Name der Umgebungsvariable für die Benutzerdaten 11 | label_ldap_checked_auto_registration: Automatische Registrierung mit LDAP-Abgleich 12 | label_login_name: Loginname 13 | label_remove_suffix_help: Der eingetragene Text wird vom Ende des Texts in der Umgebungsvariable abgeschnitten 14 | label_remove_suffix: Entferne suffix 15 | label_redmine_user_property: Redmine Benutzereigenschaft 16 | label_env_checked_auto_registration: Auto-Registrierung mit Umgebungsvariablen 17 | label_env_variable_firstname: Variable mit Vorname 18 | label_env_variable_lastname: Variable mit Nachname 19 | label_env_variable_email: Variable mit Email-Adresse 20 | label_env_variable_admins: Liste mit Admin-Logins 21 | label_env_variable_admins_description: Kommaseparierte Liste mit Logins, die als Administratoren registriert werden 22 | label_env_variable_new_user_initial_locked: Sperre neu registrierte Konten 23 | label_show_logout_link: Abmelden-Link anzeigen 24 | label_external_logout_target: Ziel für Abmelden-Link 25 | label_external_logout_target_description: hier kann ein externer Abmeldeservice angegeben werden. Wenn leer, Umleitung auf internen logout-Pfad -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | Redmine::Plugin.register :redmine_env_auth do 2 | name "Request Environment Authentication" 3 | author "Intera GmbH" 4 | url "http://github.com/intera/redmine_env_auth" if respond_to?(:url) 5 | description "A plugin for authentication based on variables in the request environment." 6 | version "1.3" 7 | 8 | Redmine::MenuManager.map :account_menu do |menu| 9 | # hide the logout link if an automatic login is active 10 | menu.delete :logout 11 | menu.push :logout, {:controller => 'env_auth', :action => 'logout'}, :caption => :label_logout, :if => Proc.new { 12 | if !User.current.logged? 13 | false 14 | elsif Setting.plugin_redmine_env_auth["enabled"] != "true" 15 | true 16 | elsif Setting.plugin_redmine_env_auth["show_logout_link"] == "true" 17 | true 18 | else 19 | false 20 | end 21 | }, :after => :my_account 22 | end 23 | 24 | settings :partial => "settings/redmine_env_auth_settings", 25 | :default => { 26 | "allow_other_login" => "admins", 27 | "allow_other_login_users" => "", 28 | "enabled" => "false", 29 | "env_variable_name" => "REMOTE_USER", 30 | "ldap_checked_auto_registration" => "false", 31 | "redmine_user_property" => "login", 32 | "remove_suffix" => "", 33 | "env_checked_auto_registration" => "false", 34 | "env_variable_firstname" => "GIVENNAME", 35 | "env_variable_lastname" => "LASTNAME", 36 | "env_variable_email" => "EMAIL", 37 | "env_variable_admins" => "", 38 | "env_variable_new_user_initial_locked" => "false", 39 | "show_logout_link" => "false", 40 | "external_logout_target" => "" 41 | } 42 | end 43 | 44 | if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled? 45 | RedmineEnvAuth::EnvAuthPatch.install 46 | else 47 | Rails.configuration.to_prepare do 48 | RedmineEnvAuth::EnvAuthPatch.install 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /app/views/settings/_redmine_env_auth_settings.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= content_tag(:label, l(:label_enabled))%> 3 | <%= check_box_tag "settings[enabled]", true, @settings["enabled"] == "true" %> 4 |
5 | 6 |
7 | <%= content_tag(:label, l(:label_env_variable_name)) %>
8 | <%= text_field_tag "settings[env_variable_name]", @settings["env_variable_name"] %>
9 | <%= l(:label_default)%>: REMOTE_USER
10 |
13 | <%= content_tag(:label, l(:label_remove_suffix)) %>
14 | <%= text_field_tag "settings[remove_suffix]", @settings["remove_suffix"] %>
15 | <%= l(:label_remove_suffix_help)%>
16 |
19 | <%= content_tag(:label, l(:label_redmine_user_property))%>
20 | <%= radio_button_tag "settings[redmine_user_property]", "login", @settings["redmine_user_property"] == "login" %>
21 | <%= l(:label_login_name)%>
22 | <%= radio_button_tag "settings[redmine_user_property]", "mail", @settings["redmine_user_property"] == "mail" %>
23 | <%= l(:label_email_address)%>
24 |
27 | <%= content_tag(:label, l(:label_allow_other_login))%>
28 | <%= radio_button_tag "settings[allow_other_login]", "admins", @settings["allow_other_login"] == "admins" %>
29 | <%= l(:label_allow_other_login_admins)%>
30 | <%= radio_button_tag "settings[allow_other_login]", "all", @settings["allow_other_login"] == "all" %>
31 | <%= l(:label_allow_other_login_all)%>
32 | <%= radio_button_tag "settings[allow_other_login]", "users", @settings["allow_other_login"] == "users" %>
33 | <%= l(:label_allow_other_login_users)%>
34 | <%= text_field_tag "settings[allow_other_login_users]", @settings["allow_other_login_users"] %>
35 | <%= radio_button_tag "settings[allow_other_login]", "none", @settings["allow_other_login"] == "none" %>
36 | <%= l(:label_allow_other_login_none)%>
37 |
40 | <%= content_tag(:label, l(:label_ldap_checked_auto_registration))%> 41 | <%= check_box_tag "settings[ldap_checked_auto_registration]", true, @settings["ldap_checked_auto_registration"] == "true" %> 42 |
43 | 44 |
45 | <%= content_tag(:label, l(:label_env_checked_auto_registration))%>
46 | <%= check_box_tag "settings[env_checked_auto_registration]", true, @settings["env_checked_auto_registration"] == "true" %>
47 | <%= content_tag(:label, l(:label_env_variable_firstname)) %>
48 | <%= text_field_tag "settings[env_variable_firstname]", @settings["env_variable_firstname"] %>
49 | <%= l(:label_default)%>: GIVENNAME
50 | <%= content_tag(:label, l(:label_env_variable_lastname)) %>
51 | <%= text_field_tag "settings[env_variable_lastname]", @settings["env_variable_lastname"] %>
52 | <%= l(:label_default)%>: LASTNAME
53 | <%= content_tag(:label, l(:label_env_variable_email)) %>
54 | <%= text_field_tag "settings[env_variable_email]", @settings["env_variable_email"] %>
55 | <%= l(:label_default)%>: EMAIL
56 | <%= content_tag(:label, l(:label_env_variable_admins)) %>
57 | <%= text_field_tag "settings[env_variable_admins]", @settings["env_variable_admins"] %>
58 | <%= l(:label_env_variable_admins_description)%>
59 | <%= content_tag(:label, l(:label_env_variable_new_user_initial_locked))%>
60 | <%= check_box_tag "settings[env_variable_new_user_initial_locked]", true, @settings["env_variable_new_user_initial_locked"] == "true" %>
61 | <%= content_tag(:label, l(:label_show_logout_link))%>
62 | <%= check_box_tag "settings[show_logout_link]", true, @settings["show_logout_link"] == "true" %>
63 | <%= content_tag(:label, l(:label_external_logout_target)) %>
64 | <%= text_field_tag "settings[external_logout_target]", @settings["external_logout_target"] %>
65 | <%= l(:label_external_logout_target_description)%>
66 |