Commit a3d12f0eff86e16e08b71754b1f7b8b5532934da
Exists in
theme-brasil-digital-from-staging
and in
4 other branches
Merge branch 'master' into staging_rails4
Showing
8 changed files
with
54 additions
and
22 deletions
Show diff stats
etc/noosfero/varnish-accept-language.vcl
... | ... | @@ -23,7 +23,7 @@ C{ |
23 | 23 | #include <string.h> |
24 | 24 | |
25 | 25 | #define DEFAULT_LANGUAGE "en" |
26 | -#define SUPPORTED_LANGUAGES ":de:eo:es:fr:hy:it:pt:ru:" | |
26 | +#define SUPPORTED_LANGUAGES ":en:cs:de:eo:es:fr:hy:it:pt:ru:" | |
27 | 27 | |
28 | 28 | #define vcl_string char |
29 | 29 | #define LANG_LIST_SIZE 16 |
... | ... | @@ -162,20 +162,21 @@ void select_language(const vcl_string *incoming_header, char *lang) { |
162 | 162 | } |
163 | 163 | |
164 | 164 | /* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language */ |
165 | -void vcl_rewrite_accept_language(const struct sess *sp) { | |
165 | +void vcl_rewrite_accept_language(const struct vrt_ctx *ctx) { | |
166 | 166 | vcl_string *in_hdr; |
167 | 167 | vcl_string lang[LANG_MAXLEN]; |
168 | + const struct gethdr_s hdr = { HDR_REQ, "\020Accept-Language:" }; | |
169 | + const struct gethdr_s hdrUpd = { HDR_REQ, "\032X-Varnish-Accept-Language:"}; | |
168 | 170 | |
169 | 171 | /* Get Accept-Language header from client */ |
170 | - in_hdr = VRT_GetHdr(sp, HDR_REQ, "\020Accept-Language:"); | |
172 | + in_hdr = VRT_GetHdr(ctx, &hdr); | |
171 | 173 | |
172 | 174 | /* Normalize and filter out by list of supported languages */ |
173 | 175 | memset(lang, 0, sizeof(lang)); |
174 | 176 | select_language(in_hdr, lang); |
175 | 177 | |
176 | 178 | /* By default, use a different header name: don't mess with backend logic */ |
177 | - VRT_SetHdr(sp, HDR_REQ, "\032X-Varnish-Accept-Language:", lang, vrt_magic_string_end); | |
178 | - | |
179 | + VRT_SetHdr(ctx, &hdrUpd, lang, vrt_magic_string_end); | |
179 | 180 | return; |
180 | 181 | } |
181 | 182 | |
... | ... | @@ -188,15 +189,14 @@ void vcl_rewrite_accept_language(const struct sess *sp) { |
188 | 189 | |
189 | 190 | sub vcl_recv { |
190 | 191 | C{ |
191 | - vcl_rewrite_accept_language(sp); | |
192 | + vcl_rewrite_accept_language(ctx); | |
192 | 193 | }C |
193 | 194 | } |
194 | 195 | |
195 | -sub vcl_fetch { | |
196 | +sub vcl_backend_response { | |
196 | 197 | if (beresp.http.Vary) { |
197 | 198 | set beresp.http.Vary = beresp.http.Vary + ", X-Varnish-Accept-Language"; |
198 | 199 | } else { |
199 | 200 | set beresp.http.Vary = "X-Varnish-Accept-Language"; |
200 | 201 | } |
201 | 202 | } |
202 | - | ... | ... |
etc/noosfero/varnish-noosfero.vcl
1 | +vcl 4.0; | |
2 | + | |
1 | 3 | sub vcl_recv { |
2 | - if (req.request == "GET" || req.request == "HEAD") { | |
4 | + if (req.method == "GET" || req.method == "HEAD") { | |
3 | 5 | if (req.http.Cookie) { |
4 | 6 | # We only care about the "_noosfero_.*" cookies, used by Noosfero |
5 | 7 | if (req.http.Cookie !~ "_noosfero_.*" ) { |
... | ... | @@ -17,10 +19,10 @@ sub vcl_deliver { |
17 | 19 | } |
18 | 20 | } |
19 | 21 | |
20 | -sub vcl_error { | |
21 | - set obj.http.Content-Type = "text/html; charset=utf-8"; | |
22 | +sub vcl_backend_error { | |
23 | + set beresp.http.Content-Type = "text/html; charset=utf-8"; | |
22 | 24 | |
23 | - synthetic {" | |
25 | + synthetic({" | |
24 | 26 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
25 | 27 | <html xmlns="http://www.w3.org/1999/xhtml"> |
26 | 28 | <head> |
... | ... | @@ -52,7 +54,7 @@ sub vcl_error { |
52 | 54 | <div id='wrap'> |
53 | 55 | <div id='header'> |
54 | 56 | <div id='logo'> </div> |
55 | - <div id='details'><b>"} + obj.status + "</b> - " + obj.response + {"</div> | |
57 | + <div id='details'><b>"} + beresp.status + "</b> - " + beresp.reason + {"</div> | |
56 | 58 | </div> |
57 | 59 | |
58 | 60 | <div id='de' style='display: none' class='message'> |
... | ... | @@ -145,6 +147,6 @@ sub vcl_error { |
145 | 147 | </div> |
146 | 148 | </body> |
147 | 149 | </html> |
148 | - "}; | |
150 | + "}); | |
149 | 151 | return(deliver); |
150 | 152 | } | ... | ... |
plugins/ldap/Gemfile
plugins/ldap/dependencies.rb
... | ... | @@ -1 +0,0 @@ |
1 | -require 'net/ldap' |
plugins/ldap/lib/ldap_authentication.rb
... | ... | @@ -15,7 +15,6 @@ |
15 | 15 | # along with this program; if not, write to the Free Software |
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | |
18 | -require 'iconv' | |
19 | 18 | require 'net/ldap' |
20 | 19 | require 'net/ldap/dn' |
21 | 20 | require 'magic' |
... | ... | @@ -111,7 +110,14 @@ class LdapAuthentication |
111 | 110 | else |
112 | 111 | ldap_con = initialize_ldap_con(self.account, self.account_password) |
113 | 112 | end |
114 | - login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) | |
113 | + login_filter = nil | |
114 | + (self.attr_login || []).split.each do |attr| | |
115 | + if(login_filter.nil?) | |
116 | + login_filter = Net::LDAP::Filter.eq( attr, login ) | |
117 | + else | |
118 | + login_filter = login_filter | Net::LDAP::Filter.eq( attr, login ) | |
119 | + end | |
120 | + end | |
115 | 121 | object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) |
116 | 122 | |
117 | 123 | attrs = {} | ... | ... |
plugins/ldap/lib/ldap_plugin.rb
... | ... | @@ -55,7 +55,7 @@ class LdapPlugin < Noosfero::Plugin |
55 | 55 | end |
56 | 56 | |
57 | 57 | if attrs |
58 | - user.login = login | |
58 | + user.login = get_login(attrs, ldap.attr_login, login) | |
59 | 59 | user.email = get_email(attrs, login) |
60 | 60 | user.name = attrs[:fullname] |
61 | 61 | user.password = password |
... | ... | @@ -94,6 +94,11 @@ class LdapPlugin < Noosfero::Plugin |
94 | 94 | user |
95 | 95 | end |
96 | 96 | |
97 | + def get_login(attrs, attr_login, login) | |
98 | + user_login = Array.wrap(attrs[attr_login.split.first.to_sym]) | |
99 | + user_login.empty? ? login : user_login.first | |
100 | + end | |
101 | + | |
97 | 102 | def get_email(attrs, login) |
98 | 103 | return attrs[:mail] unless attrs[:mail].blank? |
99 | 104 | ... | ... |
plugins/ldap/test/unit/ldap_plugin_test.rb
... | ... | @@ -14,4 +14,24 @@ class LdapPluginTest < ActiveSupport::TestCase |
14 | 14 | refute plugin.allow_password_recovery |
15 | 15 | end |
16 | 16 | |
17 | + should 'return login when exists a login attribute returned by ldap' do | |
18 | + plugin = LdapPlugin.new | |
19 | + assert_equal 'test', plugin.get_login({:uid => 'test'}, 'uid', 'test2') | |
20 | + end | |
21 | + | |
22 | + should 'return the attribute configured by attr_login when the attribute exists' do | |
23 | + plugin = LdapPlugin.new | |
24 | + assert_equal 'test', plugin.get_login({:uid => 'test'}, 'uid', 'test2') | |
25 | + end | |
26 | + | |
27 | + should 'return login when the ldap attribute does not exists' do | |
28 | + plugin = LdapPlugin.new | |
29 | + assert_equal 'test2', plugin.get_login({:uid => 'test'}, 'mail', 'test2') | |
30 | + end | |
31 | + | |
32 | + should 'use the first word at attr_login as the login key' do | |
33 | + plugin = LdapPlugin.new | |
34 | + assert_equal 'test', plugin.get_login({:uid => 'test', :mail => 'test@test'}, 'uid mail', 'test2') | |
35 | + end | |
36 | + | |
17 | 37 | end | ... | ... |
plugins/stoa/script/stoa-auth-server
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
26 | 26 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
27 | 27 | DESC="Stoa authentication deamon" |
28 | -NAME=stoa-auth-daemon | |
28 | +NAME=stoa-auth-server | |
29 | 29 | SCRIPTNAME=/etc/init.d/$NAME |
30 | 30 | |
31 | 31 | # default values |
... | ... | @@ -33,8 +33,8 @@ NOOSFERO_DIR=/var/lib/noosfero/current |
33 | 33 | NOOSFERO_USER=noosfero |
34 | 34 | |
35 | 35 | # Read configuration variable file if it is present |
36 | -if [ -r /etc/default/$NAME ]; then | |
37 | - . /etc/default/$NAME | |
36 | +if [ -r /etc/default/noosfero ]; then | |
37 | + . /etc/default/noosfero | |
38 | 38 | else |
39 | 39 | # for running from development setup, or from git with the script symlinked |
40 | 40 | script=$(readlink -f $0) | ... | ... |