-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
* normalize namespaces in Admin API * remove Knock auth
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AccountingProfilesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AreaPrefixesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AreasController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AuthController < Knock::AuthTokenController | ||
class Api::Rest::Admin::AuthController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
include Memoizable | ||
include WithPayloads | ||
|
||
rescue_from Authentication::AdminAuth::AuthenticationError, with: :handle_authentication_error | ||
rescue_from Authentication::AdminAuth::IpAddressNotAllowedError, with: :handle_ip_not_allowed | ||
|
||
define_memoizable :debug_mode, apply: -> { System::ApiLogConfig.exists?(controller: self.class.name) } | ||
|
||
before_action :authenticate | ||
|
||
def create | ||
render json: { jwt: @auth_token }, status: 201 | ||
end | ||
|
||
def meta | ||
nil | ||
end | ||
|
||
private | ||
|
||
def entity_name | ||
'AdminUser' | ||
def authenticate | ||
result = Authentication::AdminAuth.authenticate!( | ||
auth_params[:username], | ||
auth_params[:password], | ||
remote_ip: request.remote_ip | ||
) | ||
@auth_token = result.token | ||
end | ||
|
||
def auth_params | ||
params.require(:auth).permit :username, :password | ||
params.require(:auth).permit(:username, :password) | ||
end | ||
|
||
def not_found | ||
def handle_authentication_error | ||
error = JSONAPI::Exceptions::AuthenticationFailed.new | ||
render status: 401, json: { errors: error.errors.map(&:to_hash) } | ||
end | ||
|
||
def ip_not_allowed | ||
def handle_ip_not_allowed | ||
error = JSONAPI::Exceptions::AuthenticationFailed.new( | ||
detail: 'Your IP address is not allowed.' | ||
) | ||
render status: 401, json: { errors: error.errors.map(&:to_hash) } | ||
end | ||
|
||
def authenticate | ||
super | ||
|
||
ip_not_allowed unless entity.ip_allowed?(request.remote_ip) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AuthLogsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::AuthProfilesController < Api::Rest::Admin::BaseController | ||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::CountriesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::DestinationNextRatesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::DestinationsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::DtmfReceiveModesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::DtmfSendModesController < Api::Rest::Admin::BaseController | ||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::GatewayDiversionSendModesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::Equipment::Radius::AuthProfilesController < Api::Rest::Admin::BaseController | ||
class Api::Rest::Admin::GatewayInbandDtmfFilteringModesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::Billing::InvoiceServiceDataController < Api::Rest::Admin::BaseController | ||
class Api::Rest::Admin::GatewayMediaEncryptionModesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::GatewayNetworkProtocolPrioritiesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::GatewayRel100ModesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::Equipment::GatewayRel100ModesController < Api::Rest::Admin::BaseController | ||
class Api::Rest::Admin::InvoiceOriginatedDestinationsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::InvoiceOriginatedNetworksController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::InvoiceServiceDataController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::InvoiceTemplateController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::Equipment::TransportProtocolsController < Api::Rest::Admin::BaseController | ||
class Api::Rest::Admin::InvoiceTerminatedDestinationsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::InvoiceTerminatedNetworksController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::NetworkTypesController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::NetworksController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::NumberlistItemsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::NumberlistsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::RateGroupsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::RateplansController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::RegistrationsController < Api::Rest::Admin::BaseController | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::Rest::Admin::RoutesetDiscriminatorsController < Api::Rest::Admin::BaseController | ||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.