Skip to content

Commit

Permalink
Add new column for new encyrption format (#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjb authored May 14, 2024
1 parent daccbc1 commit fcf857b
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 72 deletions.
16 changes: 16 additions & 0 deletions database/migrations/000056_encrypted_column.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

ALTER TABLE provider_access_tokens DROP COLUMN encrypted_access_token;
ALTER TABLE session_store DROP COLUMN encrypted_redirect;
18 changes: 18 additions & 0 deletions database/migrations/000056_encrypted_column.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

-- add columns for new encrypted data format

ALTER TABLE provider_access_tokens ADD COLUMN encrypted_access_token JSONB;
ALTER TABLE session_store ADD COLUMN encrypted_redirect TEXT;
14 changes: 0 additions & 14 deletions database/mock/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions database/query/provider_access_tokens.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ SELECT * FROM provider_access_tokens WHERE provider = $1 AND project_id = $2 AND

-- name: UpsertAccessToken :one
INSERT INTO provider_access_tokens
(project_id, provider, encrypted_token, expiration_time, owner_filter, enrollment_nonce)
(project_id, provider, encrypted_token, expiration_time, owner_filter, enrollment_nonce, encrypted_access_token)
VALUES
($1, $2, $3, $4, $5, $6)
($1, $2, $3, $4, $5, $6, $7)
ON CONFLICT (project_id, provider)
DO UPDATE SET
encrypted_token = $3,
expiration_time = $4,
owner_filter = $5,
enrollment_nonce = $6,
updated_at = NOW()
updated_at = NOW(),
encrypted_access_token = $7
WHERE provider_access_tokens.project_id = $1 AND provider_access_tokens.provider = $2
RETURNING *;

Expand Down
3 changes: 0 additions & 3 deletions database/query/session_store.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ INSERT INTO session_store (provider, project_id, remote_user, session_state, own
-- name: GetProjectIDBySessionState :one
SELECT provider, project_id, remote_user, owner_filter, redirect_url FROM session_store WHERE session_state = $1;

-- name: DeleteSessionState :exec
DELETE FROM session_store WHERE id = $1;

-- name: DeleteSessionStateByProjectID :exec
DELETE FROM session_store WHERE provider = $1 AND project_id = $2;

Expand Down
38 changes: 20 additions & 18 deletions internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions internal/db/provider_access_tokens.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/db/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions internal/db/session_store.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions internal/verifier/verifyif/mock/verifyif.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/protobuf/go/minder/v1/minder.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fcf857b

Please sign in to comment.