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!
Instance Method Details
#authorize!(action, subject = :global, reason = nil) ⇒ Object
38
39
40
41
42
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 38
def authorize!(action, subject = :global, reason = nil)
return if can?(current_user, action, subject)
unauthorized_or! { forbidden!(reason) }
end
|
#authorized_project_find! ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 28
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
24
25
26
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 24
def authorized_user_project
@authorized_user_project ||= authorized_project_find!
end
|
#unauthorized_or! ⇒ Object
44
45
46
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 44
def unauthorized_or!
current_user ? yield : unauthorized!
end
|
#unauthorized_user_project ⇒ Object
16
17
18
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 16
def unauthorized_user_project
@unauthorized_user_project ||= find_project(params[:id])
end
|
#unauthorized_user_project! ⇒ Object
20
21
22
|
# File 'lib/api/helpers/packages/basic_auth_helpers.rb', line 20
def unauthorized_user_project!
unauthorized_user_project || not_found!
end
|