mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 22:46:22 +02:00
Validation of user certificates
This commit is contained in:
parent
e6e0624943
commit
65ae5adbb8
2 changed files with 90 additions and 29 deletions
|
@ -2,9 +2,10 @@ module Repp
|
|||
module V1
|
||||
module Registrar
|
||||
class AuthController < BaseController
|
||||
before_action :validate_webclient_user_cert, only: :index
|
||||
skip_before_action :authenticate_user, only: :tara_callback
|
||||
skip_before_action :check_ip_restriction, only: :tara_callback
|
||||
skip_before_action :validate_client_certs, only: :tara_callback
|
||||
skip_before_action :validate_api_user_cert, only: :tara_callback
|
||||
|
||||
THROTTLED_ACTIONS = %i[index tara_callback].freeze
|
||||
include Shunter::Integration::Throttle
|
||||
|
@ -21,7 +22,10 @@ module Repp
|
|||
def tara_callback
|
||||
user = ApiUser.from_omniauth(auth_params)
|
||||
response = { code: 401, message: I18n.t(:no_such_user), data: {} }
|
||||
render(json: response, status: :unauthorized) and return unless user && user&.active
|
||||
unless user&.active && webclient_request?
|
||||
render(json: response, status: :unauthorized)
|
||||
return
|
||||
end
|
||||
|
||||
token = Base64.urlsafe_encode64("#{user.username}:#{user.plain_text_password}")
|
||||
render_success(data: { token: token, username: user.username })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue