-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
201 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...re/autoconfigure/src/main/java/org/royllo/explorer/core/domain/user/UserLnurlAuthKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.royllo.explorer.core.domain.user; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import static jakarta.persistence.FetchType.EAGER; | ||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PACKAGE; | ||
|
||
/** | ||
* Public key generated by the user's Lightning wallet. | ||
* This key is unique to each user and service combination, ensuring that the user's identity is consistent with each service but not across different services. | ||
*/ | ||
@Getter | ||
@Setter | ||
@ToString | ||
@RequiredArgsConstructor | ||
@AllArgsConstructor(access = PACKAGE) | ||
@Builder | ||
@Entity | ||
@Table(name = "APPLICATION_USER_LNURL_AUTH_LINKING_KEY") | ||
public class UserLnurlAuthKey { | ||
|
||
/** Unique identifier. */ | ||
@Id | ||
@Column(name = "ID") | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
/** User. */ | ||
@ManyToOne(fetch = EAGER) | ||
@JoinColumn(name = "FK_USER_OWNER", nullable = false) | ||
private User owner; | ||
|
||
/** Linking key. */ | ||
@Column(name = "LINKING_KEY", nullable = false) | ||
private String linkingKey; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...re/autoconfigure/src/main/java/org/royllo/explorer/core/dto/user/UserLnurlAuthKeyDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.royllo.explorer.core.dto.user; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Value; | ||
import org.royllo.explorer.core.domain.user.User; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
/** | ||
* Public key generated by the user's Lightning wallet. | ||
* This key is unique to each user and service combination, ensuring that the user's identity is consistent with each service but not across different services. | ||
*/ | ||
@Value | ||
@Builder | ||
@AllArgsConstructor(access = PRIVATE) | ||
public class UserLnurlAuthKeyDTO { | ||
|
||
/** Unique identifier. */ | ||
Long id; | ||
|
||
/** Linking key owner. */ | ||
@NotNull(message = "User owner is required") | ||
User owner; | ||
|
||
/** Linking key. */ | ||
@NotBlank(message = "Linking key is mandatory") | ||
String linkingKey; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...oconfigure/src/main/java/org/royllo/explorer/core/util/mapper/UserLnurlAuthKeyMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.royllo.explorer.core.util.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.royllo.explorer.core.domain.user.UserLnurlAuthKey; | ||
import org.royllo.explorer.core.dto.user.UserLnurlAuthKeyDTO; | ||
|
||
import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE; | ||
|
||
/** | ||
* User LNURL auth key related mapper. | ||
*/ | ||
@Mapper(nullValuePropertyMappingStrategy = IGNORE, | ||
uses = {UserMapper.class}) | ||
public interface UserLnurlAuthKeyMapper { | ||
|
||
UserLnurlAuthKey mapToUserLnurlAuthKey(UserLnurlAuthKeyDTO source); | ||
|
||
UserLnurlAuthKeyDTO mapToUserLnurlAuthKeyDTO(UserLnurlAuthKey source); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...log/1.0.0/table-constraints/table-constraints-application_user_lnurl_auth_linking_key.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd"> | ||
<changeSet author="straumat" id="1.0.0-table-constraints-application_user"> | ||
|
||
</changeSet> | ||
</databaseChangeLog> |
55 changes: 55 additions & 0 deletions
55
...main/resources/db/changelog/1.0.0/table/table-application_user_lnurl_auth_linking_key.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd"> | ||
<changeSet author="straumat" id="1.0.0-table-application_user_lnurl_auth_linking_key"> | ||
|
||
<createTable tableName="APPLICATION_USER_LNURL_AUTH_LINKING_KEY" | ||
remarks="Public key generated by the user's Lightning wallet"> | ||
|
||
<!-- Unique identifier --> | ||
<column name="ID" type="BIGINT" | ||
remarks="Unique identifier"> | ||
<constraints nullable="false" primaryKey="true" | ||
primaryKeyName="PRIMARY_KEY_APPLICATION_USER_LNURL_AUTH_LINKING_KEY"/> | ||
</column> | ||
|
||
<!-- Table fields --> | ||
<column name="LINKING_KEY" type="VARCHAR(255)" | ||
remarks="Public key generated by the user's Lightning wallet"> | ||
<constraints nullable="false" unique="true" | ||
uniqueConstraintName="UNIQUE_APPLICATION_USER_LINKING_KEY"/> | ||
</column> | ||
<column name="FK_USER_OWNER" type="BIGINT" | ||
remarks="The user who owns this linking key"> | ||
<constraints nullable="false"/> | ||
</column> | ||
|
||
<!-- Technical fields --> | ||
<column name="CREATED_ON" type="TIMESTAMP" | ||
remarks="Data created on"/> | ||
<column name="UPDATED_ON" type="TIMESTAMP" | ||
remarks="Data updated on"/> | ||
|
||
</createTable> | ||
|
||
<!-- Auto increment on the unique identifier --> | ||
<addAutoIncrement tableName="APPLICATION_USER_LNURL_AUTH_LINKING_KEY" | ||
columnName="ID" | ||
columnDataType="BIGINT" | ||
startWith="2"/> | ||
|
||
<!-- Index on FK_USER_OWNER --> | ||
<createIndex indexName="INDEX_APPLICATION_USER_LNURL_AUTH_LINKING_KEY_FK_USER_OWNER" | ||
tableName="APPLICATION_USER_LNURL_AUTH_LINKING_KEY"> | ||
<column name="FK_USER_OWNER"/> | ||
</createIndex> | ||
|
||
<!-- Index on LINKING_KEY --> | ||
<createIndex indexName="INDEX_APPLICATION_USER_LNURL_AUTH_LINKING_KEY_LINKING_KEY" | ||
tableName="APPLICATION_USER_LNURL_AUTH_LINKING_KEY"> | ||
<column name="LINKING_KEY"/> | ||
</createIndex> | ||
|
||
</changeSet> | ||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
backend/servers/explorer-web/src/test/resources/db/test/web-test-data-user.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd"> | ||
<changeSet author="straumat" id="test-data-user"> | ||
|
||
<!-- straumat user --> | ||
<insert tableName="USER"> | ||
<column name="ID" value="2"/> | ||
<column name="USER_ID" value="22222222-2222-2222-2222-222222222222"/> | ||
<column name="USERNAME" value="straumat"/> | ||
<column name="ROLE" value="ADMINISTRATOR"/> | ||
<column name="CREATED_ON"/> | ||
<column name="UPDATED_ON"/> | ||
</insert> | ||
|
||
</changeSet> | ||
</databaseChangeLog> |