Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ID-1117] Add fence_account_key and distributed_lock tables to db #174

Merged
merged 14 commits into from
Mar 6, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package bio.terra.externalcreds.models;

import java.sql.Timestamp;
import org.immutables.value.Value;

@Value.Immutable
public interface DistributedLock extends WithDistributedLock {
String getLockName();

String getUserId();

Timestamp getExpiresAt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use java.time.Instant here instead of the SQL Timestamp.


class Builder extends ImmutableDistributedLock.Builder {}
}

Check warning on line 15 in service/src/main/java/bio/terra/externalcreds/models/DistributedLock.java

View check run for this annotation

Codecov / codecov/patch

service/src/main/java/bio/terra/externalcreds/models/DistributedLock.java#L14-L15

Added lines #L14 - L15 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package bio.terra.externalcreds.models;

import java.sql.Timestamp;
import java.util.Optional;
import org.immutables.value.Value;

@Value.Immutable
public interface FenceAccountKey extends WithFenceAccountKey {
Integer getId();

Optional<String> getKeyJson();

Timestamp getExpiresAt();

class Builder extends ImmutableFenceAccountKey.Builder {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
databaseChangeLog:
- changeSet:
id: "add_fence_account_key_and_dist_lock_table"
author: sehsan
changes:
- createTable:
tableName: fence_account_key
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need a foreign key to the user's linked_account record, so that we can retrieve a user's fence account key by user_id and provider (similar to ga4gh_passport). Does that make sense @tlangs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does make sense!

columns:
- column:
name: id
type: int
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: key_json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe this should be called key_json_base64?

type: text
constraints:
nullable: false
- column:
name: expires_at
type: timestamp
constraints:
nullable: false
- createTable:
tableName: distributed_lock
columns:
- column:
name: lock_name
type: text
constraints:
primaryKey: true
primaryKeyName: pk_dist_lock
- column:
name: user_id
type: text
constraints:
primaryKey: true
primaryKeyName: pk_dist_lock
- column:
name: expires_at
type: timestamp
constraints:
nullable: false
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ databaseChangeLog:
- include:
file: changesets/20220412_add_last_encrypt_timestamp_to_ssh_key_pair_table.yaml
relativeToChangelogFile: true
- include:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a merge conflict here. Make sure this changeset comes after the just-merged changeset.

file: changesets/20240228_add_fence_account_key_and_dist_lock_table.yaml
relativeToChangelogFile: true
Loading