Module: API::Helpers::Packages::BasicAuthHelpers
Defined Under Namespace
Modules: Constants
Constant Summary
Constants included
from Constants
Constants::AUTHENTICATE_REALM_HEADER, Constants::AUTHENTICATE_REALM_NAME
Instance Method Summary
collapse
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
#clear_memoization, #strong_memoize, #strong_memoized?
Instance Method Details
#authorize!(action, subject = :global, reason = nil) ⇒ Object
59
60
61
62
63
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 59
def authorize!(action, subject = :global, reason = nil)
return if can?(current_user, action, subject)
unauthorized_or! { forbidden!(reason) }
end
|
#authorized_project_find! ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 37
def authorized_project_find!
project = unauthorized_user_project
unless project && can?(current_user, :read_project, project)
return unauthorized_or! { not_found! }
end
project
end
|
#authorized_user_project ⇒ Object
33
34
35
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 33
def authorized_user_project
@authorized_user_project ||= authorized_project_find!
end
|
#find_authorized_group! ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 47
def find_authorized_group!
strong_memoize(:authorized_group) do
group = find_group(params[:id])
unless group && can?(current_user, :read_group, group)
next unauthorized_or! { not_found! }
end
group
end
end
|
#unauthorized_or! ⇒ Object
65
66
67
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 65
def unauthorized_or!
current_user ? yield : unauthorized!
end
|
#unauthorized_user_group ⇒ Object
25
26
27
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 25
def unauthorized_user_group
@unauthorized_user_group ||= find_group(params[:id])
end
|
#unauthorized_user_group! ⇒ Object
29
30
31
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 29
def unauthorized_user_group!
unauthorized_user_group || not_found!
end
|
#unauthorized_user_project ⇒ Object
17
18
19
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 17
def unauthorized_user_project
@unauthorized_user_project ||= find_project(params[:id])
end
|
#unauthorized_user_project! ⇒ Object
21
22
23
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 21
def unauthorized_user_project!
unauthorized_user_project || not_found!
end
|