Don't leak private group existence by redirecting from namespace controller to group controller.

This commit is contained in:
Douwe Maan 2015-03-24 15:55:12 +01:00
parent 2953e0d19b
commit 61e8ca8ce0
4 changed files with 16 additions and 7 deletions

View file

@ -31,6 +31,7 @@ v 7.10.0 (unreleased)
- Replace commits calendar with faster contribution calendar that includes issues and merge requests
- Add inifinite scroll to user page activity
- Don't show commit comment button when user is not signed in.
- Don't leak private group existence by redirecting from namespace controller to group controller.
v 7.9.0
- Send EmailsOnPush email when branch or tag is created or deleted.

View file

@ -4,14 +4,22 @@ class NamespacesController < ApplicationController
def show
namespace = Namespace.find_by(path: params[:id])
unless namespace
return render_404
if namespace
if namespace.is_a?(Group)
group = namespace
else
user = namespace.owner
end
end
if namespace.type == "Group"
redirect_to group_path(namespace)
if user
redirect_to user_path(user)
elsif group && can?(current_user, :read_group, group)
redirect_to group_path(group)
elsif current_user.nil?
authenticate_user!
else
redirect_to user_path(namespace.owner)
render_404
end
end
end

View file

@ -52,7 +52,7 @@ module Mentionable
if identifier == "all"
users.push(*project.team.members.flatten)
elsif namespace = Namespace.find_by(path: identifier)
if namespace.type == "Group"
if namespace.is_a?(Group)
users.push(*namespace.users)
else
users << namespace.owner

View file

@ -221,7 +221,7 @@ module Gitlab
link_to("@all", namespace_project_url(project.namespace, project), options)
elsif namespace = Namespace.find_by(path: identifier)
url =
if namespace.type == "Group"
if namespace.is_a?(Group)
group_url(identifier)
else
user_url(identifier)