mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Rename users.password
to users.plain_text_password
Otherwise it conflicts with Devise
This commit is contained in:
parent
22e70e7707
commit
32ecf36057
19 changed files with 32 additions and 24 deletions
|
@ -4,7 +4,7 @@ module Repp
|
||||||
prefix :repp
|
prefix :repp
|
||||||
|
|
||||||
http_basic do |username, password|
|
http_basic do |username, password|
|
||||||
@current_user ||= ApiUser.find_by(username: username, password: password)
|
@current_user ||= ApiUser.find_by(username: username, plain_text_password: password)
|
||||||
if @current_user
|
if @current_user
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
params[:api_user].delete(:password) if params[:api_user][:password].blank?
|
params[:api_user].delete(:plain_text_password) if params[:api_user][:plain_text_password].blank?
|
||||||
if @api_user.update(api_user_params)
|
if @api_user.update(api_user_params)
|
||||||
flash[:notice] = I18n.t('record_updated')
|
flash[:notice] = I18n.t('record_updated')
|
||||||
redirect_to [:admin, @api_user]
|
redirect_to [:admin, @api_user]
|
||||||
|
@ -59,7 +59,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_user_params
|
def api_user_params
|
||||||
params.require(:api_user).permit(:username, :password, :active,
|
params.require(:api_user).permit(:username, :plain_text_password, :active,
|
||||||
:registrar_id, :registrar_typeahead,
|
:registrar_id, :registrar_typeahead,
|
||||||
:identity_code, { roles: [] })
|
:identity_code, { roles: [] })
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Epp::SessionsController < EppController
|
||||||
|
|
||||||
if success
|
if success
|
||||||
if params[:parsed_frame].css('newPW').first
|
if params[:parsed_frame].css('newPW').first
|
||||||
unless @api_user.update(password: params[:parsed_frame].css('newPW').first.text)
|
unless @api_user.update(plain_text_password: params[:parsed_frame].css('newPW').first.text)
|
||||||
response.headers['X-EPP-Returncode'] = '2500'
|
response.headers['X-EPP-Returncode'] = '2500'
|
||||||
handle_errors(@api_user) and return
|
handle_errors(@api_user) and return
|
||||||
end
|
end
|
||||||
|
@ -128,7 +128,7 @@ class Epp::SessionsController < EppController
|
||||||
def login_params
|
def login_params
|
||||||
user = params[:parsed_frame].css('clID').first.text
|
user = params[:parsed_frame].css('clID').first.text
|
||||||
pw = params[:parsed_frame].css('pw').first.text
|
pw = params[:parsed_frame].css('pw').first.text
|
||||||
{ username: user, password: pw }
|
{ username: user, plain_text_password: pw }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Registrar
|
||||||
return nil unless current_registrar_user
|
return nil unless current_registrar_user
|
||||||
@depp_current_user ||= Depp::User.new(
|
@depp_current_user ||= Depp::User.new(
|
||||||
tag: current_registrar_user.username,
|
tag: current_registrar_user.username,
|
||||||
password: current_registrar_user.password
|
password: current_registrar_user.plain_text_password
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Registrar
|
||||||
uri = URI.parse("#{ENV['repp_url']}domain_transfers")
|
uri = URI.parse("#{ENV['repp_url']}domain_transfers")
|
||||||
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
||||||
request.body = { data: { domainTransfers: domain_transfers } }.to_json
|
request.body = { data: { domainTransfers: domain_transfers } }.to_json
|
||||||
request.basic_auth(current_registrar_user.username, current_registrar_user.password)
|
request.basic_auth(current_registrar_user.username, current_registrar_user.plain_text_password)
|
||||||
|
|
||||||
|
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Registrar
|
||||||
attributes: { hostname: params[:new_hostname],
|
attributes: { hostname: params[:new_hostname],
|
||||||
ipv4: ipv4,
|
ipv4: ipv4,
|
||||||
ipv6: ipv6 } } }.to_json
|
ipv6: ipv6 } } }.to_json
|
||||||
request.basic_auth(current_registrar_user.username, current_registrar_user.password)
|
request.basic_auth(current_registrar_user.username, current_registrar_user.plain_text_password)
|
||||||
|
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
response = Net::HTTP.start(uri.hostname, uri.port,
|
response = Net::HTTP.start(uri.hostname, uri.port,
|
||||||
|
|
|
@ -26,7 +26,8 @@ class Registrar
|
||||||
@depp_user.errors.add(:base, :webserver_client_cert_directive_should_be_required)
|
@depp_user.errors.add(:base, :webserver_client_cert_directive_should_be_required)
|
||||||
end
|
end
|
||||||
|
|
||||||
@api_user = ApiUser.find_by(username: params[:depp_user][:tag], password: params[:depp_user][:password])
|
@api_user = ApiUser.find_by(username: params[:depp_user][:tag],
|
||||||
|
plain_text_password: params[:depp_user][:password])
|
||||||
|
|
||||||
unless @api_user
|
unless @api_user
|
||||||
@depp_user.errors.add(:base, t(:no_such_user))
|
@depp_user.errors.add(:base, t(:no_such_user))
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Registrar
|
||||||
request = Net::HTTP::Patch.new(uri)
|
request = Net::HTTP::Patch.new(uri)
|
||||||
request.set_form_data(current_contact_id: params[:current_contact_id],
|
request.set_form_data(current_contact_id: params[:current_contact_id],
|
||||||
new_contact_id: params[:new_contact_id])
|
new_contact_id: params[:new_contact_id])
|
||||||
request.basic_auth(current_registrar_user.username, current_registrar_user.password)
|
request.basic_auth(current_registrar_user.username, current_registrar_user.plain_text_password)
|
||||||
|
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
response = Net::HTTP.start(uri.hostname, uri.port,
|
response = Net::HTTP.start(uri.hostname, uri.port,
|
||||||
|
|
|
@ -7,7 +7,7 @@ class ApiUser < User
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2306' => [ # Parameter policy error
|
'2306' => [ # Parameter policy error
|
||||||
[:password, :blank]
|
[:plain_text_password, :blank]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -20,8 +20,8 @@ class ApiUser < User
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
has_many :certificates
|
has_many :certificates
|
||||||
|
|
||||||
validates :username, :password, :registrar, :roles, presence: true
|
validates :username, :plain_text_password, :registrar, :roles, presence: true
|
||||||
validates :password, length: { minimum: min_password_length }
|
validates :plain_text_password, length: { minimum: min_password_length }
|
||||||
validates :username, uniqueness: true
|
validates :username, uniqueness: true
|
||||||
|
|
||||||
delegate :code, :name, to: :registrar, prefix: true
|
delegate :code, :name, to: :registrar, prefix: true
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
.col-md-4.control-label
|
.col-md-4.control-label
|
||||||
= f.label :password, nil, class: 'required'
|
= f.label :password, nil, class: 'required'
|
||||||
.col-md-7
|
.col-md-7
|
||||||
= f.text_field :password, required: true, class: 'form-control'
|
= f.text_field :plain_text_password, required: true, class: 'form-control'
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-4.control-label
|
.col-md-4.control-label
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
%dd= @api_user.username
|
%dd= @api_user.username
|
||||||
|
|
||||||
%dt= t(:password)
|
%dt= t(:password)
|
||||||
%dd= @api_user.password
|
%dd= @api_user.plain_text_password
|
||||||
|
|
||||||
%dt= t(:registrar_name)
|
%dt= t(:registrar_name)
|
||||||
%dd= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar))
|
%dd= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar))
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameUsersPasswordToPlainTextPassword < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :users, :password, :plain_text_password
|
||||||
|
end
|
||||||
|
end
|
|
@ -2282,7 +2282,7 @@ ALTER SEQUENCE public.settings_id_seq OWNED BY public.settings.id;
|
||||||
CREATE TABLE public.users (
|
CREATE TABLE public.users (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
username character varying,
|
username character varying,
|
||||||
password character varying,
|
plain_text_password character varying,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
email character varying,
|
email character varying,
|
||||||
|
@ -4757,3 +4757,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180613030330');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20180613045614');
|
INSERT INTO schema_migrations (version) VALUES ('20180613045614');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20180713154915');
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace :import do
|
||||||
if y.try(:cert) == 'idkaart'
|
if y.try(:cert) == 'idkaart'
|
||||||
id_users << ApiUser.new({
|
id_users << ApiUser.new({
|
||||||
username: y.try(:password) ? y.try(:password) : y.try(:password),
|
username: y.try(:password) ? y.try(:password) : y.try(:password),
|
||||||
password: ('a'..'z').to_a.shuffle.first(8).join,
|
plain_text_password: ('a'..'z').to_a.shuffle.first(8).join,
|
||||||
identity_code: y.try(:password) ? y.try(:password) : y.try(:password),
|
identity_code: y.try(:password) ? y.try(:password) : y.try(:password),
|
||||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||||
roles: ['billing'],
|
roles: ['billing'],
|
||||||
|
@ -154,7 +154,7 @@ namespace :import do
|
||||||
else
|
else
|
||||||
temp << ApiUser.new({
|
temp << ApiUser.new({
|
||||||
username: x.handle.try(:strip),
|
username: x.handle.try(:strip),
|
||||||
password: y.try(:password) ? y.try(:password) : ('a'..'z').to_a.shuffle.first(8).join,
|
plain_text_password: y.try(:password) ? y.try(:password) : ('a'..'z').to_a.shuffle.first(8).join,
|
||||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||||
roles: ['epp'],
|
roles: ['epp'],
|
||||||
legacy_id: y.try(:id)
|
legacy_id: y.try(:id)
|
||||||
|
|
|
@ -45,6 +45,6 @@ RSpec.describe Repp::ContactV1, db: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
def http_auth_key
|
def http_auth_key
|
||||||
ActionController::HttpAuthentication::Basic.encode_credentials(user.username, user.password)
|
ActionController::HttpAuthentication::Basic.encode_credentials(user.username, user.plain_text_password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :api_user do
|
factory :api_user do
|
||||||
sequence(:username) { |n| "test#{n}" }
|
sequence(:username) { |n| "test#{n}" }
|
||||||
password 'a' * ApiUser.min_password_length
|
plain_text_password 'a' * ApiUser.min_password_length
|
||||||
roles ['super']
|
roles ['super']
|
||||||
registrar
|
registrar
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Features
|
||||||
visit new_registrar_user_session_url
|
visit new_registrar_user_session_url
|
||||||
|
|
||||||
fill_in 'depp_user_tag', with: user.username
|
fill_in 'depp_user_tag', with: user.username
|
||||||
fill_in 'depp_user_password', with: user.password
|
fill_in 'depp_user_password', with: user.plain_text_password
|
||||||
|
|
||||||
click_button 'Login'
|
click_button 'Login'
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Requests
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_to_registrar_area(user: create(:api_user))
|
def sign_in_to_registrar_area(user: create(:api_user))
|
||||||
post registrar_user_session_path, { depp_user: { tag: user.username, password: user.password } }
|
post registrar_user_session_path, { depp_user: { tag: user.username, password: user.plain_text_password } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
4
test/fixtures/users.yml
vendored
4
test/fixtures/users.yml
vendored
|
@ -1,6 +1,6 @@
|
||||||
api_bestnames:
|
api_bestnames:
|
||||||
username: test_bestnames
|
username: test_bestnames
|
||||||
password: testtest
|
plain_text_password: testtest
|
||||||
type: ApiUser
|
type: ApiUser
|
||||||
registrar: bestnames
|
registrar: bestnames
|
||||||
active: true
|
active: true
|
||||||
|
@ -9,7 +9,7 @@ api_bestnames:
|
||||||
|
|
||||||
api_goodnames:
|
api_goodnames:
|
||||||
username: test_goodnames
|
username: test_goodnames
|
||||||
password: testtest
|
plain_text_password: testtest
|
||||||
type: ApiUser
|
type: ApiUser
|
||||||
registrar: goodnames
|
registrar: goodnames
|
||||||
active: true
|
active: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue