mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 23:16:23 +02:00
Add UserCertificate model with tests
- Create UserCertificate model with validations and certificate renewal logic - Add tests for UserCertificate model functionality - Add user certificates fixtures for testing - Add association between ApiUser and UserCertificates - Add required gems: dry-types, dry-struct, openssl - Add /certs to .gitignore This commit implements the base model for storing user certificates in the database, including private keys, CSRs, certificates and P12 files. The model includes basic validation and certificate renewal functionality, with comprehensive test coverage.
This commit is contained in:
parent
c192d3bf08
commit
51035d1ddf
11 changed files with 403 additions and 3 deletions
|
@ -2812,6 +2812,45 @@ CREATE SEQUENCE public.settings_id_seq
|
|||
ALTER SEQUENCE public.settings_id_seq OWNED BY public.settings.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.user_certificates (
|
||||
id bigint NOT NULL,
|
||||
user_id bigint NOT NULL,
|
||||
private_key bytea NOT NULL,
|
||||
csr text,
|
||||
certificate text,
|
||||
p12 bytea,
|
||||
status character varying,
|
||||
expires_at timestamp without time zone,
|
||||
revoked_at timestamp without time zone,
|
||||
p12_password_digest character varying,
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.user_certificates_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.user_certificates_id_seq OWNED BY public.user_certificates.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: users; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -3512,6 +3551,13 @@ ALTER TABLE ONLY public.setting_entries ALTER COLUMN id SET DEFAULT nextval('pub
|
|||
ALTER TABLE ONLY public.settings ALTER COLUMN id SET DEFAULT nextval('public.settings_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.user_certificates ALTER COLUMN id SET DEFAULT nextval('public.user_certificates_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -4210,6 +4256,14 @@ ALTER TABLE ONLY public.zones
|
|||
ADD CONSTRAINT unique_zone_origin UNIQUE (origin);
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates user_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.user_certificates
|
||||
ADD CONSTRAINT user_certificates_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -4895,6 +4949,20 @@ CREATE UNIQUE INDEX index_setting_entries_on_code ON public.setting_entries USIN
|
|||
CREATE UNIQUE INDEX index_settings_on_thing_type_and_thing_id_and_var ON public.settings USING btree (thing_type, thing_id, var);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_user_certificates_on_user_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_user_certificates_on_user_id ON public.user_certificates USING btree (user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_user_certificates_on_user_id_and_status; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_user_certificates_on_user_id_and_status ON public.user_certificates USING btree (user_id, status);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_users_on_identity_code; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -5040,6 +5108,14 @@ ALTER TABLE ONLY public.domains
|
|||
ADD CONSTRAINT domains_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES public.registrars(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: user_certificates fk_rails_03b0a0c9d8; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.user_certificates
|
||||
ADD CONSTRAINT fk_rails_03b0a0c9d8 FOREIGN KEY (user_id) REFERENCES public.users(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: invoices fk_rails_242b91538b; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -5718,6 +5794,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20241112124405'),
|
||||
('20241129095711'),
|
||||
('20241206085817'),
|
||||
('20250204094550');
|
||||
('20250204094550'),
|
||||
('20250218115707');
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue