2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-04 17:07:49 -05:00
|
|
|
module API
|
|
|
|
# External applications API
|
2020-10-14 20:08:42 -04:00
|
|
|
class Applications < ::API::Base
|
2017-01-04 17:07:49 -05:00
|
|
|
before { authenticated_as_admin! }
|
|
|
|
|
2020-10-28 11:08:49 -04:00
|
|
|
feature_category :authentication_and_authorization
|
|
|
|
|
2017-01-04 17:07:49 -05:00
|
|
|
resource :applications do
|
|
|
|
desc 'Create a new application' do
|
2018-01-23 04:50:10 -05:00
|
|
|
detail 'This feature was introduced in GitLab 10.5'
|
2018-01-24 03:44:07 -05:00
|
|
|
success Entities::ApplicationWithSecret
|
2017-01-04 17:07:49 -05:00
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :name, type: String, desc: 'Application name'
|
|
|
|
requires :redirect_uri, type: String, desc: 'Application redirect URI'
|
|
|
|
requires :scopes, type: String, desc: 'Application scopes'
|
2020-01-22 13:08:47 -05:00
|
|
|
|
|
|
|
optional :confidential, type: Boolean, default: true,
|
|
|
|
desc: 'Application will be used where the client secret is confidential'
|
2017-01-04 17:07:49 -05:00
|
|
|
end
|
|
|
|
post do
|
|
|
|
application = Doorkeeper::Application.new(declared_params)
|
|
|
|
|
|
|
|
if application.save
|
2018-01-24 03:44:07 -05:00
|
|
|
present application, with: Entities::ApplicationWithSecret
|
2017-01-04 17:07:49 -05:00
|
|
|
else
|
|
|
|
render_validation_error! application
|
|
|
|
end
|
|
|
|
end
|
2018-10-11 06:54:15 -04:00
|
|
|
|
|
|
|
desc 'Get applications' do
|
2018-10-12 05:33:58 -04:00
|
|
|
success Entities::Application
|
2018-10-11 06:54:15 -04:00
|
|
|
end
|
|
|
|
get do
|
2018-10-15 10:03:08 -04:00
|
|
|
applications = ApplicationsFinder.new.execute
|
2018-10-11 06:54:15 -04:00
|
|
|
present applications, with: Entities::Application
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Delete an application'
|
|
|
|
delete ':id' do
|
2018-10-15 10:03:08 -04:00
|
|
|
application = ApplicationsFinder.new(params).execute
|
|
|
|
application.destroy
|
2018-10-11 06:54:15 -04:00
|
|
|
|
2020-01-16 13:08:46 -05:00
|
|
|
no_content!
|
2018-10-11 06:54:15 -04:00
|
|
|
end
|
2017-01-04 17:07:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|