encryption – Combining confidentiality, authenticity and data integrity to form secure URL

There are clients, they can share links to their profile info, which should be confidential. The link expires in 5 minutes. They set Auth Code, so that the one who gets the link can access the client’s data if he get the correct Auth code.

Restrictions:

  1. The link data should be encrypted.

  2. Every client has different key

  3. The client can generate the link in offline mode.

I looked at this answer https://security.stackexchange.com/a/63134/238870

But the same secret key is shared between all clients. Given that the profile, in my problem, contains sensitive information, I can’t rely on that solution.
Also the solution assumes the clients are online and the server knows the IV (I maybe wrong understanding the solution)

What I came up with is combining asymmetric encryption with digital signature:

Clients will encrypt the link data (Auth code, timestamp, user ID) using the server public key, and signs the data using their private key. The combination of the ciphertext and signature is the link data.

At the server, the encrypted data gets decrypted using the server’s private key, then I get the user ID, and by that ID, I get his public key, then verify his signature.

The problem with my solution, is that it’s costly (asymmetric encryption)
And the link gets too long, which is not very handy when sharing links via QR code, which is a main functionality of the application.

magento2 – Importing existing products: Integrity constraint violation: 1062 Duplicate Entry

I have been importing existing products to a local environment through the admin dashboard. I realized that many of the products I imported didn’t include their attributes, so I went back to make sure they were included by changing the ‘Multiple value separator’ to a pipe. Now though, when I import I get the following error:

General system exception happened
Additional data:
SQLSTATE(23000): Integrity constraint violation: 1062 Duplicate entry 'sauces-rubs/healthy-choices/gluten-free-default-category/healthy' for key 'url_rewrite.URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`store_id`,`entity_type`,`entity_id`,`request_path`,`target_path`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)

I have deleted all products and categories, I have wiped the url_rewrites table clean, and I have attempted to regenerate them using this module. What am I missing? I am new to Magento, so please let me know if I need to include more information, but this is all that I am aware of at the moment.

How integrity is compromised if forward secrecy is not enabled in TLS communication?

If TLS communication uses ciphers that does not support forward secrecy(FS) (like RSA key exchange ciphers), confidentiality of the past communication is compromised if the private key is compromised. But will the integrity also gets compromised in this scenario? I got this doubt after seeing the CVSS scoring in this link. Vector: CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N – The severity of integrity compromise is given as Low. Could anyone explain how integrity is getting affected in the absence of FS?

domain driven design – DDD Best way to preserve integrity of entity

I have an entity that contain the status of data (WaitingForData, ReadyForData, DataUsed).

class Batch
{
    int Status { get; }
    DateTime StartTime { get; }
    string Code { get; }
    void SetCode(string code)
    {
       Code=code; 
       if (StartTime not null) { Status = ReadyForData; }
    }
    void SetDate(DateTime date)
    {
       StarDate=date; 
       if (Code not null) { Status = ReadyForData; }
    }
    Product Product { get; }
    Category Category { get; }
}
class Product{...}
class Category{...}

When StartTime and Code are not null, the Status move from WaitingForData to ReadyForData. For preserve the integry of my Entity i check in SetDate() and SetCode if all data have a value and move the status.

Now my Entity need to change the Status for some value of Product and Category because for some category of product, the status can move to ReadyForData when have the Code not null (the value of StartDate is ignored), for the other combination of Category and PRoduct still check the Code and StartDate.

From the poin of DDD what is the best way to do?

I think to create the interface IManageBatch with method CheckStatusData(Product, Category, Batch) and the method return the status of Batch.

So the Batch method change to:


void SetCode(string code, IManageBatch checker);
void SetDate(DateTime date, IManageBatch checker);
    {
       StarDate=date; 
       if (checker.CheckStatusData(Product, Category, this)) { Status = ReadyForData; }
    }

This way is an antipattern? Becaouse my domain is not pure? In alternative i can move the use of SetDate() in an Appplication Service, and after check teh status and update.

MethodInApplicationService(string code, IManageBatch checker)
{
    batchEntity.SetCode(code);
    var result = checker(batchEntity.PRoduct, batchEntity.Category, batchEntity);
    if (result)  batchEntity.ChangeStatus(ReadyFroBatch)
}

In this way if I forgot to change the status and call only the SetCode i have my entity in WaintingForData when is Ready, and my entity in an Inconsistent value…

What is the best practice in this case?

Thanks

postgresql – Relational schema and integrity constraints

May I ask if these integrity constraints can be created over this schema using create script?

  1. club (klub) can have exactly one coach (trener)
  2. club can have just one owner (majitel)
  3. each member (člen) can be in just one club
  4. and a coach can set tactics (taktika) only for his club?

Is it possible to solve this with integrity constraints in the create script at all or are triggers used for it? I am a part of my create script.

Schema

enter image description here

Create script

CREATE TABLE club (
id_club SERIAL NOT NULL,
nazev VARCHAR(256) NOT NULL,
datum_zalozeni VARCHAR(256) NOT NULL
);
ALTER TABLE club ADD CONSTRAINT pk_club PRIMARY KEY (id_club);
ALTER TABLE club ADD CONSTRAINT uc_club_nazev UNIQUE (nazev);

CREATE TABLE coach (
    id_member INTEGER NOT NULL
);
ALTER TABLE coach ADD CONSTRAINT pk_coach PRIMARY KEY (id_member);

CREATE TABLE member (
    id_member SERIAL NOT NULL,
    id_club INTEGER NOT NULL,
    jmeno VARCHAR(256) NOT NULL,
    prijmeni VARCHAR(256) NOT NULL,
    narodnost VARCHAR(256) NOT NULL,
    datum_narozeni VARCHAR(256) NOT NULL
);
ALTER TABLE member ADD CONSTRAINT pk_member PRIMARY KEY (id_member);

CREATE TABLE owner (
    id_member INTEGER NOT NULL
);
ALTER TABLE owner ADD CONSTRAINT pk_owner PRIMARY KEY (id_member);

CREATE TABLE player (
    id_member INTEGER NOT NULL,
    cislo VARCHAR(256) NOT NULL,
    post VARCHAR(256) NOT NULL
);
ALTER TABLE player ADD CONSTRAINT pk_player PRIMARY KEY (id_member);

ALTER TABLE coach ADD CONSTRAINT fk_coach_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;

ALTER TABLE member ADD CONSTRAINT fk_member_club FOREIGN KEY (id_club) REFERENCES club (id_club) ON DELETE CASCADE;

ALTER TABLE owner ADD CONSTRAINT fk_owner_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;

ALTER TABLE player ADD CONSTRAINT fk_player_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;
enter code here
enter code here

php – Laravel 8: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

I want to apply OneToMany Relationship between users and roles table and I have already some data in these two tables.

So in order to make this relationship, I made this Migration for adding role_id to users table:

public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->unsignedBigInteger('role_id')->nullable()->unsigned();
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
        });
    }

But when I want to run this Migration, I get this error:

SQLSTATE(42S21): Column already exists: 1060 Duplicate column name
‘role_id’ (SQL: alter table users add role_id bigint unsigned
null)

So what is going wrong here ? How can I fix this issue ?

Here is also the Migration of roles table:

public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug');
            $table->timestamps();
        });
    }

sql server – Create script – integrity constraints

I would like to ask how in this part of conceptual scheme and create script I can create an integrity constraint / check that would set me that a club can have a maximum of one coach and just one owner. At the same time, but I admit that theoretically a member of the club can be both the player, the owner and the coach. Thank you in advance for any advice

enter image description here

CREATE TABLE club (
id_club SERIAL NOT NULL,
nazev VARCHAR(256) NOT NULL,
datum_zalozeni VARCHAR(256) NOT NULL
);
ALTER TABLE club ADD CONSTRAINT pk_club PRIMARY KEY (id_club);
ALTER TABLE club ADD CONSTRAINT uc_club_nazev UNIQUE (nazev);

CREATE TABLE coach (
    id_member INTEGER NOT NULL
);
ALTER TABLE coach ADD CONSTRAINT pk_coach PRIMARY KEY (id_member);

CREATE TABLE member (
    id_member SERIAL NOT NULL,
    id_club INTEGER NOT NULL,
    jmeno VARCHAR(256) NOT NULL,
    prijmeni VARCHAR(256) NOT NULL,
    narodnost VARCHAR(256) NOT NULL,
    datum_narozeni VARCHAR(256) NOT NULL
);
ALTER TABLE member ADD CONSTRAINT pk_member PRIMARY KEY (id_member);

CREATE TABLE owner (
    id_member INTEGER NOT NULL
);
ALTER TABLE owner ADD CONSTRAINT pk_owner PRIMARY KEY (id_member);

CREATE TABLE player (
    id_member INTEGER NOT NULL,
    cislo VARCHAR(256) NOT NULL,
    post VARCHAR(256) NOT NULL
);
ALTER TABLE player ADD CONSTRAINT pk_player PRIMARY KEY (id_member);

ALTER TABLE coach ADD CONSTRAINT fk_coach_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;

ALTER TABLE member ADD CONSTRAINT fk_member_club FOREIGN KEY (id_club) REFERENCES club (id_club) ON DELETE CASCADE;

ALTER TABLE owner ADD CONSTRAINT fk_owner_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;

ALTER TABLE player ADD CONSTRAINT fk_player_member FOREIGN KEY (id_member) REFERENCES member (id_member) ON DELETE CASCADE;

magento2.3 – Magento 2 Data Migration “Integrity constraint violation: 1062 Duplicate entry ### for key ‘SALES_CREDITMEMO_INCREMENT_ID_STORE_ID

I’ve been having issues while using the data migration tool to migrate data from Magento 1.9.3 to Magento 2.3:

I already setup the config.xml to migrate only Customers and Sales. I then run the following commands:

php bin/magento migrate:settings –reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

php bin/magento migrate:data –auto vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.8/config.xml

and then get the following error:

In Mysql.php line 182:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘100000003-1’ for key ‘SALES_CREDITMEMO_INCREMENT_ID_STORE_ID’

The Magento 2 database sales_creditmemo_* tables are all empty, so I’m clueless.
Any help is greatly appreciated.