From 3f9896bf4b4d517bfd80616e329f2e74e37ddcd3 Mon Sep 17 00:00:00 2001 From: Afonso Barracha Date: Sat, 10 Oct 2026 13:38:23 +0100 Subject: [PATCH 1/2] chore: update project.md --- project.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project.md b/project.md index 265ccb8..f5baf35 100644 --- a/project.md +++ b/project.md @@ -22,16 +22,16 @@ - Add support for multiple 2FA types - Make refresh tokens whitelisted not blacklisted - Add grants to control refresh token - -### IDP On-Going - - Add OAuth Dynamic Registration for: - accounts - apps -### IDP Todo +### IDP On-Going - Update serial to big serial for scalability support + +### IDP Todo + - OAuth Client ID Metadata Document - User authentication for each app type: - web (including public SPA clients and service clients using client_credentials or JWT bearer grants) From d8177a31a7a80a5956de1a67adcd79352814cbde Mon Sep 17 00:00:00 2001 From: Afonso Barracha Date: Sat, 10 Oct 2026 14:33:38 +0100 Subject: [PATCH 2/2] refactor: update ids from int32 to int64 --- idp/initial_schema.dbml | 216 ++++++++--------- idp/internal/controllers/middleware.go | 4 +- idp/internal/controllers/params/users.go | 2 +- idp/internal/controllers/users.go | 10 +- .../providers/cache/account_username.go | 10 +- .../cache/apps_dynamic_registration.go | 4 +- idp/internal/providers/cache/two_factor.go | 10 +- idp/internal/providers/crypto/dek.go | 2 +- idp/internal/providers/crypto/hmac.go | 2 +- idp/internal/providers/crypto/jwk.go | 2 +- idp/internal/providers/crypto/kek.go | 6 +- idp/internal/providers/crypto/totp.go | 10 +- .../database/account_2fa_configs.sql.go | 8 +- .../account_credential_secrets.sql.go | 20 +- .../database/account_credentials.sql.go | 16 +- .../database/account_credentials_keys.sql.go | 16 +- .../account_data_encryption_keys.sql.go | 8 +- ...ccount_dynamic_registration_configs.sql.go | 8 +- .../providers/database/account_grants.sql.go | 22 +- .../database/account_hmac_secrets.sql.go | 12 +- .../account_key_encryption_keys.sql.go | 6 +- .../database/account_sessions.sql.go | 30 +-- .../account_token_signing_keys.sql.go | 10 +- .../providers/database/account_totps.sql.go | 8 +- .../providers/database/accounts.sql.go | 24 +- .../providers/database/app_designs.sql.go | 12 +- .../app_dynamic_registration_configs.sql.go | 8 +- .../providers/database/app_keys.sql.go | 14 +- .../providers/database/app_profiles.sql.go | 10 +- .../providers/database/app_secrets.sql.go | 14 +- idp/internal/providers/database/apps.sql.go | 26 +-- .../database/credentials_keys.sql.go | 8 +- .../database/credentials_secrets.sql.go | 10 +- .../database/data_encryption_keys.sql.go | 2 +- .../dynamic_registration_domain_codes.sql.go | 10 +- .../dynamic_registration_domains.sql.go | 6 +- idp/internal/providers/database/grants.sql.go | 6 +- .../database/key_encryption_keys.sql.go | 12 +- ...0241213231542_create_initial_schema.up.sql | 218 +++++++++--------- idp/internal/providers/database/models.go | 216 ++++++++--------- .../providers/database/oidc_configs.sql.go | 10 +- .../providers/database/registered_apps.sql.go | 4 +- .../providers/database/session_tokens.sql.go | 6 +- .../providers/database/sessions.sql.go | 12 +- .../database/token_signing_keys.sql.go | 6 +- idp/internal/providers/database/totps.sql.go | 10 +- .../database/user_auth_providers.sql.go | 6 +- .../providers/database/user_sessions.sql.go | 16 +- .../providers/database/user_totps.sql.go | 2 +- idp/internal/providers/database/users.sql.go | 38 +-- idp/internal/services/account_2fa_configs.go | 2 +- idp/internal/services/account_credentials.go | 30 +-- .../account_credentials_registration.go | 4 +- idp/internal/services/account_hmac_secrets.go | 10 +- idp/internal/services/accounts.go | 12 +- .../services/app_dynamic_registration.go | 6 +- .../app_dynamic_registration_configs.go | 4 +- .../services/app_dynamic_registration_iat.go | 4 +- idp/internal/services/app_users.go | 8 +- idp/internal/services/apps.go | 47 ++-- idp/internal/services/apps_auth.go | 2 +- idp/internal/services/auth.go | 26 +-- idp/internal/services/client_credentials.go | 6 +- idp/internal/services/deks.go | 10 +- idp/internal/services/dtos/account.go | 4 +- .../services/dtos/account_2fa_config.go | 4 +- .../services/dtos/account_credentials.go | 8 +- .../account_dynamic_registration_config.go | 4 +- idp/internal/services/dtos/app.go | 9 +- idp/internal/services/dtos/app_design.go | 4 +- .../dtos/app_dynamic_registration_config.go | 4 +- idp/internal/services/dtos/auth_provider.go | 4 +- .../dtos/client_credentials_secrets.go | 6 +- .../dtos/dynamic_registration_domain.go | 4 +- .../dtos/dynamic_registration_domain_code.go | 4 +- idp/internal/services/dtos/oidc_configs.go | 4 +- idp/internal/services/dtos/user.go | 4 +- idp/internal/services/jwks.go | 12 +- idp/internal/services/keks.go | 14 +- idp/internal/services/oauth.go | 2 +- .../oauth_dynamic_registration_apps.go | 32 +-- idp/internal/services/oidc_configs.go | 8 +- .../services/registration_credentials.go | 2 +- .../services/registration_management.go | 5 +- .../services/registration_metadata.go | 2 +- idp/internal/services/users.go | 30 +-- idp/internal/services/users_auth.go | 32 +-- idp/internal/services/well_known.go | 4 +- idp/tests/dynamic_registration_test.go | 4 +- 89 files changed, 769 insertions(+), 760 deletions(-) diff --git a/idp/initial_schema.dbml b/idp/initial_schema.dbml index 36fff89..4dd0f78 100644 --- a/idp/initial_schema.dbml +++ b/idp/initial_schema.dbml @@ -11,7 +11,7 @@ Enum kek_usage { } Table key_encryption_keys as KEK { - id serial [pk] + id bigserial [pk] kid uuid [not null] usage kek_usage [not null] @@ -36,7 +36,7 @@ Enum dek_usage { } Table data_encryption_keys as DEK { - id serial [pk] + id bigserial [pk] kid varchar(22) [not null] dek text [not null] @@ -96,7 +96,7 @@ Enum token_key_type { } Table token_signing_keys as TS { - id serial [pk] + id bigserial [pk] kid varchar(22) [not null] key_type token_key_type [not null] @@ -131,7 +131,7 @@ Enum activity_status { } Table accounts as A { - id serial [pk] + id bigserial [pk] public_id uuid [not null] given_name varchar(100) [not null] @@ -161,9 +161,9 @@ Enum two_factor_type { } Table account_2fa_configs as A2FA { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] two_factor_type two_factor_type [not null] @@ -188,7 +188,7 @@ Enum totp_usage { } Table totps as TP { - id serial [pk] + id bigserial [pk] dek_kid varchar(22) [not null] url varchar(512) [not null] @@ -196,7 +196,7 @@ Table totps as TP { recovery_codes jsonb [not null] usage totp_usage [not null] - account_id integer [not null] + account_id bigint [not null] created_at timestamptz [not null, default: `now()`] updated_at timestamptz [not null, default: `now()`] @@ -216,7 +216,7 @@ Enum credentials_usage { } Table credentials_secrets as CS { - id serial [pk] + id bigserial [pk] secret_id varchar(22) [not null] client_secret text [not null] @@ -224,7 +224,7 @@ Table credentials_secrets as CS { is_revoked boolean [not null, default: false] usage credentials_usage [not null] - account_id integer [not null] + account_id bigint [not null] expires_at timestamptz [not null] created_at timestamptz [not null, default: `now()`] @@ -243,7 +243,7 @@ Ref: CS.account_id > A.id [delete: cascade] Ref: CS.dek_kid > DEK.kid [delete: cascade, update: cascade] Table credentials_keys as CK { - id serial [pk] + id bigserial [pk] public_kid varchar(22) [not null] public_key jsonb [not null] @@ -254,7 +254,7 @@ Table credentials_keys as CK { is_external boolean [not null, default: false] usage credentials_usage [not null] - account_id integer [not null] + account_id bigint [not null] expires_at timestamptz [not null] created_at timestamptz [not null, default: `now()`] @@ -272,8 +272,8 @@ Ref: CK.account_id > A.id [delete: cascade] Ref: CK.dek_kid > DEK.kid [delete: cascade, update: cascade] Table account_key_encryption_keys as AKEK { - account_id integer [not null] - key_encryption_key_id integer [not null] + account_id bigint [not null] + key_encryption_key_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -288,8 +288,8 @@ Ref: AKEK.account_id > A.id [delete: cascade] Ref: AKEK.key_encryption_key_id > KEK.id [delete: cascade] Table account_data_encryption_keys as ADEK { - account_id integer [not null] - data_encryption_key_id integer [not null] + account_id bigint [not null] + data_encryption_key_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -304,9 +304,9 @@ Ref: ADEK.account_id > A.id [delete: cascade] Ref: ADEK.data_encryption_key_id > DEK.id [delete: cascade] Table account_hmac_secrets as AHS { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] secret_id varchar(22) [not null] secret text [not null] @@ -328,8 +328,8 @@ Ref: AHS.account_id > A.id [delete: cascade] Ref: AHS.dek_kid > DEK.kid [delete: cascade, update: cascade] Table account_totps as AT { - account_id integer [not null] - totp_id integer [not null] + account_id bigint [not null] + totp_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -393,9 +393,9 @@ Enum creation_method { Table account_credentials as AC { registration_token_jti uuid [unique] software_statement text [not null, default: ''] - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] // Internal for checks @@ -459,10 +459,10 @@ Table account_credentials as AC { Ref: AC.account_id > A.id [delete: cascade] Table account_credentials_secrets as ACS { - account_id integer [not null] - credentials_secret_id integer [not null] + account_id bigint [not null] + credentials_secret_id bigint [not null] - account_credentials_id integer [not null] + account_credentials_id bigint [not null] account_public_id uuid [not null] secret_id varchar(22) [not null] @@ -482,10 +482,10 @@ Ref: ACS.account_id > A.id [delete: cascade] Ref: ACS.credentials_secret_id > CS.id [delete: cascade] Table account_credentials_keys as ACK { - account_id integer [not null] - credentials_key_id integer [not null] + account_id bigint [not null] + credentials_key_id bigint [not null] - account_credentials_id integer [not null] + account_credentials_id bigint [not null] account_public_id uuid [not null] jwk_kid varchar(22) [not null] @@ -515,7 +515,7 @@ Enum auth_provider { } Table account_auth_providers as AP { - id serial [pk] + id bigserial [pk] email varchar(250) [not null] provider auth_provider [not null] @@ -565,9 +565,9 @@ Enum scopes { } Table oidc_configs as OIDC { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] claims_supported "claims[]" [not null, default: '{ "sub", "email", "email_verified", "given_name", "family_name" }'] scopes_supported "scopes[]" [not null, default: '{ "openid", "email", "profile" }'] @@ -584,8 +584,8 @@ Table oidc_configs as OIDC { Ref: OIDC.account_id > A.id [delete: cascade] Table account_token_signing_keys as ATSK { - account_id integer [not null] - token_signing_key_id integer [not null] + account_id bigint [not null] + token_signing_key_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -600,10 +600,10 @@ Ref: ATSK.account_id > A.id [delete: cascade] Ref: ATSK.token_signing_key_id > TS.id [delete: cascade] Table users as U { - id serial [pk] + id bigserial [pk] public_id uuid [not null] - account_id integer [not null] + account_id bigint [not null] email varchar(250) [not null] username varchar(63) [not null] // maximum length of a DNS label @@ -628,10 +628,10 @@ Table users as U { Ref: U.account_id > A.id [delete: cascade] Table user_2fa_configs as U2FA { - id serial [pk] - account_id integer [not null] + id bigserial [pk] + account_id bigint [not null] - user_id integer [not null] + user_id bigint [not null] two_factor_type two_factor_type [not null] is_default boolean [not null, default: false] @@ -649,10 +649,10 @@ Ref: U2FA.account_id > A.id [delete: cascade] Ref: U2FA.user_id > U.id [delete: cascade] Table user_data_encryption_keys as UDEK { - user_id integer [not null] - data_encryption_key_id integer [not null] + user_id bigint [not null] + data_encryption_key_id bigint [not null] - account_id integer [not null] + account_id bigint [not null] created_at timestamptz [not null, default: `now()`] Indexes { @@ -668,10 +668,10 @@ Ref: UDEK.user_id > U.id [delete: cascade] Ref: UDEK.data_encryption_key_id > DEK.id [delete: cascade] Table user_totps as UT { - user_id integer [not null] - totp_id integer [not null] + user_id bigint [not null] + totp_id bigint [not null] - account_id integer [not null] + account_id bigint [not null] created_at timestamptz [not null, default: `now()`] Indexes { @@ -687,10 +687,10 @@ Ref: UT.user_id > U.id [delete: cascade] Ref: UT.totp_id > TP.id [delete: cascade] Table user_auth_providers as UAP { - id serial [pk] + id bigserial [pk] - user_id integer [not null] - account_id integer [not null] + user_id bigint [not null] + account_id bigint [not null] provider auth_provider [not null] @@ -707,11 +707,11 @@ Ref: UAP.account_id > A.id [delete: cascade] Ref: UAP.user_id > U.id [delete: cascade] Table user_credentials as UC { - id serial [pk] + id bigserial [pk] - user_id integer [not null] - account_id integer [not null] - app_id integer [not null] + user_id bigint [not null] + account_id bigint [not null] + app_id bigint [not null] client_id varchar(22) [not null] auth_methods "auth_method[]" [not null] @@ -733,11 +733,11 @@ Ref: UC.account_id > A.id [delete: cascade] Ref: UC.app_id > APP.id [delete: cascade] Table user_credentials_secrets as UCS { - user_id integer [not null] - credentials_secret_id integer [not null] + user_id bigint [not null] + credentials_secret_id bigint [not null] - user_credential_id integer [not null] - account_id integer [not null] + user_credential_id bigint [not null] + account_id bigint [not null] user_public_id uuid [not null] @@ -759,11 +759,11 @@ Ref: UCS.credentials_secret_id > CS.id [delete: cascade] Ref: UCS.account_id > A.id [delete: cascade] Table user_credentials_keys as UCK { - user_id integer [not null] - credentials_key_id integer [not null] + user_id bigint [not null] + credentials_key_id bigint [not null] - user_credential_id integer [not null] - account_id integer [not null] + user_credential_id bigint [not null] + account_id bigint [not null] user_public_id uuid [not null] created_at timestamptz [not null, default: `now()`] @@ -811,8 +811,8 @@ Enum session_type { Table apps as APP { registration_token_jti uuid [unique] software_statement text [not null, default: ''] - id serial [pk] - account_id integer [not null] + id bigserial [pk] + account_id bigint [not null] account_public_id uuid [not null] @@ -896,10 +896,10 @@ Ref: APP.account_id > A.id [delete: cascade] Table app_secrets as APS { - app_id integer [not null] - credentials_secret_id integer [not null] + app_id bigint [not null] + credentials_secret_id bigint [not null] - account_id integer [not null] + account_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -916,10 +916,10 @@ Ref: APS.app_id > APP.id [delete: cascade] Ref: APS.credentials_secret_id > CS.id [delete: cascade] Table app_keys as APK { - app_id integer [not null] - credentials_key_id integer [not null] + app_id bigint [not null] + credentials_key_id bigint [not null] - account_id integer [not null] + account_id bigint [not null] created_at timestamptz [not null, default: `now()`] @@ -936,10 +936,10 @@ Ref: APK.app_id > APP.id [delete: cascade] Ref: APK.credentials_key_id > CK.id [delete: cascade] Table app_designs as AD { - id serial [pk] + id bigserial [pk] - account_id integer [not null] - app_id integer [not null] + account_id bigint [not null] + app_id bigint [not null] light_colors jsonb [not null] dark_colors jsonb [null] @@ -969,9 +969,9 @@ Enum software_statement_verification_method { } Table account_dynamic_registration_configs as ADRC { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] account_credentials_types "account_credentials_type[]" [not null] @@ -990,9 +990,9 @@ Table account_dynamic_registration_configs as ADRC { Ref: ADRC.account_id > A.id [delete: cascade] Table app_dynamic_registration_configs as APDRC { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] allowed_app_types "app_type[]" [not null] @@ -1038,9 +1038,9 @@ Enum domain_verification_method { } Table dynamic_registration_domains as ADRD { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] domain varchar(250) [not null] @@ -1063,10 +1063,10 @@ Table dynamic_registration_domains as ADRD { Ref: ADRD.account_id > A.id [delete: cascade] Table dynamic_registration_domain_codes as DRDC { - id serial [pk] + id bigserial [pk] - account_id integer [not null] - dynamic_registration_domain_id integer [not null] + account_id bigint [not null] + dynamic_registration_domain_id bigint [not null] verification_host varchar(50) [not null] verification_code text [not null] @@ -1087,11 +1087,11 @@ Ref: DRDC.dynamic_registration_domain_id > ADRD.id [delete: cascade] Ref: DRDC.hmac_secret_id > AHS.secret_id [delete: cascade, update: cascade] Table dynamic_registration_software_statement_keys as DRSK { - id serial [pk] + id bigserial [pk] - account_id integer [not null] + account_id bigint [not null] account_public_id uuid [not null] - credentials_key_id integer [not null] + credentials_key_id bigint [not null] credentials_key_kid varchar(22) [not null] root_domain varchar(250) [not null] @@ -1115,10 +1115,10 @@ Enum app_profile_type { } Table app_profiles as AUP { - app_id integer [not null] - user_id integer [not null] + app_id bigint [not null] + user_id bigint [not null] - account_id integer [not null] + account_id bigint [not null] profile_type app_profile_type [not null] created_at timestamptz [not null, default: `now()`] @@ -1141,8 +1141,8 @@ Enum token_owner { } Table grants as G { - id serial [pk] - account_id integer [not null] + id bigserial [pk] + account_id bigint [not null] grant_id uuid [not null] granted_client_id varchar(22) [not null] @@ -1164,11 +1164,11 @@ Table grants as G { Ref: G.account_id > A.id [delete: cascade] Table account_grants as AG { - account_id integer [not null] + account_id bigint [not null] account_version integer [not null] - grant_id integer [not null] - account_credentials_id integer [null] + grant_id bigint [not null] + account_credentials_id bigint [null] granted_client_id varchar(22) [not null] is_revoked boolean [not null, default: false] @@ -1190,11 +1190,11 @@ Ref: AG.grant_id > G.id [delete: cascade] Ref: AG.account_credentials_id > AC.id [delete: cascade] Table user_grants as UG { - user_id integer [not null] + user_id bigint [not null] user_version integer [not null] - grant_id integer [not null] - app_id integer [not null] - account_id integer [not null] + grant_id bigint [not null] + app_id bigint [not null] + account_id bigint [not null] granted_client_id varchar(22) [not null] is_revoked boolean [not null, default: false] @@ -1218,9 +1218,9 @@ Ref: UG.app_id > APP.id [delete: cascade] Ref: UG.account_id > A.id [delete: cascade] Table sessions as S { - id serial [pk] - account_id integer [not null] - grant_id integer [not null] + id bigserial [pk] + account_id bigint [not null] + grant_id bigint [not null] session_id uuid [not null] session_type session_type [not null] @@ -1246,11 +1246,11 @@ Ref: S.account_id > A.id [delete: cascade] Ref: S.grant_id > G.id [delete: cascade] Table account_sessions as AS { - account_id integer [not null] + account_id bigint [not null] account_version integer [not null] - session_id integer [not null] - account_credentials_id integer [null] + session_id bigint [not null] + account_credentials_id bigint [null] session_uuid uuid [not null] @@ -1269,11 +1269,11 @@ Ref: AS.session_id > S.id [delete: cascade] Ref: AS.account_credentials_id > AC.id [delete: cascade] Table user_sessions as US { - user_id integer [not null] + user_id bigint [not null] user_version integer [not null] - session_id integer [not null] - app_id integer [not null] - account_id integer [not null] + session_id bigint [not null] + app_id bigint [not null] + account_id bigint [not null] session_uuid uuid [not null] @@ -1293,10 +1293,10 @@ Ref: US.app_id > APP.id [delete: cascade] Ref: US.account_id > A.id [delete: cascade] Table session_tokens as ST { - id serial [pk] - account_id integer [not null] - session_id integer [not null] - grant_id integer [not null] + id bigserial [pk] + account_id bigint [not null] + session_id bigint [not null] + grant_id bigint [not null] session_uuid uuid [not null] token_id uuid [not null] diff --git a/idp/internal/controllers/middleware.go b/idp/internal/controllers/middleware.go index 78f7d6f..a7d6397 100644 --- a/idp/internal/controllers/middleware.go +++ b/idp/internal/controllers/middleware.go @@ -446,13 +446,13 @@ func getUserAccessClaims(ctx fiber.Ctx) (tokens.UserAuthClaims, tokens.AppClaims return user, app, scopes, nil } -func getHostAccount(ctx fiber.Ctx) (string, int32, *exceptions.ServiceError) { +func getHostAccount(ctx fiber.Ctx) (string, int64, *exceptions.ServiceError) { accountUsername, ok := ctx.Locals("accountUsername").(string) if !ok || accountUsername == "" { return "", 0, exceptions.NewNotFoundError() } - accountID, ok := ctx.Locals("accountID").(int32) + accountID, ok := ctx.Locals("accountID").(int64) if !ok || accountID == 0 { return "", 0, exceptions.NewNotFoundError() } diff --git a/idp/internal/controllers/params/users.go b/idp/internal/controllers/params/users.go index 644811f..79325fe 100644 --- a/idp/internal/controllers/params/users.go +++ b/idp/internal/controllers/params/users.go @@ -29,5 +29,5 @@ type GetUserURLParams struct { } type MutateUserURLParams struct { - UserID int32 `validate:"required,min=1"` + UserID int64 `validate:"required,min=1"` } diff --git a/idp/internal/controllers/users.go b/idp/internal/controllers/users.go index 33d082c..d697c98 100644 --- a/idp/internal/controllers/users.go +++ b/idp/internal/controllers/users.go @@ -193,11 +193,11 @@ func (c *Controllers) GetUser(ctx fiber.Ctx) error { return serviceErrorResponse(logger, ctx, serviceErr) } - userID, err := strconv.ParseInt(urlParams.UserIDOrUsername, 10, 32) + userID, err := strconv.ParseInt(urlParams.UserIDOrUsername, 10, 64) if err == nil { userDTO, serviceErr := c.services.GetUserByID(ctx.Context(), services.GetUserByIDOptions{ RequestID: requestID, - UserID: int32(userID), + UserID: int64(userID), AccountID: accountID, }) if serviceErr != nil { @@ -236,7 +236,7 @@ func (c *Controllers) UpdateUser(ctx fiber.Ctx) error { userID := fiber.Params[int](ctx, "userID") urlParams := params.MutateUserURLParams{ - UserID: int32(userID), + UserID: int64(userID), } if err := c.validate.StructCtx(ctx.Context(), &urlParams); err != nil { return validateURLParamsErrorResponse(logger, ctx, err) @@ -314,7 +314,7 @@ func (c *Controllers) UpdateUserPassword(ctx fiber.Ctx) error { userID := fiber.Params[int](ctx, "userID") urlParams := params.MutateUserURLParams{ - UserID: int32(userID), + UserID: int64(userID), } if err := c.validate.StructCtx(ctx.Context(), &urlParams); err != nil { return validateURLParamsErrorResponse(logger, ctx, err) @@ -366,7 +366,7 @@ func (c *Controllers) DeleteUser(ctx fiber.Ctx) error { userID := fiber.Params[int](ctx, "userID") urlParams := params.MutateUserURLParams{ - UserID: int32(userID), + UserID: int64(userID), } if err := c.validate.StructCtx(ctx.Context(), &urlParams); err != nil { return validateURLParamsErrorResponse(logger, ctx, err) diff --git a/idp/internal/providers/cache/account_username.go b/idp/internal/providers/cache/account_username.go index 34c20d1..0d586e4 100644 --- a/idp/internal/providers/cache/account_username.go +++ b/idp/internal/providers/cache/account_username.go @@ -16,7 +16,7 @@ const ( type AddAccountUsernameOptions struct { RequestID string - ID int32 + ID int64 Username string } @@ -31,7 +31,7 @@ func (c *Cache) AddAccountUsername(ctx context.Context, opts AddAccountUsernameO return c.storage.SetWithContext( ctx, fmt.Sprintf("%s:%s", accountUsernamePrefix, opts.Username), - []byte(strconv.Itoa(int(opts.ID))), + []byte(strconv.FormatInt(opts.ID, 10)), c.accountUsernameTTL, ) } @@ -44,7 +44,7 @@ type GetAccountIDByUsernameOptions struct { func (c *Cache) GetAccountIDByUsername( ctx context.Context, opts GetAccountIDByUsernameOptions, -) (int32, error) { +) (int64, error) { logger := utils.BuildLogger(c.logger, utils.LoggerOptions{ Location: accountUsernameLocation, Method: "GetAccountIDByUsername", @@ -60,10 +60,10 @@ func (c *Cache) GetAccountIDByUsername( return 0, nil } - id, err := strconv.Atoi(string(val)) + id, err := strconv.ParseInt(string(val), 10, 64) if err != nil { return 0, err } - return int32(id), nil + return id, nil } diff --git a/idp/internal/providers/cache/apps_dynamic_registration.go b/idp/internal/providers/cache/apps_dynamic_registration.go index a43c2b5..96ec957 100644 --- a/idp/internal/providers/cache/apps_dynamic_registration.go +++ b/idp/internal/providers/cache/apps_dynamic_registration.go @@ -26,7 +26,7 @@ func buildAppDynamicRegistrationIATAuthCacheKey(hostname, clientID string) strin } type AppsDynamicRegistrationIATAuthData struct { - AccountID int32 `json:"account_id"` + AccountID int64 `json:"account_id"` Domain string `json:"domain"` State string `json:"state"` Challenge string `json:"challenge"` @@ -36,7 +36,7 @@ type AppsDynamicRegistrationIATAuthData struct { type SaveAppsDynamicRegistrationIATAuthOptions struct { RequestID string Hostname string - AccountID int32 + AccountID int64 Domain string State string RedirectURI string diff --git a/idp/internal/providers/cache/two_factor.go b/idp/internal/providers/cache/two_factor.go index 14a47da..4fa488a 100644 --- a/idp/internal/providers/cache/two_factor.go +++ b/idp/internal/providers/cache/two_factor.go @@ -43,7 +43,7 @@ func generate2FACode() (string, error) { return string(code), nil } -func generateKey(accountID, userID int32) string { +func generateKey(accountID, userID int64) string { if userID > 0 { return fmt.Sprintf("%s:%d:%s:%d", twoFactorPrefix, accountID, twoFactorUserPrefix, userID) } @@ -53,8 +53,8 @@ func generateKey(accountID, userID int32) string { type AddTwoFactorCodeOptions struct { RequestID string - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 TTL int64 } @@ -89,8 +89,8 @@ func (c *Cache) AddTwoFactorCode(ctx context.Context, opts AddTwoFactorCodeOptio type VerifyTwoFactorCodeOptions struct { RequestID string - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 Code string } diff --git a/idp/internal/providers/crypto/dek.go b/idp/internal/providers/crypto/dek.go index 9a00e7a..e95fb5e 100644 --- a/idp/internal/providers/crypto/dek.go +++ b/idp/internal/providers/crypto/dek.go @@ -24,7 +24,7 @@ const ( dekByteLen int = 32 // 256 bits ) -type StoreDEK = func(dekID, encryptedDEK string, kekID uuid.UUID) (int32, *exceptions.ServiceError) +type StoreDEK = func(dekID, encryptedDEK string, kekID uuid.UUID) (int64, *exceptions.ServiceError) type GenerateDEKOptions struct { RequestID string diff --git a/idp/internal/providers/crypto/hmac.go b/idp/internal/providers/crypto/hmac.go index 3e30718..b45d769 100644 --- a/idp/internal/providers/crypto/hmac.go +++ b/idp/internal/providers/crypto/hmac.go @@ -33,7 +33,7 @@ func decodeHMACSecret(secret string) ([]byte, error) { type SecretID = string -type StoreHMACSecret = func(dekID string, secretID SecretID, encryptedSecret string) (int32, *exceptions.ServiceError) +type StoreHMACSecret = func(dekID string, secretID SecretID, encryptedSecret string) (int64, *exceptions.ServiceError) type GenerateHMACSecretOptions struct { RequestID string diff --git a/idp/internal/providers/crypto/jwk.go b/idp/internal/providers/crypto/jwk.go index c04cb1c..a6ba91c 100644 --- a/idp/internal/providers/crypto/jwk.go +++ b/idp/internal/providers/crypto/jwk.go @@ -28,7 +28,7 @@ type KeyPair struct { CryptoSuite utils.SupportedCryptoSuite } -type StorePrivateKey = func(dekKid string, cryptoSuite utils.SupportedCryptoSuite, kid, encryptedKey string, pubKey utils.JWK) (int32, *exceptions.ServiceError) +type StorePrivateKey = func(dekKid string, cryptoSuite utils.SupportedCryptoSuite, kid, encryptedKey string, pubKey utils.JWK) (int64, *exceptions.ServiceError) type GenerateKeyPairOptions struct { RequestID string diff --git a/idp/internal/providers/crypto/kek.go b/idp/internal/providers/crypto/kek.go index 26a4926..b2c3f54 100644 --- a/idp/internal/providers/crypto/kek.go +++ b/idp/internal/providers/crypto/kek.go @@ -60,14 +60,14 @@ func (e *Crypto) rotateKey(ctx context.Context, keyID uuid.UUID) error { } type KEKID = uuid.UUID -type StoreKEK = func(keyID KEKID) (int32, error) +type StoreKEK = func(keyID KEKID) (int64, error) type GenerateKEKOptions struct { RequestID string StoreFN StoreKEK } -func (e *Crypto) GenerateKEK(ctx context.Context, opts GenerateKEKOptions) (int32, uuid.UUID, error) { +func (e *Crypto) GenerateKEK(ctx context.Context, opts GenerateKEKOptions) (int64, uuid.UUID, error) { logger := utils.BuildLogger(e.logger, utils.LoggerOptions{ Location: kekLocation, Method: "GenerateKEK", @@ -102,7 +102,7 @@ type RotateKEKOptions struct { KEKid KEKID } -func (e *Crypto) RotateKEK(ctx context.Context, opts RotateKEKOptions) (int32, uuid.UUID, error) { +func (e *Crypto) RotateKEK(ctx context.Context, opts RotateKEKOptions) (int64, uuid.UUID, error) { logger := utils.BuildLogger(e.logger, utils.LoggerOptions{ Location: kekLocation, Method: "RotateKEK", diff --git a/idp/internal/providers/crypto/totp.go b/idp/internal/providers/crypto/totp.go index 9e6c877..a60425c 100644 --- a/idp/internal/providers/crypto/totp.go +++ b/idp/internal/providers/crypto/totp.go @@ -277,12 +277,12 @@ func (e *Crypto) GenerateTotpKey( }) } -type GetTOTPSecret = func(ownerID int32) (DEKCiphertext, *exceptions.ServiceError) +type GetTOTPSecret = func(ownerID int64) (DEKCiphertext, *exceptions.ServiceError) type VerifyTotpCodeOptions struct { RequestID string Code string - OwnerID int32 + OwnerID int64 GetSecret GetTOTPSecret GetDecryptDEKFN GetDEKtoDecrypt GetEncryptDEKFN GetDEKtoEncrypt @@ -313,7 +313,7 @@ func (e *Crypto) VerifyTotpCode( GetDecryptDEKfn: opts.GetDecryptDEKFN, GetEncryptDEKfn: opts.GetEncryptDEKFN, Ciphertext: encSecret, - EntityID: strconv.Itoa(int(opts.OwnerID)), + EntityID: strconv.FormatInt(opts.OwnerID, 10), StoreReEncryptedDataFn: opts.StoreFN, }, ) @@ -325,14 +325,14 @@ func (e *Crypto) VerifyTotpCode( return totp.Validate(opts.Code, secret), nil } -type GetTOTPRecoveryCodes = func(ownerID int32) ([]byte, *exceptions.ServiceError) +type GetTOTPRecoveryCodes = func(ownerID int64) ([]byte, *exceptions.ServiceError) type VerifyTotpRecoveryCodeOptions struct { RequestID string Issuer string Email string RecoveryCode string - OwnerID int32 + OwnerID int64 GetCodes GetTOTPRecoveryCodes GetDEKfn GetDEKtoEncrypt StoreTOTPfn StoreTOTP diff --git a/idp/internal/providers/database/account_2fa_configs.sql.go b/idp/internal/providers/database/account_2fa_configs.sql.go index fdebe54..4a07ccc 100644 --- a/idp/internal/providers/database/account_2fa_configs.sql.go +++ b/idp/internal/providers/database/account_2fa_configs.sql.go @@ -17,7 +17,7 @@ WHERE "account_id" = $1 LIMIT 1 ` -func (q *Queries) CountAccount2FAConfigsByAccountID(ctx context.Context, accountID int32) (int64, error) { +func (q *Queries) CountAccount2FAConfigsByAccountID(ctx context.Context, accountID int64) (int64, error) { row := q.db.QueryRow(ctx, countAccount2FAConfigsByAccountID, accountID) var count int64 err := row.Scan(&count) @@ -40,7 +40,7 @@ INSERT INTO "account_2fa_configs" ( ` type CreateAccount2FAConfigParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID TwoFactorType TwoFactorType IsDefault bool @@ -77,7 +77,7 @@ DELETE FROM "account_2fa_configs" WHERE "id" = $1 ` -func (q *Queries) DeleteAccount2FAConfig(ctx context.Context, id int32) error { +func (q *Queries) DeleteAccount2FAConfig(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteAccount2FAConfig, id) return err } @@ -175,7 +175,7 @@ RETURNING id, account_id, account_public_id, two_factor_type, is_default, is_act ` type UpdateAccount2FAConfigParams struct { - ID int32 + ID int64 IsDefault bool } diff --git a/idp/internal/providers/database/account_credential_secrets.sql.go b/idp/internal/providers/database/account_credential_secrets.sql.go index f4a5e09..aaf5ee2 100644 --- a/idp/internal/providers/database/account_credential_secrets.sql.go +++ b/idp/internal/providers/database/account_credential_secrets.sql.go @@ -18,7 +18,7 @@ WHERE "acs"."account_credentials_id" = $1 LIMIT 1 ` -func (q *Queries) CountAccountCredentialSecretsByAccountCredentialID(ctx context.Context, accountCredentialsID int32) (int64, error) { +func (q *Queries) CountAccountCredentialSecretsByAccountCredentialID(ctx context.Context, accountCredentialsID int64) (int64, error) { row := q.db.QueryRow(ctx, countAccountCredentialSecretsByAccountCredentialID, accountCredentialsID) var count int64 err := row.Scan(&count) @@ -43,9 +43,9 @@ INSERT INTO "account_credentials_secrets" ( ` type CreateAccountCredentialSecretParams struct { - AccountCredentialsID int32 - CredentialsSecretID int32 - AccountID int32 + AccountCredentialsID int64 + CredentialsSecretID int64 + AccountID int64 AccountPublicID uuid.UUID SecretID string } @@ -76,7 +76,7 @@ LIMIT 1 ` type FindAccountCredentialSecretByAccountCredentialIDAndCredentialsSecretIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 SecretID string } @@ -108,7 +108,7 @@ LIMIT 1 ` type FindAccountCredentialsSecretAccountByAccountCredentialIDAndSecretIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 SecretID string } @@ -144,7 +144,7 @@ ORDER BY "csr"."created_at" DESC, "csr"."id" DESC LIMIT 1 ` -func (q *Queries) FindCurrentAccountCredentialSecretByAccountCredentialID(ctx context.Context, accountCredentialsID int32) (CredentialsSecret, error) { +func (q *Queries) FindCurrentAccountCredentialSecretByAccountCredentialID(ctx context.Context, accountCredentialsID int64) (CredentialsSecret, error) { row := q.db.QueryRow(ctx, findCurrentAccountCredentialSecretByAccountCredentialID, accountCredentialsID) var i CredentialsSecret err := row.Scan( @@ -171,7 +171,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedAccountCredentialSecretsByAccountCredentialIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 Offset int32 Limit int32 } @@ -219,7 +219,7 @@ LIMIT 1 ` type FindValidAccountCredentialSecretByAccountCredentialIDAndCredentialsSecretIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 SecretID string } @@ -247,7 +247,7 @@ UPDATE "credentials_secrets" SET WHERE "id" = $1 ` -func (q *Queries) RevokeAccountCredentialSecret(ctx context.Context, id int32) error { +func (q *Queries) RevokeAccountCredentialSecret(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, revokeAccountCredentialSecret, id) return err } diff --git a/idp/internal/providers/database/account_credentials.sql.go b/idp/internal/providers/database/account_credentials.sql.go index f72c731..f7bebc5 100644 --- a/idp/internal/providers/database/account_credentials.sql.go +++ b/idp/internal/providers/database/account_credentials.sql.go @@ -49,7 +49,7 @@ WHERE "account_id" = $1 AND "client_name" = $2 ` type CountAccountCredentialsByNameAndAccountIDParams struct { - AccountID int32 + AccountID int64 ClientName string } @@ -145,7 +145,7 @@ INSERT INTO "account_credentials" ( ` type CreateAccountCredentialsParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID Domain string CreationMethod CreationMethod @@ -303,7 +303,7 @@ DELETE FROM grants WHERE account_id = $1 AND granted_client_id = $2 ` type DeleteRegisteredAccountCredentialsGrantsParams struct { - AccountID int32 + AccountID int64 GrantedClientID string } @@ -587,7 +587,7 @@ UPDATE credentials_keys SET is_revoked = true, updated_at = now() WHERE id IN (SELECT credentials_key_id FROM account_credentials_keys WHERE account_credentials_id = $1) ` -func (q *Queries) RevokeRegisteredAccountCredentialsKeys(ctx context.Context, accountCredentialsID int32) error { +func (q *Queries) RevokeRegisteredAccountCredentialsKeys(ctx context.Context, accountCredentialsID int64) error { _, err := q.db.Exec(ctx, revokeRegisteredAccountCredentialsKeys, accountCredentialsID) return err } @@ -597,7 +597,7 @@ UPDATE credentials_secrets SET is_revoked = true, updated_at = now() WHERE id IN (SELECT credentials_secret_id FROM account_credentials_secrets WHERE account_credentials_id = $1) ` -func (q *Queries) RevokeRegisteredAccountCredentialsSecrets(ctx context.Context, accountCredentialsID int32) error { +func (q *Queries) RevokeRegisteredAccountCredentialsSecrets(ctx context.Context, accountCredentialsID int64) error { _, err := q.db.Exec(ctx, revokeRegisteredAccountCredentialsSecrets, accountCredentialsID) return err } @@ -607,7 +607,7 @@ UPDATE account_credentials SET registration_token_jti = $2, software_statement = ` type SetAccountCredentialsRegistrationStateParams struct { - ID int32 + ID int64 RegistrationTokenJti pgtype.UUID SoftwareStatement string } @@ -636,7 +636,7 @@ RETURNING registration_token_jti, software_statement, id, account_id, account_pu ` type UpdateAccountCredentialsParams struct { - ID int32 + ID int64 Scopes []AccountCredentialsScope ClientName string Domain string @@ -757,7 +757,7 @@ RETURNING registration_token_jti, software_statement, id, account_id, account_pu ` type UpdateRegisteredAccountCredentialsParams struct { - ID int32 + ID int64 Domain string RedirectUris []string TokenEndpointAuthMethod AuthMethod diff --git a/idp/internal/providers/database/account_credentials_keys.sql.go b/idp/internal/providers/database/account_credentials_keys.sql.go index 4d3ef43..63101b7 100644 --- a/idp/internal/providers/database/account_credentials_keys.sql.go +++ b/idp/internal/providers/database/account_credentials_keys.sql.go @@ -18,7 +18,7 @@ WHERE "ack"."account_credentials_id" = $1 LIMIT 1 ` -func (q *Queries) CountAccountCredentialKeysByAccountCredentialID(ctx context.Context, accountCredentialsID int32) (int64, error) { +func (q *Queries) CountAccountCredentialKeysByAccountCredentialID(ctx context.Context, accountCredentialsID int64) (int64, error) { row := q.db.QueryRow(ctx, countAccountCredentialKeysByAccountCredentialID, accountCredentialsID) var count int64 err := row.Scan(&count) @@ -43,9 +43,9 @@ INSERT INTO "account_credentials_keys" ( ` type CreateAccountCredentialKeyParams struct { - AccountCredentialsID int32 - CredentialsKeyID int32 - AccountID int32 + AccountCredentialsID int64 + CredentialsKeyID int64 + AccountID int64 AccountPublicID uuid.UUID JwkKid string } @@ -76,7 +76,7 @@ LIMIT 1 ` type FindAccountCredentialKeyByAccountCredentialIDAndPublicKIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 PublicKid string } @@ -111,7 +111,7 @@ LIMIT 1 ` type FindAccountCredentialsKeyAccountByAccountCredentialIDAndJWKKIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 JwkKid string } @@ -191,7 +191,7 @@ ORDER BY "ckr"."created_at" DESC, "ckr"."id" DESC LIMIT 1 ` -func (q *Queries) FindCurrentAccountCredentialKeyByAccountCredentialID(ctx context.Context, accountCredentialsID int32) (CredentialsKey, error) { +func (q *Queries) FindCurrentAccountCredentialKeyByAccountCredentialID(ctx context.Context, accountCredentialsID int64) (CredentialsKey, error) { row := q.db.QueryRow(ctx, findCurrentAccountCredentialKeyByAccountCredentialID, accountCredentialsID) var i CredentialsKey err := row.Scan( @@ -221,7 +221,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedAccountCredentialKeysByAccountCredentialIDParams struct { - AccountCredentialsID int32 + AccountCredentialsID int64 Offset int32 Limit int32 } diff --git a/idp/internal/providers/database/account_data_encryption_keys.sql.go b/idp/internal/providers/database/account_data_encryption_keys.sql.go index 4a72de4..1f2362c 100644 --- a/idp/internal/providers/database/account_data_encryption_keys.sql.go +++ b/idp/internal/providers/database/account_data_encryption_keys.sql.go @@ -22,8 +22,8 @@ INSERT INTO "account_data_encryption_keys" ( ` type CreateAccountDataEncryptionKeyParams struct { - AccountID int32 - DataEncryptionKeyID int32 + AccountID int64 + DataEncryptionKeyID int64 } // Copyright (c) 2025 Afonso Barracha @@ -44,7 +44,7 @@ LIMIT 1 ` type FindAccountDataEncryptionKeyByAccountIDParams struct { - AccountID int32 + AccountID int64 ExpiresAt time.Time } @@ -73,7 +73,7 @@ LIMIT 1 ` type FindAccountDataEncryptionKeyByAccountIDAndKIDParams struct { - AccountID int32 + AccountID int64 Kid string } diff --git a/idp/internal/providers/database/account_dynamic_registration_configs.sql.go b/idp/internal/providers/database/account_dynamic_registration_configs.sql.go index 5ad6bff..ffdcddb 100644 --- a/idp/internal/providers/database/account_dynamic_registration_configs.sql.go +++ b/idp/internal/providers/database/account_dynamic_registration_configs.sql.go @@ -31,7 +31,7 @@ INSERT INTO "account_dynamic_registration_configs" ( ` type CreateAccountDynamicRegistrationConfigParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID AccountCredentialsTypes []AccountCredentialsType RequireSoftwareStatementCredentialTypes []AccountCredentialsType @@ -70,7 +70,7 @@ const deleteAccountDynamicRegistrationConfig = `-- name: DeleteAccountDynamicReg DELETE FROM "account_dynamic_registration_configs" WHERE "id" = $1 ` -func (q *Queries) DeleteAccountDynamicRegistrationConfig(ctx context.Context, id int32) error { +func (q *Queries) DeleteAccountDynamicRegistrationConfig(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteAccountDynamicRegistrationConfig, id) return err } @@ -80,7 +80,7 @@ SELECT id, account_id, account_public_id, account_credentials_types, require_sof WHERE "account_id" = $1 LIMIT 1 ` -func (q *Queries) FindAccountDynamicRegistrationConfigByAccountID(ctx context.Context, accountID int32) (AccountDynamicRegistrationConfig, error) { +func (q *Queries) FindAccountDynamicRegistrationConfigByAccountID(ctx context.Context, accountID int64) (AccountDynamicRegistrationConfig, error) { row := q.db.QueryRow(ctx, findAccountDynamicRegistrationConfigByAccountID, accountID) var i AccountDynamicRegistrationConfig err := row.Scan( @@ -129,7 +129,7 @@ RETURNING id, account_id, account_public_id, account_credentials_types, require_ ` type UpdateAccountDynamicRegistrationConfigParams struct { - ID int32 + ID int64 AccountCredentialsTypes []AccountCredentialsType RequireSoftwareStatementCredentialTypes []AccountCredentialsType SoftwareStatementVerificationMethods []SoftwareStatementVerificationMethod diff --git a/idp/internal/providers/database/account_grants.sql.go b/idp/internal/providers/database/account_grants.sql.go index d286361..51b762d 100644 --- a/idp/internal/providers/database/account_grants.sql.go +++ b/idp/internal/providers/database/account_grants.sql.go @@ -29,11 +29,11 @@ INSERT INTO "account_grants" ( ` type CreateAccountGrantWithAccountCredentialsParams struct { - AccountID int32 + AccountID int64 AccountVersion int32 - GrantID int32 + GrantID int64 GrantedClientID string - AccountCredentialsID pgtype.Int4 + AccountCredentialsID pgtype.Int8 } func (q *Queries) CreateAccountGrantWithAccountCredentials(ctx context.Context, arg CreateAccountGrantWithAccountCredentialsParams) error { @@ -63,9 +63,9 @@ INSERT INTO "account_grants" ( ` type CreateAccountGrantWithoutAccountCredentialsParams struct { - AccountID int32 + AccountID int64 AccountVersion int32 - GrantID int32 + GrantID int64 GrantedClientID string } @@ -94,22 +94,22 @@ LIMIT 1 ` type FindAccountGrantByAccountIDAndGrantedClientIDParams struct { - AccountID int32 + AccountID int64 GrantedClientID string } type FindAccountGrantByAccountIDAndGrantedClientIDRow struct { - AccountID int32 + AccountID int64 AccountVersion int32 - GrantID int32 - AccountCredentialsID pgtype.Int4 + GrantID int64 + AccountCredentialsID pgtype.Int8 GrantedClientID string IsRevoked bool RevokedAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz CreatedAt time.Time - ID pgtype.Int4 - AccountID_2 pgtype.Int4 + ID pgtype.Int8 + AccountID_2 pgtype.Int8 GrantID_2 pgtype.UUID GrantedClientID_2 pgtype.Text GrantedScopes []Scopes diff --git a/idp/internal/providers/database/account_hmac_secrets.sql.go b/idp/internal/providers/database/account_hmac_secrets.sql.go index 5a4479a..a0c986a 100644 --- a/idp/internal/providers/database/account_hmac_secrets.sql.go +++ b/idp/internal/providers/database/account_hmac_secrets.sql.go @@ -28,7 +28,7 @@ INSERT INTO "account_hmac_secrets" ( ` type CreateAccountHMACSecretParams struct { - AccountID int32 + AccountID int64 SecretID string Secret string DekKid string @@ -40,7 +40,7 @@ type CreateAccountHMACSecretParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateAccountHMACSecret(ctx context.Context, arg CreateAccountHMACSecretParams) (int32, error) { +func (q *Queries) CreateAccountHMACSecret(ctx context.Context, arg CreateAccountHMACSecretParams) (int64, error) { row := q.db.QueryRow(ctx, createAccountHMACSecret, arg.AccountID, arg.SecretID, @@ -48,7 +48,7 @@ func (q *Queries) CreateAccountHMACSecret(ctx context.Context, arg CreateAccount arg.DekKid, arg.ExpiresAt, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -60,7 +60,7 @@ LIMIT 1 ` type FindAccountHMACSecretByAccountIDAndSecretIDParams struct { - AccountID int32 + AccountID int64 SecretID string } @@ -89,7 +89,7 @@ WHERE LIMIT 1 ` -func (q *Queries) FindValidHMACSecretByAccountID(ctx context.Context, accountID int32) (AccountHmacSecret, error) { +func (q *Queries) FindValidHMACSecretByAccountID(ctx context.Context, accountID int64) (AccountHmacSecret, error) { row := q.db.QueryRow(ctx, findValidHMACSecretByAccountID, accountID) var i AccountHmacSecret err := row.Scan( @@ -114,7 +114,7 @@ WHERE "id" = $1 ` type UpdateAccountHMACSecretParams struct { - ID int32 + ID int64 Secret string DekKid string } diff --git a/idp/internal/providers/database/account_key_encryption_keys.sql.go b/idp/internal/providers/database/account_key_encryption_keys.sql.go index 2904756..8a8ebd4 100644 --- a/idp/internal/providers/database/account_key_encryption_keys.sql.go +++ b/idp/internal/providers/database/account_key_encryption_keys.sql.go @@ -21,8 +21,8 @@ INSERT INTO "account_key_encryption_keys" ( ` type CreateAccountKeyEncryptionKeyParams struct { - AccountID int32 - KeyEncryptionKeyID int32 + AccountID int64 + KeyEncryptionKeyID int64 } // Copyright (c) 2025 Afonso Barracha @@ -42,7 +42,7 @@ WHERE "akek"."account_id" = $1 LIMIT 1 ` -func (q *Queries) FindAccountKeyEncryptionKeyByAccountID(ctx context.Context, accountID int32) (KeyEncryptionKey, error) { +func (q *Queries) FindAccountKeyEncryptionKeyByAccountID(ctx context.Context, accountID int64) (KeyEncryptionKey, error) { row := q.db.QueryRow(ctx, findAccountKeyEncryptionKeyByAccountID, accountID) var i KeyEncryptionKey err := row.Scan( diff --git a/idp/internal/providers/database/account_sessions.sql.go b/idp/internal/providers/database/account_sessions.sql.go index 53588ab..5f2a7d9 100644 --- a/idp/internal/providers/database/account_sessions.sql.go +++ b/idp/internal/providers/database/account_sessions.sql.go @@ -30,11 +30,11 @@ INSERT INTO "account_sessions" ( ` type CreateAccountSessionWithAccountCredentialsParams struct { - AccountID int32 + AccountID int64 AccountVersion int32 - SessionID int32 + SessionID int64 SessionUuid uuid.UUID - AccountCredentialsID pgtype.Int4 + AccountCredentialsID pgtype.Int8 } func (q *Queries) CreateAccountSessionWithAccountCredentials(ctx context.Context, arg CreateAccountSessionWithAccountCredentialsParams) error { @@ -64,9 +64,9 @@ INSERT INTO "account_sessions" ( ` type CreateAccountSessionWithoutAccountCredentialsParams struct { - AccountID int32 + AccountID int64 AccountVersion int32 - SessionID int32 + SessionID int64 SessionUuid uuid.UUID } @@ -91,8 +91,8 @@ WHERE "account_id" = $1 AND "session_id" = $2 ` type DeleteAccountSessionByAccountIDAndSessionIDParams struct { - AccountID int32 - SessionID int32 + AccountID int64 + SessionID int64 } func (q *Queries) DeleteAccountSessionByAccountIDAndSessionID(ctx context.Context, arg DeleteAccountSessionByAccountIDAndSessionIDParams) error { @@ -107,7 +107,7 @@ WHERE "a"."session_id" = "s"."id" AND "a"."account_id" = $1 ` -func (q *Queries) DeleteAllSessionsByAccountID(ctx context.Context, accountID int32) error { +func (q *Queries) DeleteAllSessionsByAccountID(ctx context.Context, accountID int64) error { _, err := q.db.Exec(ctx, deleteAllSessionsByAccountID, accountID) return err } @@ -122,20 +122,20 @@ LIMIT 1 ` type FindAccountSessionByAccountIDAndSessionUUIDParams struct { - AccountID int32 + AccountID int64 SessionUuid uuid.UUID } type FindAccountSessionByAccountIDAndSessionUUIDRow struct { - AccountID int32 + AccountID int64 AccountVersion int32 - SessionID int32 - AccountCredentialsID pgtype.Int4 + SessionID int64 + AccountCredentialsID pgtype.Int8 SessionUuid uuid.UUID CreatedAt time.Time - ID pgtype.Int4 - AccountID_2 pgtype.Int4 - GrantID pgtype.Int4 + ID pgtype.Int8 + AccountID_2 pgtype.Int8 + GrantID pgtype.Int8 SessionID_2 pgtype.UUID SessionType NullSessionType SessionClientID pgtype.Text diff --git a/idp/internal/providers/database/account_token_signing_keys.sql.go b/idp/internal/providers/database/account_token_signing_keys.sql.go index df0c23c..e8bd78f 100644 --- a/idp/internal/providers/database/account_token_signing_keys.sql.go +++ b/idp/internal/providers/database/account_token_signing_keys.sql.go @@ -21,8 +21,8 @@ INSERT INTO "account_token_signing_keys" ( ` type CreateAccountTokenSigningKeyParams struct { - AccountID int32 - TokenSigningKeyID int32 + AccountID int64 + TokenSigningKeyID int64 } // Copyright (c) 2025 Afonso Barracha @@ -46,7 +46,7 @@ WHERE "atsk"."account_id" = $1 AND ORDER BY "t"."id" DESC ` -func (q *Queries) FindAccountDistributedTokenSigningKeyPublicKeysByAccountID(ctx context.Context, accountID int32) ([][]byte, error) { +func (q *Queries) FindAccountDistributedTokenSigningKeyPublicKeysByAccountID(ctx context.Context, accountID int64) ([][]byte, error) { rows, err := q.db.Query(ctx, findAccountDistributedTokenSigningKeyPublicKeysByAccountID, accountID) if err != nil { return nil, err @@ -74,7 +74,7 @@ LIMIT 1 ` type FindAccountTokenSigningKeyByAccountIDParams struct { - AccountID int32 + AccountID int64 KeyType TokenKeyType } @@ -107,7 +107,7 @@ LIMIT 1 ` type FindAccountTokenSigningKeyByAccountIDAndKIDParams struct { - AccountID int32 + AccountID int64 Kid string } diff --git a/idp/internal/providers/database/account_totps.sql.go b/idp/internal/providers/database/account_totps.sql.go index 4596cf6..3023b3d 100644 --- a/idp/internal/providers/database/account_totps.sql.go +++ b/idp/internal/providers/database/account_totps.sql.go @@ -21,8 +21,8 @@ INSERT INTO "account_totps" ( ` type CreateAccountTotpParams struct { - AccountID int32 - TotpID int32 + AccountID int64 + TotpID int64 } // Copyright (c) 2025 Afonso Barracha @@ -40,7 +40,7 @@ DELETE FROM "account_totps" WHERE "account_id" = $1 ` -func (q *Queries) DeleteAccountRecoveryKeys(ctx context.Context, accountID int32) error { +func (q *Queries) DeleteAccountRecoveryKeys(ctx context.Context, accountID int64) error { _, err := q.db.Exec(ctx, deleteAccountRecoveryKeys, accountID) return err } @@ -53,7 +53,7 @@ WHERE LIMIT 1 ` -func (q *Queries) FindAccountTotpByAccountID(ctx context.Context, accountID int32) (Totp, error) { +func (q *Queries) FindAccountTotpByAccountID(ctx context.Context, accountID int64) (Totp, error) { row := q.db.QueryRow(ctx, findAccountTotpByAccountID, accountID) var i Totp err := row.Scan( diff --git a/idp/internal/providers/database/accounts.sql.go b/idp/internal/providers/database/accounts.sql.go index 25aa2e3..1f995a8 100644 --- a/idp/internal/providers/database/accounts.sql.go +++ b/idp/internal/providers/database/accounts.sql.go @@ -21,7 +21,7 @@ WHERE "id" = $1 RETURNING id, public_id, given_name, family_name, username, email, organization, password, version, email_verified, activity_status, created_at, updated_at ` -func (q *Queries) ConfirmAccount(ctx context.Context, id int32) (Account, error) { +func (q *Queries) ConfirmAccount(ctx context.Context, id int64) (Account, error) { row := q.db.QueryRow(ctx, confirmAccount, id) var i Account err := row.Scan( @@ -187,7 +187,7 @@ DELETE FROM "accounts" WHERE "id" = $1 ` -func (q *Queries) DeleteAccount(ctx context.Context, id int32) error { +func (q *Queries) DeleteAccount(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteAccount, id) return err } @@ -232,7 +232,7 @@ SELECT id, public_id, given_name, family_name, username, email, organization, pa WHERE "id" = $1 LIMIT 1 ` -func (q *Queries) FindAccountById(ctx context.Context, id int32) (Account, error) { +func (q *Queries) FindAccountById(ctx context.Context, id int64) (Account, error) { row := q.db.QueryRow(ctx, findAccountById, id) var i Account err := row.Scan( @@ -320,9 +320,9 @@ type FindAccountIDByPublicIDAndVersionParams struct { Version int32 } -func (q *Queries) FindAccountIDByPublicIDAndVersion(ctx context.Context, arg FindAccountIDByPublicIDAndVersionParams) (int32, error) { +func (q *Queries) FindAccountIDByPublicIDAndVersion(ctx context.Context, arg FindAccountIDByPublicIDAndVersionParams) (int64, error) { row := q.db.QueryRow(ctx, findAccountIDByPublicIDAndVersion, arg.PublicID, arg.Version) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -332,9 +332,9 @@ SELECT "id" FROM "accounts" WHERE "username" = $1 LIMIT 1 ` -func (q *Queries) FindAccountIDByUsername(ctx context.Context, username string) (int32, error) { +func (q *Queries) FindAccountIDByUsername(ctx context.Context, username string) (int64, error) { row := q.db.QueryRow(ctx, findAccountIDByUsername, username) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -351,7 +351,7 @@ RETURNING id, public_id, given_name, family_name, username, email, organization, type UpdateAccountParams struct { GivenName string FamilyName string - ID int32 + ID int64 } func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error) { @@ -386,7 +386,7 @@ RETURNING id, public_id, given_name, family_name, username, email, organization, type UpdateAccountEmailParams struct { Email string - ID int32 + ID int64 } func (q *Queries) UpdateAccountEmail(ctx context.Context, arg UpdateAccountEmailParams) (Account, error) { @@ -421,7 +421,7 @@ RETURNING id, public_id, given_name, family_name, username, email, organization, type UpdateAccountPasswordParams struct { Password pgtype.Text - ID int32 + ID int64 } func (q *Queries) UpdateAccountPassword(ctx context.Context, arg UpdateAccountPasswordParams) (Account, error) { @@ -456,7 +456,7 @@ RETURNING id, public_id, given_name, family_name, username, email, organization, type UpdateAccountUsernameParams struct { Username string - ID int32 + ID int64 } func (q *Queries) UpdateAccountUsername(ctx context.Context, arg UpdateAccountUsernameParams) (Account, error) { @@ -488,7 +488,7 @@ WHERE "id" = $1 RETURNING id, public_id, given_name, family_name, username, email, organization, password, version, email_verified, activity_status, created_at, updated_at ` -func (q *Queries) UpdateAccountVersion(ctx context.Context, id int32) (Account, error) { +func (q *Queries) UpdateAccountVersion(ctx context.Context, id int64) (Account, error) { row := q.db.QueryRow(ctx, updateAccountVersion, id) var i Account err := row.Scan( diff --git a/idp/internal/providers/database/app_designs.sql.go b/idp/internal/providers/database/app_designs.sql.go index 748ac38..abcd3be 100644 --- a/idp/internal/providers/database/app_designs.sql.go +++ b/idp/internal/providers/database/app_designs.sql.go @@ -16,7 +16,7 @@ SELECT COUNT(*) FROM "app_designs" WHERE "app_id" = $1 LIMIT 1 ` -func (q *Queries) CountAppDesignsByAppID(ctx context.Context, appID int32) (int64, error) { +func (q *Queries) CountAppDesignsByAppID(ctx context.Context, appID int64) (int64, error) { row := q.db.QueryRow(ctx, countAppDesignsByAppID, appID) var count int64 err := row.Scan(&count) @@ -43,8 +43,8 @@ INSERT INTO "app_designs" ( ` type CreateAppDesignParams struct { - AccountID int32 - AppID int32 + AccountID int64 + AppID int64 LightColors []byte DarkColors []byte LogoUrl pgtype.Text @@ -93,7 +93,7 @@ const deleteAppDesign = `-- name: DeleteAppDesign :exec DELETE FROM "app_designs" WHERE "id" = $1 ` -func (q *Queries) DeleteAppDesign(ctx context.Context, id int32) error { +func (q *Queries) DeleteAppDesign(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteAppDesign, id) return err } @@ -103,7 +103,7 @@ SELECT id, account_id, app_id, light_colors, dark_colors, logo_url, favicon_url, LIMIT 1 ` -func (q *Queries) FindAppDesignByAppID(ctx context.Context, appID int32) (AppDesign, error) { +func (q *Queries) FindAppDesignByAppID(ctx context.Context, appID int64) (AppDesign, error) { row := q.db.QueryRow(ctx, findAppDesignByAppID, appID) var i AppDesign err := row.Scan( @@ -135,7 +135,7 @@ type UpdateAppDesignParams struct { DarkColors []byte LogoUrl pgtype.Text FaviconUrl pgtype.Text - ID int32 + ID int64 } func (q *Queries) UpdateAppDesign(ctx context.Context, arg UpdateAppDesignParams) (AppDesign, error) { diff --git a/idp/internal/providers/database/app_dynamic_registration_configs.sql.go b/idp/internal/providers/database/app_dynamic_registration_configs.sql.go index 4d0e9d7..ac026a8 100644 --- a/idp/internal/providers/database/app_dynamic_registration_configs.sql.go +++ b/idp/internal/providers/database/app_dynamic_registration_configs.sql.go @@ -57,7 +57,7 @@ INSERT INTO "app_dynamic_registration_configs" ( ` type CreateAppDynamicRegistrationConfigParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID AllowedAppTypes []AppType DefaultAllowUserRegistration bool @@ -137,7 +137,7 @@ const deleteAppDynamicRegistrationConfig = `-- name: DeleteAppDynamicRegistratio DELETE FROM "app_dynamic_registration_configs" WHERE "id" = $1 ` -func (q *Queries) DeleteAppDynamicRegistrationConfig(ctx context.Context, id int32) error { +func (q *Queries) DeleteAppDynamicRegistrationConfig(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteAppDynamicRegistrationConfig, id) return err } @@ -147,7 +147,7 @@ SELECT id, account_id, account_public_id, allowed_app_types, default_allow_user_ WHERE "account_id" = $1 LIMIT 1 ` -func (q *Queries) FindAppDynamicRegistrationConfigByAccountID(ctx context.Context, accountID int32) (AppDynamicRegistrationConfig, error) { +func (q *Queries) FindAppDynamicRegistrationConfigByAccountID(ctx context.Context, accountID int64) (AppDynamicRegistrationConfig, error) { row := q.db.QueryRow(ctx, findAppDynamicRegistrationConfigByAccountID, accountID) var i AppDynamicRegistrationConfig err := row.Scan( @@ -236,7 +236,7 @@ RETURNING id, account_id, account_public_id, allowed_app_types, default_allow_us ` type UpdateAppDynamicRegistrationConfigParams struct { - ID int32 + ID int64 AllowedAppTypes []AppType DefaultAllowUserRegistration bool DefaultAuthProviders []AuthProvider diff --git a/idp/internal/providers/database/app_keys.sql.go b/idp/internal/providers/database/app_keys.sql.go index 07c9085..7e82d1a 100644 --- a/idp/internal/providers/database/app_keys.sql.go +++ b/idp/internal/providers/database/app_keys.sql.go @@ -16,7 +16,7 @@ WHERE "ak"."app_id" = $1 LIMIT 1 ` -func (q *Queries) CountAppKeysByAppID(ctx context.Context, appID int32) (int64, error) { +func (q *Queries) CountAppKeysByAppID(ctx context.Context, appID int64) (int64, error) { row := q.db.QueryRow(ctx, countAppKeysByAppID, appID) var count int64 err := row.Scan(&count) @@ -37,9 +37,9 @@ INSERT INTO "app_keys" ( ` type CreateAppKeyParams struct { - AppID int32 - CredentialsKeyID int32 - AccountID int32 + AppID int64 + CredentialsKeyID int64 + AccountID int64 } // Copyright (c) 2025 Afonso Barracha @@ -62,7 +62,7 @@ LIMIT 1 ` type FindAppKeyByAppIDAndPublicKIDParams struct { - AppID int32 + AppID int64 PublicKid string } @@ -93,7 +93,7 @@ WHERE a.app_id = $1 AND NOT c.is_revoked AND c.expires_at > now() ORDER BY c.created_at DESC, c.id DESC LIMIT 1 ` -func (q *Queries) FindCurrentAppKey(ctx context.Context, appID int32) (CredentialsKey, error) { +func (q *Queries) FindCurrentAppKey(ctx context.Context, appID int64) (CredentialsKey, error) { row := q.db.QueryRow(ctx, findCurrentAppKey, appID) var i CredentialsKey err := row.Scan( @@ -123,7 +123,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedAppKeysByAppIDParams struct { - AppID int32 + AppID int64 Offset int32 Limit int32 } diff --git a/idp/internal/providers/database/app_profiles.sql.go b/idp/internal/providers/database/app_profiles.sql.go index 703b435..42fcec7 100644 --- a/idp/internal/providers/database/app_profiles.sql.go +++ b/idp/internal/providers/database/app_profiles.sql.go @@ -25,9 +25,9 @@ INSERT INTO "app_profiles" ( ` type CreateAppProfileParams struct { - AccountID int32 - UserID int32 - AppID int32 + AccountID int64 + UserID int64 + AppID int64 ProfileType AppProfileType } @@ -52,8 +52,8 @@ WHERE "app_id" = $1 AND "user_id" = $2 ` type FindAppProfileByAppIDAndUserIDParams struct { - AppID int32 - UserID int32 + AppID int64 + UserID int64 } func (q *Queries) FindAppProfileByAppIDAndUserID(ctx context.Context, arg FindAppProfileByAppIDAndUserIDParams) (AppProfile, error) { diff --git a/idp/internal/providers/database/app_secrets.sql.go b/idp/internal/providers/database/app_secrets.sql.go index 4c8befe..7825bcc 100644 --- a/idp/internal/providers/database/app_secrets.sql.go +++ b/idp/internal/providers/database/app_secrets.sql.go @@ -16,7 +16,7 @@ WHERE "as"."app_id" = $1 LIMIT 1 ` -func (q *Queries) CountAppSecretsByAppID(ctx context.Context, appID int32) (int64, error) { +func (q *Queries) CountAppSecretsByAppID(ctx context.Context, appID int64) (int64, error) { row := q.db.QueryRow(ctx, countAppSecretsByAppID, appID) var count int64 err := row.Scan(&count) @@ -37,9 +37,9 @@ INSERT INTO "app_secrets" ( ` type CreateAppSecretParams struct { - AppID int32 - CredentialsSecretID int32 - AccountID int32 + AppID int64 + CredentialsSecretID int64 + AccountID int64 } // Copyright (c) 2025 Afonso Barracha @@ -62,7 +62,7 @@ LIMIT 1 ` type FindAppSecretByAppIDAndSecretIDParams struct { - AppID int32 + AppID int64 SecretID string } @@ -90,7 +90,7 @@ WHERE a.app_id = $1 AND NOT c.is_revoked AND c.expires_at > now() ORDER BY c.created_at DESC, c.id DESC LIMIT 1 ` -func (q *Queries) FindCurrentAppSecret(ctx context.Context, appID int32) (CredentialsSecret, error) { +func (q *Queries) FindCurrentAppSecret(ctx context.Context, appID int64) (CredentialsSecret, error) { row := q.db.QueryRow(ctx, findCurrentAppSecret, appID) var i CredentialsSecret err := row.Scan( @@ -117,7 +117,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedAppSecretsByAppIDParams struct { - AppID int32 + AppID int64 Offset int32 Limit int32 } diff --git a/idp/internal/providers/database/apps.sql.go b/idp/internal/providers/database/apps.sql.go index b1cbf9f..f8dbc1c 100644 --- a/idp/internal/providers/database/apps.sql.go +++ b/idp/internal/providers/database/apps.sql.go @@ -19,7 +19,7 @@ LIMIT 1 ` type CountAppsByAccountIDAndCliantNameOrSoftwareIDParams struct { - AccountID int32 + AccountID int64 ClientName string SoftwareID pgtype.Text } @@ -38,7 +38,7 @@ LIMIT 1 ` type CountAppsByAccountIDAndNameParams struct { - AccountID int32 + AccountID int64 ClientName string } @@ -199,7 +199,7 @@ INSERT INTO "apps" ( ` type CreateAppParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID AppType AppType ClientName string @@ -340,7 +340,7 @@ DELETE FROM "apps" WHERE "id" = $1 ` -func (q *Queries) DeleteApp(ctx context.Context, id int32) error { +func (q *Queries) DeleteApp(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteApp, id) return err } @@ -350,7 +350,7 @@ DELETE FROM grants WHERE account_id = $1 AND granted_client_id = $2 ` type DeleteRegisteredAppGrantsParams struct { - AccountID int32 + AccountID int64 GrantedClientID string } @@ -1175,7 +1175,7 @@ SELECT registration_token_jti, software_statement, id, account_id, account_publi WHERE "id" = $1 LIMIT 1 ` -func (q *Queries) FindAppByID(ctx context.Context, id int32) (App, error) { +func (q *Queries) FindAppByID(ctx context.Context, id int64) (App, error) { row := q.db.QueryRow(ctx, findAppByID, id) var i App err := row.Scan( @@ -1247,7 +1247,7 @@ ORDER BY "client_name" ASC LIMIT $2 ` type FindAppsByClientIDsAndAccountIDParams struct { - AccountID int32 + AccountID int64 Limit int32 ClientIds []string } @@ -1591,7 +1591,7 @@ UPDATE credentials_keys SET is_revoked = true, updated_at = now() WHERE id IN (SELECT credentials_key_id FROM app_keys WHERE app_id = $1) ` -func (q *Queries) RevokeRegisteredAppKeys(ctx context.Context, appID int32) error { +func (q *Queries) RevokeRegisteredAppKeys(ctx context.Context, appID int64) error { _, err := q.db.Exec(ctx, revokeRegisteredAppKeys, appID) return err } @@ -1601,7 +1601,7 @@ UPDATE credentials_secrets SET is_revoked = true, updated_at = now() WHERE id IN (SELECT credentials_secret_id FROM app_secrets WHERE app_id = $1) ` -func (q *Queries) RevokeRegisteredAppSecrets(ctx context.Context, appID int32) error { +func (q *Queries) RevokeRegisteredAppSecrets(ctx context.Context, appID int64) error { _, err := q.db.Exec(ctx, revokeRegisteredAppSecrets, appID) return err } @@ -1611,7 +1611,7 @@ UPDATE apps SET registration_token_jti = $2, software_statement = $3 WHERE id = ` type SetAppRegistrationStateParams struct { - ID int32 + ID int64 RegistrationTokenJti pgtype.UUID SoftwareStatement string } @@ -1643,7 +1643,7 @@ RETURNING registration_token_jti, software_statement, id, account_id, account_pu ` type UpdateAppParams struct { - ID int32 + ID int64 ClientName string UsernameColumn AppUsernameColumn ClientUri string @@ -1752,7 +1752,7 @@ RETURNING registration_token_jti, software_statement, id, account_id, account_pu ` type UpdateAppScopesParams struct { - ID int32 + ID int64 Scopes []Scopes DefaultScopes []Scopes CustomScopes []string @@ -1838,7 +1838,7 @@ WHERE "id" = $1 RETURNING registration_token_jti, software_statement, id, account_id, account_public_id, client_id, version, creation_method, redirect_uris, token_endpoint_auth_method, grant_types, response_types, client_name, client_uri, logo_uri, scopes, custom_scopes, contacts, tos_uri, policy_uri, jwks_uri, jwks, software_id, software_version, domain, allow_user_registration, auth_providers, username_column, default_scopes, default_custom_scopes, app_type, sector_identifier_uri, subject_type, id_token_signed_response_alg, id_token_encrypted_response_alg, id_token_encrypted_response_enc, userinfo_signed_response_alg, userinfo_encrypted_response_alg, userinfo_encrypted_response_enc, request_object_signing_alg, request_object_encryption_alg, request_object_encryption_enc, token_endpoint_auth_signing_alg, default_max_age, require_auth_time, default_acr_values, initiate_login_uri, request_uris, access_token_signing_alg, session_type, access_token_ttl, id_token_ttl, refresh_token_idle_ttl, refresh_token_ttl, grant_ttl, created_at, updated_at ` -func (q *Queries) UpdateAppVersion(ctx context.Context, id int32) (App, error) { +func (q *Queries) UpdateAppVersion(ctx context.Context, id int64) (App, error) { row := q.db.QueryRow(ctx, updateAppVersion, id) var i App err := row.Scan( diff --git a/idp/internal/providers/database/credentials_keys.sql.go b/idp/internal/providers/database/credentials_keys.sql.go index 948631e..fd22a18 100644 --- a/idp/internal/providers/database/credentials_keys.sql.go +++ b/idp/internal/providers/database/credentials_keys.sql.go @@ -34,7 +34,7 @@ INSERT INTO "credentials_keys" ( ` type CreateCredentialsKeyParams struct { - AccountID int32 + AccountID int64 PublicKid string PublicKey []byte PrivateKey string @@ -94,7 +94,7 @@ WHERE "id" = $1 LIMIT 1 ` -func (q *Queries) FindCredentialsKeyByID(ctx context.Context, id int32) (CredentialsKey, error) { +func (q *Queries) FindCredentialsKeyByID(ctx context.Context, id int64) (CredentialsKey, error) { row := q.db.QueryRow(ctx, findCredentialsKeyByID, id) var i CredentialsKey err := row.Scan( @@ -147,7 +147,7 @@ WHERE "id" = $1 RETURNING id, public_kid, public_key, private_key, dek_kid, crypto_suite, is_revoked, is_external, usage, account_id, expires_at, created_at, updated_at ` -func (q *Queries) RevokeCredentialsKey(ctx context.Context, id int32) (CredentialsKey, error) { +func (q *Queries) RevokeCredentialsKey(ctx context.Context, id int64) (CredentialsKey, error) { row := q.db.QueryRow(ctx, revokeCredentialsKey, id) var i CredentialsKey err := row.Scan( @@ -192,7 +192,7 @@ UPDATE credentials_keys SET private_key = $2, dek_kid = $3 WHERE id = $1 ` type UpdateCredentialsKeyPrivateKeyParams struct { - ID int32 + ID int64 PrivateKey string DekKid string } diff --git a/idp/internal/providers/database/credentials_secrets.sql.go b/idp/internal/providers/database/credentials_secrets.sql.go index 2d42378..a1c5f9a 100644 --- a/idp/internal/providers/database/credentials_secrets.sql.go +++ b/idp/internal/providers/database/credentials_secrets.sql.go @@ -30,7 +30,7 @@ INSERT INTO "credentials_secrets" ( ` type CreateCredentialsSecretParams struct { - AccountID int32 + AccountID int64 SecretID string ClientSecret string DekKid string @@ -43,7 +43,7 @@ type CreateCredentialsSecretParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateCredentialsSecret(ctx context.Context, arg CreateCredentialsSecretParams) (int32, error) { +func (q *Queries) CreateCredentialsSecret(ctx context.Context, arg CreateCredentialsSecretParams) (int64, error) { row := q.db.QueryRow(ctx, createCredentialsSecret, arg.AccountID, arg.SecretID, @@ -52,7 +52,7 @@ func (q *Queries) CreateCredentialsSecret(ctx context.Context, arg CreateCredent arg.ExpiresAt, arg.Usage, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -101,7 +101,7 @@ WHERE "id" = $1 RETURNING id, secret_id, client_secret, dek_kid, is_revoked, usage, account_id, expires_at, created_at, updated_at ` -func (q *Queries) RevokeCredentialsSecret(ctx context.Context, id int32) (CredentialsSecret, error) { +func (q *Queries) RevokeCredentialsSecret(ctx context.Context, id int64) (CredentialsSecret, error) { row := q.db.QueryRow(ctx, revokeCredentialsSecret, id) var i CredentialsSecret err := row.Scan( @@ -128,7 +128,7 @@ WHERE "id" = $1 ` type UpdateCredentialsSecretClientSecretParams struct { - ID int32 + ID int64 ClientSecret string DekKid string } diff --git a/idp/internal/providers/database/data_encryption_keys.sql.go b/idp/internal/providers/database/data_encryption_keys.sql.go index 6ace41b..6dcdf3b 100644 --- a/idp/internal/providers/database/data_encryption_keys.sql.go +++ b/idp/internal/providers/database/data_encryption_keys.sql.go @@ -121,7 +121,7 @@ UPDATE "data_encryption_keys" SET WHERE "id" = $1 ` -func (q *Queries) RevokeDataEncryptionKey(ctx context.Context, id int32) error { +func (q *Queries) RevokeDataEncryptionKey(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, revokeDataEncryptionKey, id) return err } diff --git a/idp/internal/providers/database/dynamic_registration_domain_codes.sql.go b/idp/internal/providers/database/dynamic_registration_domain_codes.sql.go index 468714e..4956feb 100644 --- a/idp/internal/providers/database/dynamic_registration_domain_codes.sql.go +++ b/idp/internal/providers/database/dynamic_registration_domain_codes.sql.go @@ -32,8 +32,8 @@ INSERT INTO "dynamic_registration_domain_codes" ( ` type CreateDynamicRegistrationDomainCodeParams struct { - AccountID int32 - DynamicRegistrationDomainID int32 + AccountID int64 + DynamicRegistrationDomainID int64 VerificationHost string VerificationCode string VerificationPrefix string @@ -64,7 +64,7 @@ DELETE FROM "dynamic_registration_domain_codes" WHERE "id" = $1 ` -func (q *Queries) DeleteDynamicRegistrationDomainCode(ctx context.Context, id int32) error { +func (q *Queries) DeleteDynamicRegistrationDomainCode(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteDynamicRegistrationDomainCode, id) return err } @@ -74,7 +74,7 @@ SELECT id, account_id, dynamic_registration_domain_id, verification_host, verifi WHERE "dynamic_registration_domain_id" = $1 ` -func (q *Queries) FindDynamicRegistrationDomainCodeByDynamicRegistrationDomainID(ctx context.Context, dynamicRegistrationDomainID int32) (DynamicRegistrationDomainCode, error) { +func (q *Queries) FindDynamicRegistrationDomainCodeByDynamicRegistrationDomainID(ctx context.Context, dynamicRegistrationDomainID int64) (DynamicRegistrationDomainCode, error) { row := q.db.QueryRow(ctx, findDynamicRegistrationDomainCodeByDynamicRegistrationDomainID, dynamicRegistrationDomainID) var i DynamicRegistrationDomainCode err := row.Scan( @@ -103,7 +103,7 @@ WHERE "id" = $1 ` type UpdateDynamicRegistrationDomainCodeParams struct { - ID int32 + ID int64 VerificationHost string VerificationCode string VerificationPrefix string diff --git a/idp/internal/providers/database/dynamic_registration_domains.sql.go b/idp/internal/providers/database/dynamic_registration_domains.sql.go index a6f7512..f0a5f50 100644 --- a/idp/internal/providers/database/dynamic_registration_domains.sql.go +++ b/idp/internal/providers/database/dynamic_registration_domains.sql.go @@ -285,7 +285,7 @@ INSERT INTO "dynamic_registration_domains" ( ` type CreateDynamicRegistrationDomainParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID Domain string VerificationMethod DomainVerificationMethod @@ -325,7 +325,7 @@ DELETE FROM "dynamic_registration_domains" WHERE "id" = $1 ` -func (q *Queries) DeleteDynamicRegistrationDomain(ctx context.Context, id int32) error { +func (q *Queries) DeleteDynamicRegistrationDomain(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteDynamicRegistrationDomain, id) return err } @@ -553,7 +553,7 @@ WHERE "id" = $1 RETURNING id, account_id, account_public_id, domain, verified_at ` type VerifyDynamicRegistrationDomainParams struct { - ID int32 + ID int64 VerificationMethod DomainVerificationMethod } diff --git a/idp/internal/providers/database/grants.sql.go b/idp/internal/providers/database/grants.sql.go index 99adc72..35c6924 100644 --- a/idp/internal/providers/database/grants.sql.go +++ b/idp/internal/providers/database/grants.sql.go @@ -29,7 +29,7 @@ INSERT INTO "grants" ( ` type CreateGrantParams struct { - AccountID int32 + AccountID int64 GrantID uuid.UUID GrantedClientID string GrantedScopes []Scopes @@ -41,7 +41,7 @@ type CreateGrantParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateGrant(ctx context.Context, arg CreateGrantParams) (int32, error) { +func (q *Queries) CreateGrant(ctx context.Context, arg CreateGrantParams) (int64, error) { row := q.db.QueryRow(ctx, createGrant, arg.AccountID, arg.GrantID, @@ -49,7 +49,7 @@ func (q *Queries) CreateGrant(ctx context.Context, arg CreateGrantParams) (int32 arg.GrantedScopes, arg.GrantedCustomScopes, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } diff --git a/idp/internal/providers/database/key_encryption_keys.sql.go b/idp/internal/providers/database/key_encryption_keys.sql.go index bfc439c..635d3d5 100644 --- a/idp/internal/providers/database/key_encryption_keys.sql.go +++ b/idp/internal/providers/database/key_encryption_keys.sql.go @@ -36,9 +36,9 @@ type CreateKeyEncryptionKeyParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateKeyEncryptionKey(ctx context.Context, arg CreateKeyEncryptionKeyParams) (int32, error) { +func (q *Queries) CreateKeyEncryptionKey(ctx context.Context, arg CreateKeyEncryptionKeyParams) (int64, error) { row := q.db.QueryRow(ctx, createKeyEncryptionKey, arg.Kid, arg.Usage, arg.NextRotationAt) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -71,7 +71,7 @@ WHERE "id" = $1 LIMIT 1 ` -func (q *Queries) FindKeyEncryptionKeyByID(ctx context.Context, id int32) (KeyEncryptionKey, error) { +func (q *Queries) FindKeyEncryptionKeyByID(ctx context.Context, id int64) (KeyEncryptionKey, error) { row := q.db.QueryRow(ctx, findKeyEncryptionKeyByID, id) var i KeyEncryptionKey err := row.Scan( @@ -124,13 +124,13 @@ RETURNING "id" ` type RotateKeyEncryptionKeyParams struct { - ID int32 + ID int64 NextRotationAt time.Time } -func (q *Queries) RotateKeyEncryptionKey(ctx context.Context, arg RotateKeyEncryptionKeyParams) (int32, error) { +func (q *Queries) RotateKeyEncryptionKey(ctx context.Context, arg RotateKeyEncryptionKeyParams) (int64, error) { row := q.db.QueryRow(ctx, rotateKeyEncryptionKey, arg.ID, arg.NextRotationAt) - var id int32 + var id int64 err := row.Scan(&id) return id, err } diff --git a/idp/internal/providers/database/migrations/20241213231542_create_initial_schema.up.sql b/idp/internal/providers/database/migrations/20241213231542_create_initial_schema.up.sql index 5f30857..f217b3b 100644 --- a/idp/internal/providers/database/migrations/20241213231542_create_initial_schema.up.sql +++ b/idp/internal/providers/database/migrations/20241213231542_create_initial_schema.up.sql @@ -1,6 +1,6 @@ -- SQL dump generated using DBML (dbml.dbdiagram.io) -- Database: PostgreSQL --- Generated at: 2026-10-09T19:10:27.473Z +-- Generated at: 2026-10-10T12:55:15.004Z CREATE TYPE "kek_usage" AS ENUM ( 'global', @@ -216,7 +216,7 @@ CREATE TYPE "token_owner" AS ENUM ( ); CREATE TABLE "key_encryption_keys" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "kid" uuid NOT NULL, "usage" kek_usage NOT NULL, "version" integer NOT NULL DEFAULT 1, @@ -227,7 +227,7 @@ CREATE TABLE "key_encryption_keys" ( ); CREATE TABLE "data_encryption_keys" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "kid" varchar(22) NOT NULL, "dek" text NOT NULL, "kek_kid" uuid NOT NULL, @@ -239,7 +239,7 @@ CREATE TABLE "data_encryption_keys" ( ); CREATE TABLE "token_signing_keys" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "kid" varchar(22) NOT NULL, "key_type" token_key_type NOT NULL, "public_key" jsonb NOT NULL, @@ -255,7 +255,7 @@ CREATE TABLE "token_signing_keys" ( ); CREATE TABLE "accounts" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "public_id" uuid NOT NULL, "given_name" varchar(100) NOT NULL, "family_name" varchar(100) NOT NULL, @@ -271,8 +271,8 @@ CREATE TABLE "accounts" ( ); CREATE TABLE "account_2fa_configs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "two_factor_type" two_factor_type NOT NULL, "is_default" boolean NOT NULL DEFAULT false, @@ -282,32 +282,32 @@ CREATE TABLE "account_2fa_configs" ( ); CREATE TABLE "totps" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "dek_kid" varchar(22) NOT NULL, "url" varchar(512) NOT NULL, "secret" text NOT NULL, "recovery_codes" jsonb NOT NULL, "usage" totp_usage NOT NULL, - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), "updated_at" timestamptz NOT NULL DEFAULT (now()) ); CREATE TABLE "credentials_secrets" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "secret_id" varchar(22) NOT NULL, "client_secret" text NOT NULL, "dek_kid" varchar(22) NOT NULL, "is_revoked" boolean NOT NULL DEFAULT false, "usage" credentials_usage NOT NULL, - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "expires_at" timestamptz NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), "updated_at" timestamptz NOT NULL DEFAULT (now()) ); CREATE TABLE "credentials_keys" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "public_kid" varchar(22) NOT NULL, "public_key" jsonb NOT NULL, "private_key" text NOT NULL, @@ -316,29 +316,29 @@ CREATE TABLE "credentials_keys" ( "is_revoked" boolean NOT NULL DEFAULT false, "is_external" boolean NOT NULL DEFAULT false, "usage" credentials_usage NOT NULL, - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "expires_at" timestamptz NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), "updated_at" timestamptz NOT NULL DEFAULT (now()) ); CREATE TABLE "account_key_encryption_keys" ( - "account_id" integer NOT NULL, - "key_encryption_key_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "key_encryption_key_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("account_id", "key_encryption_key_id") ); CREATE TABLE "account_data_encryption_keys" ( - "account_id" integer NOT NULL, - "data_encryption_key_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "data_encryption_key_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("account_id", "data_encryption_key_id") ); CREATE TABLE "account_hmac_secrets" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "secret_id" varchar(22) NOT NULL, "secret" text NOT NULL, "dek_kid" varchar(22) NOT NULL, @@ -348,8 +348,8 @@ CREATE TABLE "account_hmac_secrets" ( ); CREATE TABLE "account_totps" ( - "account_id" integer NOT NULL, - "totp_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "totp_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("account_id", "totp_id") ); @@ -357,8 +357,8 @@ CREATE TABLE "account_totps" ( CREATE TABLE "account_credentials" ( "registration_token_jti" uuid UNIQUE, "software_statement" text NOT NULL DEFAULT '', - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "domain" varchar(250) NOT NULL, "creation_method" creation_method NOT NULL, @@ -403,9 +403,9 @@ CREATE TABLE "account_credentials" ( ); CREATE TABLE "account_credentials_secrets" ( - "account_id" integer NOT NULL, - "credentials_secret_id" integer NOT NULL, - "account_credentials_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "credentials_secret_id" bigint NOT NULL, + "account_credentials_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "secret_id" varchar(22) NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), @@ -413,9 +413,9 @@ CREATE TABLE "account_credentials_secrets" ( ); CREATE TABLE "account_credentials_keys" ( - "account_id" integer NOT NULL, - "credentials_key_id" integer NOT NULL, - "account_credentials_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "credentials_key_id" bigint NOT NULL, + "account_credentials_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "jwk_kid" varchar(22) NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), @@ -423,7 +423,7 @@ CREATE TABLE "account_credentials_keys" ( ); CREATE TABLE "account_auth_providers" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "email" varchar(250) NOT NULL, "provider" auth_provider NOT NULL, "account_public_id" uuid NOT NULL, @@ -432,8 +432,8 @@ CREATE TABLE "account_auth_providers" ( ); CREATE TABLE "oidc_configs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "claims_supported" claims[] NOT NULL DEFAULT '{ "sub", "email", "email_verified", "given_name", "family_name" }', "scopes_supported" scopes[] NOT NULL DEFAULT '{ "openid", "email", "profile" }', "custom_claims" varchar(512)[] NOT NULL DEFAULT '{}', @@ -443,16 +443,16 @@ CREATE TABLE "oidc_configs" ( ); CREATE TABLE "account_token_signing_keys" ( - "account_id" integer NOT NULL, - "token_signing_key_id" integer NOT NULL, + "account_id" bigint NOT NULL, + "token_signing_key_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("account_id", "token_signing_key_id") ); CREATE TABLE "users" ( - "id" serial PRIMARY KEY, + "id" bigserial PRIMARY KEY, "public_id" uuid NOT NULL, - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "email" varchar(250) NOT NULL, "username" varchar(63) NOT NULL, "password" text, @@ -465,9 +465,9 @@ CREATE TABLE "users" ( ); CREATE TABLE "user_2fa_configs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, - "user_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, + "user_id" bigint NOT NULL, "two_factor_type" two_factor_type NOT NULL, "is_default" boolean NOT NULL DEFAULT false, "created_at" timestamptz NOT NULL DEFAULT (now()), @@ -475,35 +475,35 @@ CREATE TABLE "user_2fa_configs" ( ); CREATE TABLE "user_data_encryption_keys" ( - "user_id" integer NOT NULL, - "data_encryption_key_id" integer NOT NULL, - "account_id" integer NOT NULL, + "user_id" bigint NOT NULL, + "data_encryption_key_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("user_id", "data_encryption_key_id") ); CREATE TABLE "user_totps" ( - "user_id" integer NOT NULL, - "totp_id" integer NOT NULL, - "account_id" integer NOT NULL, + "user_id" bigint NOT NULL, + "totp_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("user_id", "totp_id") ); CREATE TABLE "user_auth_providers" ( - "id" serial PRIMARY KEY, - "user_id" integer NOT NULL, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "user_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "provider" auth_provider NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), "updated_at" timestamptz NOT NULL DEFAULT (now()) ); CREATE TABLE "user_credentials" ( - "id" serial PRIMARY KEY, - "user_id" integer NOT NULL, - "account_id" integer NOT NULL, - "app_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "user_id" bigint NOT NULL, + "account_id" bigint NOT NULL, + "app_id" bigint NOT NULL, "client_id" varchar(22) NOT NULL, "auth_methods" auth_method[] NOT NULL, "issuers" varchar(512)[] NOT NULL, @@ -512,20 +512,20 @@ CREATE TABLE "user_credentials" ( ); CREATE TABLE "user_credentials_secrets" ( - "user_id" integer NOT NULL, - "credentials_secret_id" integer NOT NULL, - "user_credential_id" integer NOT NULL, - "account_id" integer NOT NULL, + "user_id" bigint NOT NULL, + "credentials_secret_id" bigint NOT NULL, + "user_credential_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "user_public_id" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("user_id", "credentials_secret_id") ); CREATE TABLE "user_credentials_keys" ( - "user_id" integer NOT NULL, - "credentials_key_id" integer NOT NULL, - "user_credential_id" integer NOT NULL, - "account_id" integer NOT NULL, + "user_id" bigint NOT NULL, + "credentials_key_id" bigint NOT NULL, + "user_credential_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "user_public_id" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("user_id", "credentials_key_id") @@ -534,8 +534,8 @@ CREATE TABLE "user_credentials_keys" ( CREATE TABLE "apps" ( "registration_token_jti" uuid UNIQUE, "software_statement" text NOT NULL DEFAULT '', - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "client_id" varchar(22) NOT NULL, "version" integer NOT NULL DEFAULT 1, @@ -592,25 +592,25 @@ CREATE TABLE "apps" ( ); CREATE TABLE "app_secrets" ( - "app_id" integer NOT NULL, - "credentials_secret_id" integer NOT NULL, - "account_id" integer NOT NULL, + "app_id" bigint NOT NULL, + "credentials_secret_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("app_id", "credentials_secret_id") ); CREATE TABLE "app_keys" ( - "app_id" integer NOT NULL, - "credentials_key_id" integer NOT NULL, - "account_id" integer NOT NULL, + "app_id" bigint NOT NULL, + "credentials_key_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("app_id", "credentials_key_id") ); CREATE TABLE "app_designs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, - "app_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, + "app_id" bigint NOT NULL, "light_colors" jsonb NOT NULL, "dark_colors" jsonb, "logo_url" varchar(512), @@ -620,8 +620,8 @@ CREATE TABLE "app_designs" ( ); CREATE TABLE "account_dynamic_registration_configs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "account_credentials_types" account_credentials_type[] NOT NULL, "require_software_statement_credential_types" account_credentials_type[] NOT NULL, @@ -632,8 +632,8 @@ CREATE TABLE "account_dynamic_registration_configs" ( ); CREATE TABLE "app_dynamic_registration_configs" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "allowed_app_types" app_type[] NOT NULL, "default_allow_user_registration" boolean NOT NULL, @@ -657,8 +657,8 @@ CREATE TABLE "app_dynamic_registration_configs" ( ); CREATE TABLE "dynamic_registration_domains" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, "domain" varchar(250) NOT NULL, "verified_at" timestamptz, @@ -669,9 +669,9 @@ CREATE TABLE "dynamic_registration_domains" ( ); CREATE TABLE "dynamic_registration_domain_codes" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, - "dynamic_registration_domain_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, + "dynamic_registration_domain_id" bigint NOT NULL, "verification_host" varchar(50) NOT NULL, "verification_code" text NOT NULL, "hmac_secret_id" varchar(22) NOT NULL, @@ -682,27 +682,27 @@ CREATE TABLE "dynamic_registration_domain_codes" ( ); CREATE TABLE "dynamic_registration_software_statement_keys" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "account_public_id" uuid NOT NULL, - "credentials_key_id" integer NOT NULL, + "credentials_key_id" bigint NOT NULL, "credentials_key_kid" varchar(22) NOT NULL, "root_domain" varchar(250) NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()) ); CREATE TABLE "app_profiles" ( - "app_id" integer NOT NULL, - "user_id" integer NOT NULL, - "account_id" integer NOT NULL, + "app_id" bigint NOT NULL, + "user_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "profile_type" app_profile_type NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("app_id", "user_id") ); CREATE TABLE "grants" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, "grant_id" uuid NOT NULL, "granted_client_id" varchar(22) NOT NULL, "granted_scopes" scopes[] NOT NULL, @@ -714,10 +714,10 @@ CREATE TABLE "grants" ( ); CREATE TABLE "account_grants" ( - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "account_version" integer NOT NULL, - "grant_id" integer NOT NULL, - "account_credentials_id" integer, + "grant_id" bigint NOT NULL, + "account_credentials_id" bigint, "granted_client_id" varchar(22) NOT NULL, "is_revoked" boolean NOT NULL DEFAULT false, "revoked_at" timestamptz, @@ -727,11 +727,11 @@ CREATE TABLE "account_grants" ( ); CREATE TABLE "user_grants" ( - "user_id" integer NOT NULL, + "user_id" bigint NOT NULL, "user_version" integer NOT NULL, - "grant_id" integer NOT NULL, - "app_id" integer NOT NULL, - "account_id" integer NOT NULL, + "grant_id" bigint NOT NULL, + "app_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "granted_client_id" varchar(22) NOT NULL, "is_revoked" boolean NOT NULL DEFAULT false, "revoked_at" timestamptz, @@ -741,9 +741,9 @@ CREATE TABLE "user_grants" ( ); CREATE TABLE "sessions" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, - "grant_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, + "grant_id" bigint NOT NULL, "session_id" uuid NOT NULL, "session_type" session_type NOT NULL, "session_client_id" varchar(22) NOT NULL, @@ -756,31 +756,31 @@ CREATE TABLE "sessions" ( ); CREATE TABLE "account_sessions" ( - "account_id" integer NOT NULL, + "account_id" bigint NOT NULL, "account_version" integer NOT NULL, - "session_id" integer NOT NULL, - "account_credentials_id" integer, + "session_id" bigint NOT NULL, + "account_credentials_id" bigint, "session_uuid" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("account_id", "session_id") ); CREATE TABLE "user_sessions" ( - "user_id" integer NOT NULL, + "user_id" bigint NOT NULL, "user_version" integer NOT NULL, - "session_id" integer NOT NULL, - "app_id" integer NOT NULL, - "account_id" integer NOT NULL, + "session_id" bigint NOT NULL, + "app_id" bigint NOT NULL, + "account_id" bigint NOT NULL, "session_uuid" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT (now()), PRIMARY KEY ("user_id", "session_id") ); CREATE TABLE "session_tokens" ( - "id" serial PRIMARY KEY, - "account_id" integer NOT NULL, - "session_id" integer NOT NULL, - "grant_id" integer NOT NULL, + "id" bigserial PRIMARY KEY, + "account_id" bigint NOT NULL, + "session_id" bigint NOT NULL, + "grant_id" bigint NOT NULL, "session_uuid" uuid NOT NULL, "token_id" uuid NOT NULL, "issued_at" timestamptz NOT NULL DEFAULT (now()), diff --git a/idp/internal/providers/database/models.go b/idp/internal/providers/database/models.go index 1d2eea2..b86cf66 100644 --- a/idp/internal/providers/database/models.go +++ b/idp/internal/providers/database/models.go @@ -1337,7 +1337,7 @@ func (ns NullTwoFactorType) Value() (driver.Value, error) { } type Account struct { - ID int32 + ID int64 PublicID uuid.UUID GivenName string FamilyName string @@ -1353,8 +1353,8 @@ type Account struct { } type Account2faConfig struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID TwoFactorType TwoFactorType IsDefault bool @@ -1364,7 +1364,7 @@ type Account2faConfig struct { } type AccountAuthProvider struct { - ID int32 + ID int64 Email string Provider AuthProvider AccountPublicID uuid.UUID @@ -1375,8 +1375,8 @@ type AccountAuthProvider struct { type AccountCredential struct { RegistrationTokenJti pgtype.UUID SoftwareStatement string - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID Domain string CreationMethod CreationMethod @@ -1421,32 +1421,32 @@ type AccountCredential struct { } type AccountCredentialsKey struct { - AccountID int32 - CredentialsKeyID int32 - AccountCredentialsID int32 + AccountID int64 + CredentialsKeyID int64 + AccountCredentialsID int64 AccountPublicID uuid.UUID JwkKid string CreatedAt time.Time } type AccountCredentialsSecret struct { - AccountID int32 - CredentialsSecretID int32 - AccountCredentialsID int32 + AccountID int64 + CredentialsSecretID int64 + AccountCredentialsID int64 AccountPublicID uuid.UUID SecretID string CreatedAt time.Time } type AccountDataEncryptionKey struct { - AccountID int32 - DataEncryptionKeyID int32 + AccountID int64 + DataEncryptionKeyID int64 CreatedAt time.Time } type AccountDynamicRegistrationConfig struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID AccountCredentialsTypes []AccountCredentialsType RequireSoftwareStatementCredentialTypes []AccountCredentialsType @@ -1457,10 +1457,10 @@ type AccountDynamicRegistrationConfig struct { } type AccountGrant struct { - AccountID int32 + AccountID int64 AccountVersion int32 - GrantID int32 - AccountCredentialsID pgtype.Int4 + GrantID int64 + AccountCredentialsID pgtype.Int8 GrantedClientID string IsRevoked bool RevokedAt pgtype.Timestamptz @@ -1469,8 +1469,8 @@ type AccountGrant struct { } type AccountHmacSecret struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 SecretID string Secret string DekKid string @@ -1480,37 +1480,37 @@ type AccountHmacSecret struct { } type AccountKeyEncryptionKey struct { - AccountID int32 - KeyEncryptionKeyID int32 + AccountID int64 + KeyEncryptionKeyID int64 CreatedAt time.Time } type AccountSession struct { - AccountID int32 + AccountID int64 AccountVersion int32 - SessionID int32 - AccountCredentialsID pgtype.Int4 + SessionID int64 + AccountCredentialsID pgtype.Int8 SessionUuid uuid.UUID CreatedAt time.Time } type AccountTokenSigningKey struct { - AccountID int32 - TokenSigningKeyID int32 + AccountID int64 + TokenSigningKeyID int64 CreatedAt time.Time } type AccountTotp struct { - AccountID int32 - TotpID int32 + AccountID int64 + TotpID int64 CreatedAt time.Time } type App struct { RegistrationTokenJti pgtype.UUID SoftwareStatement string - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID ClientID string Version int32 @@ -1567,9 +1567,9 @@ type App struct { } type AppDesign struct { - ID int32 - AccountID int32 - AppID int32 + ID int64 + AccountID int64 + AppID int64 LightColors []byte DarkColors []byte LogoUrl pgtype.Text @@ -1579,8 +1579,8 @@ type AppDesign struct { } type AppDynamicRegistrationConfig struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID AllowedAppTypes []AppType DefaultAllowUserRegistration bool @@ -1604,29 +1604,29 @@ type AppDynamicRegistrationConfig struct { } type AppKey struct { - AppID int32 - CredentialsKeyID int32 - AccountID int32 + AppID int64 + CredentialsKeyID int64 + AccountID int64 CreatedAt time.Time } type AppProfile struct { - AppID int32 - UserID int32 - AccountID int32 + AppID int64 + UserID int64 + AccountID int64 ProfileType AppProfileType CreatedAt time.Time } type AppSecret struct { - AppID int32 - CredentialsSecretID int32 - AccountID int32 + AppID int64 + CredentialsSecretID int64 + AccountID int64 CreatedAt time.Time } type CredentialsKey struct { - ID int32 + ID int64 PublicKid string PublicKey []byte PrivateKey string @@ -1635,27 +1635,27 @@ type CredentialsKey struct { IsRevoked bool IsExternal bool Usage CredentialsUsage - AccountID int32 + AccountID int64 ExpiresAt time.Time CreatedAt time.Time UpdatedAt time.Time } type CredentialsSecret struct { - ID int32 + ID int64 SecretID string ClientSecret string DekKid string IsRevoked bool Usage CredentialsUsage - AccountID int32 + AccountID int64 ExpiresAt time.Time CreatedAt time.Time UpdatedAt time.Time } type DataEncryptionKey struct { - ID int32 + ID int64 Kid string Dek string KekKid uuid.UUID @@ -1667,8 +1667,8 @@ type DataEncryptionKey struct { } type DynamicRegistrationDomain struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID Domain string VerifiedAt pgtype.Timestamptz @@ -1679,9 +1679,9 @@ type DynamicRegistrationDomain struct { } type DynamicRegistrationDomainCode struct { - ID int32 - AccountID int32 - DynamicRegistrationDomainID int32 + ID int64 + AccountID int64 + DynamicRegistrationDomainID int64 VerificationHost string VerificationCode string HmacSecretID string @@ -1692,18 +1692,18 @@ type DynamicRegistrationDomainCode struct { } type DynamicRegistrationSoftwareStatementKey struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 AccountPublicID uuid.UUID - CredentialsKeyID int32 + CredentialsKeyID int64 CredentialsKeyKid string RootDomain string CreatedAt time.Time } type Grant struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 GrantID uuid.UUID GrantedClientID string GrantedScopes []Scopes @@ -1715,7 +1715,7 @@ type Grant struct { } type KeyEncryptionKey struct { - ID int32 + ID int64 Kid uuid.UUID Usage KekUsage Version int32 @@ -1726,8 +1726,8 @@ type KeyEncryptionKey struct { } type OidcConfig struct { - ID int32 - AccountID int32 + ID int64 + AccountID int64 ClaimsSupported []Claims ScopesSupported []Scopes CustomClaims []string @@ -1737,9 +1737,9 @@ type OidcConfig struct { } type Session struct { - ID int32 - AccountID int32 - GrantID int32 + ID int64 + AccountID int64 + GrantID int64 SessionID uuid.UUID SessionType SessionType SessionClientID string @@ -1752,10 +1752,10 @@ type Session struct { } type SessionToken struct { - ID int32 - AccountID int32 - SessionID int32 - GrantID int32 + ID int64 + AccountID int64 + SessionID int64 + GrantID int64 SessionUuid uuid.UUID TokenID uuid.UUID IssuedAt time.Time @@ -1764,7 +1764,7 @@ type SessionToken struct { } type TokenSigningKey struct { - ID int32 + ID int64 Kid string KeyType TokenKeyType PublicKey []byte @@ -1780,21 +1780,21 @@ type TokenSigningKey struct { } type Totp struct { - ID int32 + ID int64 DekKid string Url string Secret string RecoveryCodes []byte Usage TotpUsage - AccountID int32 + AccountID int64 CreatedAt time.Time UpdatedAt time.Time } type User struct { - ID int32 + ID int64 PublicID uuid.UUID - AccountID int32 + AccountID int64 Email string Username string Password pgtype.Text @@ -1807,9 +1807,9 @@ type User struct { } type User2faConfig struct { - ID int32 - AccountID int32 - UserID int32 + ID int64 + AccountID int64 + UserID int64 TwoFactorType TwoFactorType IsDefault bool CreatedAt time.Time @@ -1817,19 +1817,19 @@ type User2faConfig struct { } type UserAuthProvider struct { - ID int32 - UserID int32 - AccountID int32 + ID int64 + UserID int64 + AccountID int64 Provider AuthProvider CreatedAt time.Time UpdatedAt time.Time } type UserCredential struct { - ID int32 - UserID int32 - AccountID int32 - AppID int32 + ID int64 + UserID int64 + AccountID int64 + AppID int64 ClientID string AuthMethods []AuthMethod Issuers []string @@ -1838,36 +1838,36 @@ type UserCredential struct { } type UserCredentialsKey struct { - UserID int32 - CredentialsKeyID int32 - UserCredentialID int32 - AccountID int32 + UserID int64 + CredentialsKeyID int64 + UserCredentialID int64 + AccountID int64 UserPublicID uuid.UUID CreatedAt time.Time } type UserCredentialsSecret struct { - UserID int32 - CredentialsSecretID int32 - UserCredentialID int32 - AccountID int32 + UserID int64 + CredentialsSecretID int64 + UserCredentialID int64 + AccountID int64 UserPublicID uuid.UUID CreatedAt time.Time } type UserDataEncryptionKey struct { - UserID int32 - DataEncryptionKeyID int32 - AccountID int32 + UserID int64 + DataEncryptionKeyID int64 + AccountID int64 CreatedAt time.Time } type UserGrant struct { - UserID int32 + UserID int64 UserVersion int32 - GrantID int32 - AppID int32 - AccountID int32 + GrantID int64 + AppID int64 + AccountID int64 GrantedClientID string IsRevoked bool RevokedAt pgtype.Timestamptz @@ -1876,18 +1876,18 @@ type UserGrant struct { } type UserSession struct { - UserID int32 + UserID int64 UserVersion int32 - SessionID int32 - AppID int32 - AccountID int32 + SessionID int64 + AppID int64 + AccountID int64 SessionUuid uuid.UUID CreatedAt time.Time } type UserTotp struct { - UserID int32 - TotpID int32 - AccountID int32 + UserID int64 + TotpID int64 + AccountID int64 CreatedAt time.Time } diff --git a/idp/internal/providers/database/oidc_configs.sql.go b/idp/internal/providers/database/oidc_configs.sql.go index d95c418..1429419 100644 --- a/idp/internal/providers/database/oidc_configs.sql.go +++ b/idp/internal/providers/database/oidc_configs.sql.go @@ -20,7 +20,7 @@ WHERE "account_id" = $1 // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CountOIDCConfigsByAccountID(ctx context.Context, accountID int32) (int64, error) { +func (q *Queries) CountOIDCConfigsByAccountID(ctx context.Context, accountID int64) (int64, error) { row := q.db.QueryRow(ctx, countOIDCConfigsByAccountID, accountID) var count int64 err := row.Scan(&count) @@ -35,7 +35,7 @@ INSERT INTO "oidc_configs" ( ) RETURNING id, account_id, claims_supported, scopes_supported, custom_claims, custom_scopes, created_at, updated_at ` -func (q *Queries) CreateDefaultOIDCConfig(ctx context.Context, accountID int32) (OidcConfig, error) { +func (q *Queries) CreateDefaultOIDCConfig(ctx context.Context, accountID int64) (OidcConfig, error) { row := q.db.QueryRow(ctx, createDefaultOIDCConfig, accountID) var i OidcConfig err := row.Scan( @@ -68,7 +68,7 @@ INSERT INTO "oidc_configs" ( ` type CreateOIDCConfigParams struct { - AccountID int32 + AccountID int64 ClaimsSupported []Claims ScopesSupported []Scopes CustomClaims []string @@ -103,7 +103,7 @@ WHERE "account_id" = $1 LIMIT 1 ` -func (q *Queries) FindOIDCConfigByAccountID(ctx context.Context, accountID int32) (OidcConfig, error) { +func (q *Queries) FindOIDCConfigByAccountID(ctx context.Context, accountID int64) (OidcConfig, error) { row := q.db.QueryRow(ctx, findOIDCConfigByAccountID, accountID) var i OidcConfig err := row.Scan( @@ -131,7 +131,7 @@ RETURNING id, account_id, claims_supported, scopes_supported, custom_claims, cus ` type UpdateOIDCConfigParams struct { - ID int32 + ID int64 ClaimsSupported []Claims ScopesSupported []Scopes CustomClaims []string diff --git a/idp/internal/providers/database/registered_apps.sql.go b/idp/internal/providers/database/registered_apps.sql.go index 640283e..dff98b6 100644 --- a/idp/internal/providers/database/registered_apps.sql.go +++ b/idp/internal/providers/database/registered_apps.sql.go @@ -113,7 +113,7 @@ INSERT INTO "apps" ( ` type CreateRegisteredAppParams struct { - AccountID int32 + AccountID int64 AccountPublicID uuid.UUID AppType AppType ClientName string @@ -324,7 +324,7 @@ RETURNING registration_token_jti, software_statement, id, account_id, account_pu ` type UpdateRegisteredAppParams struct { - ID int32 + ID int64 ClientName string ClientUri string UsernameColumn AppUsernameColumn diff --git a/idp/internal/providers/database/session_tokens.sql.go b/idp/internal/providers/database/session_tokens.sql.go index d4cd1b5..49f09ab 100644 --- a/idp/internal/providers/database/session_tokens.sql.go +++ b/idp/internal/providers/database/session_tokens.sql.go @@ -33,10 +33,10 @@ INSERT INTO "session_tokens" ( type CreateSessionTokenParams struct { TokenID uuid.UUID - AccountID int32 - SessionID int32 + AccountID int64 + SessionID int64 SessionUuid uuid.UUID - GrantID int32 + GrantID int64 ExpiresAt time.Time } diff --git a/idp/internal/providers/database/sessions.sql.go b/idp/internal/providers/database/sessions.sql.go index 936e7d1..cbaf064 100644 --- a/idp/internal/providers/database/sessions.sql.go +++ b/idp/internal/providers/database/sessions.sql.go @@ -37,8 +37,8 @@ INSERT INTO "sessions" ( ` type CreateSessionParams struct { - AccountID int32 - GrantID int32 + AccountID int64 + GrantID int64 SessionID uuid.UUID SessionType SessionType SessionClientID string @@ -52,7 +52,7 @@ type CreateSessionParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (int32, error) { +func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (int64, error) { row := q.db.QueryRow(ctx, createSession, arg.AccountID, arg.GrantID, @@ -63,7 +63,7 @@ func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (i arg.UserAgent, arg.ExpiresAt, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -72,7 +72,7 @@ const deleteSessionByID = `-- name: DeleteSessionByID :exec DELETE FROM "sessions" WHERE "id" = $1 ` -func (q *Queries) DeleteSessionByID(ctx context.Context, id int32) error { +func (q *Queries) DeleteSessionByID(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteSessionByID, id) return err } @@ -83,7 +83,7 @@ UPDATE "sessions" SET "expires_at" = $1 WHERE "id" = $2 type UpdateSessionExpiresAtParams struct { ExpiresAt time.Time - ID int32 + ID int64 } func (q *Queries) UpdateSessionExpiresAt(ctx context.Context, arg UpdateSessionExpiresAtParams) error { diff --git a/idp/internal/providers/database/token_signing_keys.sql.go b/idp/internal/providers/database/token_signing_keys.sql.go index 19e5f5f..52badf7 100644 --- a/idp/internal/providers/database/token_signing_keys.sql.go +++ b/idp/internal/providers/database/token_signing_keys.sql.go @@ -52,7 +52,7 @@ type CreateTokenSigningKeyParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateTokenSigningKey(ctx context.Context, arg CreateTokenSigningKeyParams) (int32, error) { +func (q *Queries) CreateTokenSigningKey(ctx context.Context, arg CreateTokenSigningKeyParams) (int64, error) { row := q.db.QueryRow(ctx, createTokenSigningKey, arg.Kid, arg.KeyType, @@ -64,7 +64,7 @@ func (q *Queries) CreateTokenSigningKey(ctx context.Context, arg CreateTokenSign arg.Usage, arg.IsDistributed, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -176,7 +176,7 @@ RETURNING id, kid, key_type, public_key, private_key, dek_kid, crypto_suite, exp ` type UpdateTokenSigningKeyDEKAndPrivateKeyParams struct { - ID int32 + ID int64 DekKid string PrivateKey string } diff --git a/idp/internal/providers/database/totps.sql.go b/idp/internal/providers/database/totps.sql.go index 1694bff..cc962f0 100644 --- a/idp/internal/providers/database/totps.sql.go +++ b/idp/internal/providers/database/totps.sql.go @@ -34,7 +34,7 @@ type CreateTotpParams struct { Secret string RecoveryCodes []byte Usage TotpUsage - AccountID int32 + AccountID int64 } // Copyright (c) 2025 Afonso Barracha @@ -42,7 +42,7 @@ type CreateTotpParams struct { // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) CreateTotp(ctx context.Context, arg CreateTotpParams) (int32, error) { +func (q *Queries) CreateTotp(ctx context.Context, arg CreateTotpParams) (int64, error) { row := q.db.QueryRow(ctx, createTotp, arg.DekKid, arg.Url, @@ -51,7 +51,7 @@ func (q *Queries) CreateTotp(ctx context.Context, arg CreateTotpParams) (int32, arg.Usage, arg.AccountID, ) - var id int32 + var id int64 err := row.Scan(&id) return id, err } @@ -67,7 +67,7 @@ WHERE "id" = $1 ` type UpdateTOTPParams struct { - ID int32 + ID int64 Url string Secret string DekKid string @@ -94,7 +94,7 @@ WHERE "id" = $1 ` type UpdateTOTPSecretAndDEKParams struct { - ID int32 + ID int64 Secret string DekKid string } diff --git a/idp/internal/providers/database/user_auth_providers.sql.go b/idp/internal/providers/database/user_auth_providers.sql.go index 8adb2b6..f3e2256 100644 --- a/idp/internal/providers/database/user_auth_providers.sql.go +++ b/idp/internal/providers/database/user_auth_providers.sql.go @@ -23,8 +23,8 @@ INSERT INTO "user_auth_providers" ( ` type CreateUserAuthProviderParams struct { - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 Provider AuthProvider } @@ -47,7 +47,7 @@ LIMIT 1 ` type FindUserAuthProviderByUserIDAndProviderParams struct { - UserID int32 + UserID int64 Provider AuthProvider } diff --git a/idp/internal/providers/database/user_sessions.sql.go b/idp/internal/providers/database/user_sessions.sql.go index a1b8585..f1a0d1c 100644 --- a/idp/internal/providers/database/user_sessions.sql.go +++ b/idp/internal/providers/database/user_sessions.sql.go @@ -24,21 +24,21 @@ LIMIT 1 ` type FindUserSessionByUserIDAndSessionUUIDParams struct { - UserID int32 + UserID int64 SessionUuid uuid.UUID } type FindUserSessionByUserIDAndSessionUUIDRow struct { - UserID int32 + UserID int64 UserVersion int32 - SessionID int32 - AppID int32 - AccountID int32 + SessionID int64 + AppID int64 + AccountID int64 SessionUuid uuid.UUID CreatedAt time.Time - ID pgtype.Int4 - AccountID_2 pgtype.Int4 - GrantID pgtype.Int4 + ID pgtype.Int8 + AccountID_2 pgtype.Int8 + GrantID pgtype.Int8 SessionID_2 pgtype.UUID SessionType NullSessionType SessionClientID pgtype.Text diff --git a/idp/internal/providers/database/user_totps.sql.go b/idp/internal/providers/database/user_totps.sql.go index 7b68856..7b7df0f 100644 --- a/idp/internal/providers/database/user_totps.sql.go +++ b/idp/internal/providers/database/user_totps.sql.go @@ -21,7 +21,7 @@ WHERE "at"."user_id" = $1 LIMIT 1 // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -func (q *Queries) FindUserTotpByUserID(ctx context.Context, userID int32) (Totp, error) { +func (q *Queries) FindUserTotpByUserID(ctx context.Context, userID int64) (Totp, error) { row := q.db.QueryRow(ctx, findUserTotpByUserID, userID) var i Totp err := row.Scan( diff --git a/idp/internal/providers/database/users.sql.go b/idp/internal/providers/database/users.sql.go index f817932..15ed141 100644 --- a/idp/internal/providers/database/users.sql.go +++ b/idp/internal/providers/database/users.sql.go @@ -21,7 +21,7 @@ WHERE "id" = $1 RETURNING id, public_id, account_id, email, username, password, version, email_verified, activity_status, user_data, created_at, updated_at ` -func (q *Queries) ConfirmUser(ctx context.Context, id int32) (User, error) { +func (q *Queries) ConfirmUser(ctx context.Context, id int64) (User, error) { row := q.db.QueryRow(ctx, confirmUser, id) var i User err := row.Scan( @@ -48,7 +48,7 @@ LIMIT 1 ` type CountFilteredUsersByEmailOrUsernameAndByAccountIDParams struct { - AccountID int32 + AccountID int64 Email string Username string } @@ -66,7 +66,7 @@ WHERE "account_id" = $1 LIMIT 1 ` -func (q *Queries) CountUsersByAccountID(ctx context.Context, accountID int32) (int64, error) { +func (q *Queries) CountUsersByAccountID(ctx context.Context, accountID int64) (int64, error) { row := q.db.QueryRow(ctx, countUsersByAccountID, accountID) var count int64 err := row.Scan(&count) @@ -81,7 +81,7 @@ LIMIT 1 type CountUsersByEmailAndAccountIDParams struct { Email string - AccountID int32 + AccountID int64 } func (q *Queries) CountUsersByEmailAndAccountID(ctx context.Context, arg CountUsersByEmailAndAccountIDParams) (int64, error) { @@ -99,7 +99,7 @@ LIMIT 1 type CountUsersByUsernameAndAccountIDParams struct { Username string - AccountID int32 + AccountID int64 } func (q *Queries) CountUsersByUsernameAndAccountID(ctx context.Context, arg CountUsersByUsernameAndAccountIDParams) (int64, error) { @@ -129,7 +129,7 @@ INSERT INTO "users" ( ` type CreateUserWithPasswordParams struct { - AccountID int32 + AccountID int64 PublicID uuid.UUID Email string Username string @@ -186,7 +186,7 @@ INSERT INTO "users" ( ` type CreateUserWithoutPasswordParams struct { - AccountID int32 + AccountID int64 PublicID uuid.UUID Email string Username string @@ -224,7 +224,7 @@ DELETE FROM "users" WHERE "id" = $1 ` -func (q *Queries) DeleteUser(ctx context.Context, id int32) error { +func (q *Queries) DeleteUser(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, deleteUser, id) return err } @@ -237,7 +237,7 @@ OFFSET $4 LIMIT $5 ` type FilterUsersByEmailOrUsernameAndByAccountIDOrderedByEmailParams struct { - AccountID int32 + AccountID int64 Email string Username string Offset int32 @@ -291,7 +291,7 @@ OFFSET $4 LIMIT $5 ` type FilterUsersByEmailOrUsernameAndByAccountIDOrderedByIDParams struct { - AccountID int32 + AccountID int64 Email string Username string Offset int32 @@ -345,7 +345,7 @@ OFFSET $4 LIMIT $5 ` type FilterUsersByEmailOrUsernameAndByAccountIDOrderedByUsernameParams struct { - AccountID int32 + AccountID int64 Email string Username string Offset int32 @@ -399,7 +399,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedUsersByAccountIDOrderedByEmailParams struct { - AccountID int32 + AccountID int64 Offset int32 Limit int32 } @@ -445,7 +445,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedUsersByAccountIDOrderedByIDParams struct { - AccountID int32 + AccountID int64 Offset int32 Limit int32 } @@ -491,7 +491,7 @@ OFFSET $2 LIMIT $3 ` type FindPaginatedUsersByAccountIDOrderedByUsernameParams struct { - AccountID int32 + AccountID int64 Offset int32 Limit int32 } @@ -537,7 +537,7 @@ LIMIT 1 type FindUserByEmailAndAccountIDParams struct { Email string - AccountID int32 + AccountID int64 } func (q *Queries) FindUserByEmailAndAccountID(ctx context.Context, arg FindUserByEmailAndAccountIDParams) (User, error) { @@ -565,7 +565,7 @@ SELECT id, public_id, account_id, email, username, password, version, email_veri WHERE "id" = $1 LIMIT 1 ` -func (q *Queries) FindUserByID(ctx context.Context, id int32) (User, error) { +func (q *Queries) FindUserByID(ctx context.Context, id int64) (User, error) { row := q.db.QueryRow(ctx, findUserByID, id) var i User err := row.Scan( @@ -623,7 +623,7 @@ LIMIT 1 type FindUserByUsernameAndAccountIDParams struct { Username string - AccountID int32 + AccountID int64 } func (q *Queries) FindUserByUsernameAndAccountID(ctx context.Context, arg FindUserByUsernameAndAccountIDParams) (User, error) { @@ -660,7 +660,7 @@ RETURNING id, public_id, account_id, email, username, password, version, email_v ` type UpdateUserParams struct { - ID int32 + ID int64 Email string Username string UserData []byte @@ -706,7 +706,7 @@ RETURNING id, public_id, account_id, email, username, password, version, email_v type UpdateUserPasswordParams struct { Password pgtype.Text - ID int32 + ID int64 } func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) (User, error) { diff --git a/idp/internal/services/account_2fa_configs.go b/idp/internal/services/account_2fa_configs.go index d15796b..9d8638e 100644 --- a/idp/internal/services/account_2fa_configs.go +++ b/idp/internal/services/account_2fa_configs.go @@ -139,7 +139,7 @@ func Map2FAType(twoFAType string) (database.TwoFactorType, *exceptions.ServiceEr type buildStoreAccountTOTPOptions struct { requestID string - accountID int32 + accountID int64 queries *database.Queries } diff --git a/idp/internal/services/account_credentials.go b/idp/internal/services/account_credentials.go index 71897c9..a534aa7 100644 --- a/idp/internal/services/account_credentials.go +++ b/idp/internal/services/account_credentials.go @@ -395,7 +395,7 @@ func (s *Services) CreateAccountCredentials( return dtos.MapAccountCredentialsToDTOWithJWK(&accountCredentials, jwk, dbPrms.ExpiresAt) case AuthMethodClientSecretBasic, AuthMethodClientSecretPost, AuthMethodClientSecretJWT: - var ccID int32 + var ccID int64 var secretID, secret string var exp time.Time ccID, secretID, secret, exp, serviceErr = s.clientCredentialsSecret(ctx, qrs, clientCredentialsSecretOptions{ @@ -719,9 +719,9 @@ func (s *Services) DeleteAccountCredentials(ctx context.Context, opts DeleteAcco type createAccountCredentialsKeyOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID - accountCredentialsID int32 + accountCredentialsID int64 cryptoSuite utils.SupportedCryptoSuite } @@ -781,9 +781,9 @@ func (s *Services) createAccountCredentialsKey( type rotateAccountCredentialsKeyOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID - accountCredentialsID int32 + accountCredentialsID int64 cryptoSuite utils.SupportedCryptoSuite } @@ -822,9 +822,9 @@ func (s *Services) rotateAccountCredentialsKey( type createAccountCredentialsSecretOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID - accountCredentialsID int32 + accountCredentialsID int64 } func (s *Services) createAccountCredentialsSecret( @@ -880,9 +880,9 @@ func (s *Services) createAccountCredentialsSecret( type rotateAccountCredentialsSecretOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID - accountCredentialsID int32 + accountCredentialsID int64 authMethod database.AuthMethod } @@ -987,7 +987,7 @@ func (s *Services) RotateAccountCredentialsSecret( type listAccountCredentialsKeysOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 offset int32 limit int32 } @@ -1038,7 +1038,7 @@ func (s *Services) listAccountCredentialsKeys( type listAccountCredentialsSecretsOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 offset int32 limit int32 } @@ -1132,7 +1132,7 @@ func (s *Services) ListAccountCredentialsSecretsOrKeys( type getAccountCredentialsKeyByIDOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 publicKID string } @@ -1169,7 +1169,7 @@ func (s *Services) getAccountCredentialsKeyByID( type getAccountCredentialsSecretByIDOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 secretID string } @@ -1257,7 +1257,7 @@ func (s *Services) GetAccountCredentialsSecretOrKey( type revokeAccountCredentialsSecretOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 secretID string } @@ -1287,7 +1287,7 @@ func (s *Services) revokeAccountCredentialsSecret( type revokeAccountCredentialsKeyOptions struct { requestID string - accountCredentialsID int32 + accountCredentialsID int64 publicKID string } diff --git a/idp/internal/services/account_credentials_registration.go b/idp/internal/services/account_credentials_registration.go index 6995586..add049c 100644 --- a/idp/internal/services/account_credentials_registration.go +++ b/idp/internal/services/account_credentials_registration.go @@ -49,7 +49,7 @@ var accountCredentialsRegistrationUsages []database.DynamicRegistrationUsage = [ type mapAccountCredentialsRegistrationDataToDBParamsOptions struct { applicationType database.AccountCredentialsType accountPublicID uuid.UUID - accountID int32 + accountID int64 domain string requestID string tokenEndpointAuthMethod database.AuthMethod @@ -534,7 +534,7 @@ func (s *Services) createAccountCredentialsRegistration( return s.finalizeAccountCredentialsRegistration(ctx, qrs, opts, &accountCredentials, "", dbPrms.ExpiresAt, jwk) case database.AuthMethodClientSecretBasic, database.AuthMethodClientSecretPost, database.AuthMethodClientSecretJwt: - var ccID int32 + var ccID int64 var secretID, secret string var exp time.Time ccID, secretID, secret, exp, serviceErr = s.clientCredentialsSecret(ctx, qrs, clientCredentialsSecretOptions{ diff --git a/idp/internal/services/account_hmac_secrets.go b/idp/internal/services/account_hmac_secrets.go index 50e9f24..fd0dbfb 100644 --- a/idp/internal/services/account_hmac_secrets.go +++ b/idp/internal/services/account_hmac_secrets.go @@ -19,7 +19,7 @@ const accountHMACSecretsLocation = "account_hmac_secrets" type buildStoreAccountHMACSecretOptions struct { requestID string - accountID int32 + accountID int64 data map[string]string queries *database.Queries } @@ -31,7 +31,7 @@ func (s *Services) buildStoreAccountHMACSecretFn( logger := s.buildLogger(opts.requestID, accountHMACSecretsLocation, "buildStoreAccountHMACSecretFn") logger.InfoContext(ctx, "Building store function for account HMAC secret...") - return func(dekID string, secretID string, encryptedSecret string) (int32, *exceptions.ServiceError) { + return func(dekID string, secretID string, encryptedSecret string) (int64, *exceptions.ServiceError) { id, err := s.mapQueries(opts.queries).CreateAccountHMACSecret(ctx, database.CreateAccountHMACSecretParams{ AccountID: opts.accountID, SecretID: secretID, @@ -53,7 +53,7 @@ func (s *Services) buildStoreAccountHMACSecretFn( type BuildGetHMACSecretFNOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } @@ -98,7 +98,7 @@ func (s *Services) BuildGetHMACSecretFN( type BuildUpdateHMACSecretFNOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } @@ -138,7 +138,7 @@ func (s *Services) BuildUpdateHMACSecretFN( type BuildGetHMACSecretByIDFNOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } diff --git a/idp/internal/services/accounts.go b/idp/internal/services/accounts.go index c272f55..82bd233 100644 --- a/idp/internal/services/accounts.go +++ b/idp/internal/services/accounts.go @@ -203,7 +203,7 @@ func (s *Services) GetAccountByEmail( type GetAccountByIDOptions struct { RequestID string - ID int32 + ID int64 } func (s *Services) GetAccountByID( @@ -299,7 +299,7 @@ func (s *Services) GetAccountByPublicIDAndVersion( func (s *Services) updateAccountEmailInDB( ctx context.Context, logger *slog.Logger, - accountID int32, + accountID int64, oldEmail string, newEmail string, ) (database.Account, error) { @@ -560,7 +560,7 @@ func (s *Services) ConfirmUpdateAccountEmail( func (s *Services) updateAccountPasswordInDB( ctx context.Context, logger *slog.Logger, - accountID int32, + accountID int64, hashedPassword string, ) (database.Account, error) { var password pgtype.Text @@ -1347,7 +1347,7 @@ type GetAccountIDByUsernameOptions struct { func (s *Services) getAccountIDByUsername( ctx context.Context, opts GetAccountIDByUsernameOptions, -) (int32, *exceptions.ServiceError) { +) (int64, *exceptions.ServiceError) { logger := s.buildLogger(opts.RequestID, accountsLocation, "getAccountIDByUsername") logger.InfoContext(ctx, "Getting account ID by username...") @@ -1370,7 +1370,7 @@ func (s *Services) getAccountIDByUsername( func (s *Services) GetAndCacheAccountIDByUsername( ctx context.Context, opts GetAccountIDByUsernameOptions, -) (int32, *exceptions.ServiceError) { +) (int64, *exceptions.ServiceError) { logger := s.buildLogger(opts.RequestID, accountsLocation, "GetAndCacheAccountIDByUsername") logger.InfoContext(ctx, "Getting and caching account ID by username...") @@ -1415,7 +1415,7 @@ type GetAccountIDByPublicIDAndVersionOptions struct { func (s *Services) GetAccountIDByPublicIDAndVersion( ctx context.Context, opts GetAccountIDByPublicIDAndVersionOptions, -) (int32, *exceptions.ServiceError) { +) (int64, *exceptions.ServiceError) { logger := s.buildLogger(opts.RequestID, accountsLocation, "GetAccountIDByPublicIDAndVersion").With( "publicID", opts.PublicID, "version", opts.Version, diff --git a/idp/internal/services/app_dynamic_registration.go b/idp/internal/services/app_dynamic_registration.go index 8e75ea5..8849f2d 100644 --- a/idp/internal/services/app_dynamic_registration.go +++ b/idp/internal/services/app_dynamic_registration.go @@ -122,7 +122,7 @@ func mapAppTokenEndpointAuthMethod( type mapAppRegistrationDataToDBParamsOptions struct { appType database.AppType accountPublicID uuid.UUID - accountID int32 + accountID int64 domain string requestID string tokenEndpointAuthMethod database.AuthMethod @@ -309,7 +309,7 @@ type CreateAppCredentialsRegistrationOptions struct { // InitialAccessTokenDomain comes only from the verified IAT, never client metadata. InitialAccessTokenDomain string RequestID string - AccountID int32 + AccountID int64 IsAuthenticated bool AccountVersion int32 ApplicationType string @@ -670,7 +670,7 @@ func (s *Services) createAppCredentialsRegistration( return s.finalizeRegisteredApp(ctx, qrs, opts, accountDTO, &app, "", dbPrms.ExpiresAt, jwk) case database.AuthMethodClientSecretBasic, database.AuthMethodClientSecretPost, database.AuthMethodClientSecretJwt: - var ccID int32 + var ccID int64 var secretID, secret string var exp time.Time ccID, secretID, secret, exp, serviceErr = s.clientCredentialsSecret(ctx, qrs, clientCredentialsSecretOptions{ diff --git a/idp/internal/services/app_dynamic_registration_configs.go b/idp/internal/services/app_dynamic_registration_configs.go index a7a4ddf..fac64bc 100644 --- a/idp/internal/services/app_dynamic_registration_configs.go +++ b/idp/internal/services/app_dynamic_registration_configs.go @@ -26,7 +26,7 @@ const ( appDynamicRegistrationConfigCacheTTL time.Duration = 24 * time.Hour ) -func buildAppDynamicRegistrationConfigCacheKey(accountID int32) string { +func buildAppDynamicRegistrationConfigCacheKey(accountID int64) string { return fmt.Sprintf("%s:%d", appDynamicRegistrationConfigsLocation, accountID) } @@ -324,7 +324,7 @@ func (s *Services) GetAppDynamicRegistrationConfig( type GetAndCacheAppDynamicRegistrationConfigOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) GetAndCacheAppDynamicRegistrationConfig( diff --git a/idp/internal/services/app_dynamic_registration_iat.go b/idp/internal/services/app_dynamic_registration_iat.go index 19064b2..fdf368f 100644 --- a/idp/internal/services/app_dynamic_registration_iat.go +++ b/idp/internal/services/app_dynamic_registration_iat.go @@ -101,7 +101,7 @@ func (s *Services) CreateAppCredentialsRegistrationIAT( type ProcessAppDynamicRegistrationIATAuthOptions struct { RequestID string AuthHeader string - AccountID int32 + AccountID int64 IssuerDomain string } @@ -218,7 +218,7 @@ func (s *Services) CreateAppCredentialsRegistrationAccessToken( type ProcessAppDynamicRegistrationAccessTokenOptions struct { RequestID string AuthHeader string - AccountID int32 + AccountID int64 IssuerDomain string } diff --git a/idp/internal/services/app_users.go b/idp/internal/services/app_users.go index ba06fb0..e7a5d63 100644 --- a/idp/internal/services/app_users.go +++ b/idp/internal/services/app_users.go @@ -23,8 +23,8 @@ const appUsersLocation string = "app_users" type CreateAppUserOptions struct { RequestID string - AccountID int32 - AppID int32 + AccountID int64 + AppID int64 Email string Username string Password string @@ -161,8 +161,8 @@ func (s *Services) CreateAppUser( type ConfirmAppUserOptions struct { RequestID string - AccountID int32 - AppID int32 + AccountID int64 + AppID int64 UserPublicID uuid.UUID UserVersion int32 } diff --git a/idp/internal/services/apps.go b/idp/internal/services/apps.go index d06d2f3..4fecb08 100644 --- a/idp/internal/services/apps.go +++ b/idp/internal/services/apps.go @@ -70,7 +70,7 @@ func (s *Services) GetAppByClientIDAndAccountPublicID( type GetAppByClientIDAndAccountIDOptions struct { RequestID string ClientID string - AccountID int32 + AccountID int64 } func (s *Services) GetAppByClientIDAndAccountID( @@ -108,7 +108,7 @@ type GetAppByClientIDVersionAndAccountIDOptions struct { RequestID string ClientID string Version int32 - AccountID int32 + AccountID int64 } func (s *Services) GetAppByClientIDVersionAndAccountID( @@ -571,7 +571,7 @@ func mapAuthProviders(authProviders []string) ([]database.AuthProvider, *excepti type checkForDuplicateAppsOptions struct { requestID string - accountID int32 + accountID int64 name string softwareID string } @@ -616,7 +616,7 @@ func (s *Services) checkForDuplicateApps( type createAppOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID creationMethod database.CreationMethod appType database.AppType @@ -1000,7 +1000,7 @@ func (s *Services) CreateWebApp( logger.InfoContext(ctx, "Created web app successfully with private key JWT auth method successfully") return dtos.MapWebAppWithJWKToDTO(&app, jwk, clientKey.ExpiresAt), nil case AuthMethodClientSecretPost, AuthMethodClientSecretBasic, AuthMethodClientSecretJWT: - var ccID int32 + var ccID int64 var secretID, secret string var exp time.Time ccID, secretID, secret, exp, serviceErr = s.clientCredentialsSecret(ctx, qrs, clientCredentialsSecretOptions{ @@ -1072,9 +1072,18 @@ func (s *Services) CreateNativeApp( ) logger.InfoContext(ctx, "Creating native app...") - responseTypes, serviceErr := mapResponseTypesWithDefault(opts.ResponseTypes) - if serviceErr != nil { - logger.ErrorContext(ctx, "Failed to map response types", "serviceError", serviceErr) + var responseTypes []database.ResponseType + if len(opts.ResponseTypes) == 0 { + responseTypes = []database.ResponseType{database.ResponseTypeCode} + } else { + var serviceErr *exceptions.ServiceError + responseTypes, serviceErr = mapResponseTypesWithDefault(opts.ResponseTypes) + if serviceErr != nil { + logger.ErrorContext(ctx, "Failed to map response types", "serviceError", serviceErr) + return dtos.AppDTO{}, serviceErr + } + } + if serviceErr := validateAppGrantResponseTypes(authCodeAppGrantTypes, responseTypes); serviceErr != nil { return dtos.AppDTO{}, serviceErr } @@ -1375,7 +1384,7 @@ func validateAppGrantResponseTypes(grantTypes []database.GrantType, responseType type UpdateWebNativeAppOptions struct { RequestID string - AccountID int32 + AccountID int64 UsernameColumn string Name string Domain string @@ -1507,7 +1516,7 @@ func (s *Services) GetAppWithRelatedConfigs( type listAppKeysOptions struct { requestID string - appID int32 + appID int64 offset int32 limit int32 } @@ -1559,7 +1568,7 @@ func (s *Services) listAppKeys( type listAppSecretsOptions struct { requestID string - appID int32 + appID int64 offset int32 limit int32 } @@ -1661,7 +1670,7 @@ func (s *Services) ListAppCredentialsSecretsOrKeys( type getAppKeyByIDOptions struct { requestID string - appID int32 + appID int64 publicKID string } @@ -1698,7 +1707,7 @@ func (s *Services) getAppKeyByID( type getAppSecretByIDOptions struct { requestID string - appID int32 + appID int64 secretID string } @@ -1794,7 +1803,7 @@ func (s *Services) GetAppCredentialsSecretOrKey( type revokeAppSecretOptions struct { requestID string - appID int32 + appID int64 secretID string } @@ -1824,7 +1833,7 @@ func (s *Services) revokeAppSecret( type revokeAppKeyOptions struct { requestID string - appID int32 + appID int64 publicKID string } @@ -1925,9 +1934,9 @@ func (s *Services) RevokeAppCredentialsSecretOrKey( type rotateAppKeyOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID - appID int32 + appID int64 cryptoSuite utils.SupportedCryptoSuite } @@ -1984,8 +1993,8 @@ func (s *Services) rotateAppKey( type rotateAppSecretOptions struct { requestID string - accountID int32 - appID int32 + accountID int64 + appID int64 authMethod database.AuthMethod } diff --git a/idp/internal/services/apps_auth.go b/idp/internal/services/apps_auth.go index b2c72d0..c7bc245 100644 --- a/idp/internal/services/apps_auth.go +++ b/idp/internal/services/apps_auth.go @@ -19,7 +19,7 @@ const appsAuthLocation string = "apps_auth" type ProcessAppAuthHeaderOptions struct { RequestID string AuthHeader string - AccountID int32 + AccountID int64 } func (s *Services) ProcessAppAuthHeader( diff --git a/idp/internal/services/auth.go b/idp/internal/services/auth.go index 97333f2..4366581 100644 --- a/idp/internal/services/auth.go +++ b/idp/internal/services/auth.go @@ -247,7 +247,7 @@ func validateScopes( type upsertAccountGrantSessionAndTokenOptions struct { requestID string - accountID int32 + accountID int64 accountVersion int32 accountPublicID uuid.UUID scopes []tokens.AccountScope @@ -344,7 +344,7 @@ func (s *Services) createAccountGrantSessionAndToken( } if accountCredentialsDTO.ID() > 0 { - var accountCredentialsID pgtype.Int4 + var accountCredentialsID pgtype.Int8 if err = accountCredentialsID.Scan(accountCredentialsDTO.ID()); err != nil { logger.ErrorContext(ctx, "Failed to scan account credentials ID", "error", err) return exceptions.NewInternalServerError() @@ -393,7 +393,7 @@ func (s *Services) createAccountGrantSessionAndToken( type createAccountSessionAndTokenOptions struct { requestID string - accountID int32 + accountID int64 accountVersion int32 accountPublicID uuid.UUID scopes []tokens.AccountScope @@ -402,7 +402,7 @@ type createAccountSessionAndTokenOptions struct { clientID utils.Base62UUIDStr ipAddress string userAgent string - grantID int32 + grantID int64 } func (s *Services) createAccountSessionAndToken( @@ -471,7 +471,7 @@ func (s *Services) createAccountSessionAndToken( } if accountCredentialsDTO.ID() > 0 { - var accountCredentialsID pgtype.Int4 + var accountCredentialsID pgtype.Int8 if err = accountCredentialsID.Scan(accountCredentialsDTO.ID()); err != nil { logger.ErrorContext(ctx, "Failed to scan account credentials ID", "error", err) return exceptions.NewInternalServerError() @@ -611,7 +611,7 @@ func (s *Services) upsertAccountGrantSessionAndToken( type generateFullAuthDTOOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID accountVersion int32 sessionID uuid.UUID @@ -973,7 +973,7 @@ func (s *Services) buildGetAccountTOTPFn( logger := s.buildLogger(requestID, authLocation, "buildGetAccountTOTPFn") logger.InfoContext(ctx, "Building GetAccountTOTP function...") - return func(ownerID int32) (crypto.DEKCiphertext, *exceptions.ServiceError) { + return func(ownerID int64) (crypto.DEKCiphertext, *exceptions.ServiceError) { logger.InfoContext(ctx, "Getting TOTP secret...") accountTOTP, err := s.database.FindAccountTotpByAccountID(ctx, ownerID) if err != nil { @@ -1005,13 +1005,13 @@ func (s *Services) buildUpdateAccountTOTPDEKFn( secret crypto.DEKCiphertext, ) *exceptions.ServiceError { logger.InfoContext(ctx, "Updating TOTP secret...") - intID, err := strconv.ParseInt(accountID, 10, 32) + intID, err := strconv.ParseInt(accountID, 10, 64) if err != nil { logger.ErrorContext(ctx, "Failed to parse account ID", "error", err) return exceptions.NewInternalServerError() } - accountTOTP, err := s.database.FindAccountTotpByAccountID(ctx, int32(intID)) + accountTOTP, err := s.database.FindAccountTotpByAccountID(ctx, intID) if err != nil { logger.ErrorContext(ctx, "Failed to find account TOTP", "error", err) return exceptions.FromDBError(err) @@ -1033,7 +1033,7 @@ func (s *Services) buildUpdateAccountTOTPDEKFn( type VerifyAccountTotpOptions struct { RequestID string - ID int32 + ID int64 Code string } @@ -1082,7 +1082,7 @@ func mapTokens2FAType(twoFAType tokens.TwoFAType) (database.TwoFactorType, *exce type verifyAccount2FAInternalOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID accountVersion int32 twoFAType tokens.TwoFAType @@ -1534,7 +1534,7 @@ func (s *Services) buildGetAccountRecoveryCodesFn( logger := s.buildLogger(requestID, authLocation, "buildGetAccountRecoveryCodesFn") logger.InfoContext(ctx, "Building GetAccountRecoveryCodes function...") - return func(ownerID int32) ([]byte, *exceptions.ServiceError) { + return func(ownerID int64) ([]byte, *exceptions.ServiceError) { logger.InfoContext(ctx, "Getting recovery codes...") accountTOTP, err := s.database.FindAccountTotpByAccountID(ctx, ownerID) if err != nil { @@ -1555,7 +1555,7 @@ func (s *Services) buildGetAccountRecoveryCodesFn( type buildUpdateAccountTOTPFnOptions struct { requestID string - accountID int32 + accountID int64 } func (s *Services) buildUpdateAccountTOTPFn( diff --git a/idp/internal/services/client_credentials.go b/idp/internal/services/client_credentials.go index b37765b..9d7ba32 100644 --- a/idp/internal/services/client_credentials.go +++ b/idp/internal/services/client_credentials.go @@ -41,7 +41,7 @@ const ( type clientCredentialsSecretOptions struct { requestID string - accountID int32 + accountID int64 expiresIn time.Duration usage database.CredentialsUsage dekFN crypto.GetDEKtoEncrypt @@ -51,7 +51,7 @@ func (s *Services) clientCredentialsSecret( ctx context.Context, qrs *database.Queries, opts clientCredentialsSecretOptions, -) (int32, string, string, time.Time, *exceptions.ServiceError) { +) (int64, string, string, time.Time, *exceptions.ServiceError) { logger := s.buildLogger(opts.requestID, clientCredentialsLocation, "clientCredentialsSecret").With( "accountId", opts.accountID, "usage", opts.usage, @@ -105,7 +105,7 @@ func mapAlgorithmToTokenCryptoSuite(algorithm string) utils.SupportedCryptoSuite type clientCredentialsKeyOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID expiresIn time.Duration usage database.CredentialsUsage diff --git a/idp/internal/services/deks.go b/idp/internal/services/deks.go index 301e102..6282f83 100644 --- a/idp/internal/services/deks.go +++ b/idp/internal/services/deks.go @@ -57,7 +57,7 @@ func (s *Services) buildStoreGlobalDEKfn( ) crypto.StoreDEK { logger := s.buildLogger(requestID, deksLocation, "storeGlobalDEK") logger.InfoContext(ctx, "Building store function for global DEK...") - return func(dekID string, encryptedDEK string, kekID uuid.UUID) (int32, *exceptions.ServiceError) { + return func(dekID string, encryptedDEK string, kekID uuid.UUID) (int64, *exceptions.ServiceError) { qrs := s.mapQueries(queries) dekEnt, err := qrs.CreateDataEncryptionKey(ctx, database.CreateDataEncryptionKeyParams{ Kid: dekID, @@ -214,7 +214,7 @@ func (s *Services) BuildGetGlobalDecDEKFn( type buildStoreAccountDEKOptions struct { requestID string - accountID int32 + accountID int64 data map[string]string queries *database.Queries } @@ -226,7 +226,7 @@ func (s *Services) buildStoreAccountDEKfn( logger := s.buildLogger(opts.requestID, deksLocation, "buildStoreAccountDEKfn") logger.InfoContext(ctx, "Building store function for account DEK...") - return func(dekID string, encryptedDEK string, kekID uuid.UUID) (int32, *exceptions.ServiceError) { + return func(dekID string, encryptedDEK string, kekID uuid.UUID) (int64, *exceptions.ServiceError) { var qrs *database.Queries var txn pgx.Tx var err error @@ -288,7 +288,7 @@ func (s *Services) buildStoreAccountDEKfn( type BuildGetEncAccountDEKOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } @@ -396,7 +396,7 @@ func (s *Services) BuildGetEncAccountDEKfn( type BuildGetDecAccountDEKFnOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } diff --git a/idp/internal/services/dtos/account.go b/idp/internal/services/dtos/account.go index f2d0dcc..09963a0 100644 --- a/idp/internal/services/dtos/account.go +++ b/idp/internal/services/dtos/account.go @@ -19,13 +19,13 @@ type AccountDTO struct { Email string `json:"email"` Username string `json:"username"` - id int32 + id int64 version int32 emailVerified bool password string } -func (a *AccountDTO) ID() int32 { +func (a *AccountDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/account_2fa_config.go b/idp/internal/services/dtos/account_2fa_config.go index e830286..b1d7b24 100644 --- a/idp/internal/services/dtos/account_2fa_config.go +++ b/idp/internal/services/dtos/account_2fa_config.go @@ -27,7 +27,7 @@ type Account2FACodeConfigDTO struct { } type Account2FAConfigDTO struct { - id int32 + id int64 TwoFactorType database.TwoFactorType `json:"two_factor_type"` IsDefault bool `json:"is_default"` @@ -109,7 +109,7 @@ func (a *Account2FAConfigDTO) UnmarshalJSON(data []byte) error { return nil } -func (a *Account2FAConfigDTO) ID() int32 { +func (a *Account2FAConfigDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/account_credentials.go b/idp/internal/services/dtos/account_credentials.go index f011535..6678f76 100644 --- a/idp/internal/services/dtos/account_credentials.go +++ b/idp/internal/services/dtos/account_credentials.go @@ -62,15 +62,15 @@ type AccountCredentialsDTO struct { ClientSecretJWK utils.JWK `json:"client_secret_jwk,omitempty"` ClientSecretExp int64 `json:"client_secret_expires_at,omitempty"` - id int32 - accountId int32 + id int64 + accountId int64 } -func (ak *AccountCredentialsDTO) AccountID() int32 { +func (ak *AccountCredentialsDTO) AccountID() int64 { return ak.accountId } -func (ak *AccountCredentialsDTO) ID() int32 { +func (ak *AccountCredentialsDTO) ID() int64 { return ak.id } diff --git a/idp/internal/services/dtos/account_dynamic_registration_config.go b/idp/internal/services/dtos/account_dynamic_registration_config.go index 92254cb..066b485 100644 --- a/idp/internal/services/dtos/account_dynamic_registration_config.go +++ b/idp/internal/services/dtos/account_dynamic_registration_config.go @@ -9,7 +9,7 @@ package dtos import "github.com/tugascript/devlogs/idp/internal/providers/database" type AccountDynamicRegistrationConfigDTO struct { - id int32 + id int64 CredentialsTypes []database.AccountCredentialsType `json:"credentials_types"` RequireSoftwareStatementCredentialTypes []database.AccountCredentialsType `json:"require_software_statement_credential_types"` @@ -17,7 +17,7 @@ type AccountDynamicRegistrationConfigDTO struct { SoftwareStatementVerificationMethods []database.SoftwareStatementVerificationMethod `json:"software_statement_verification_methods"` } -func (a *AccountDynamicRegistrationConfigDTO) ID() int32 { +func (a *AccountDynamicRegistrationConfigDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/app.go b/idp/internal/services/dtos/app.go index 36aac22..513b140 100644 --- a/idp/internal/services/dtos/app.go +++ b/idp/internal/services/dtos/app.go @@ -17,8 +17,8 @@ import ( type AppDTO struct { Registration *ClientRegistrationDTO `json:"-"` - id int32 - accountID int32 + id int64 + accountID int64 version int32 AppType database.AppType `json:"app_type"` @@ -52,14 +52,13 @@ type AppDTO struct { ClientSecret string `json:"client_secret,omitempty"` ClientSecretJWK utils.JWK `json:"client_secret_jwk,omitempty"` ClientSecretExp int64 `json:"client_secret_exp,omitempty"` - } -func (a *AppDTO) ID() int32 { +func (a *AppDTO) ID() int64 { return a.id } -func (a *AppDTO) AccountID() int32 { +func (a *AppDTO) AccountID() int64 { return a.accountID } diff --git a/idp/internal/services/dtos/app_design.go b/idp/internal/services/dtos/app_design.go index 39eeaf2..68eb5dc 100644 --- a/idp/internal/services/dtos/app_design.go +++ b/idp/internal/services/dtos/app_design.go @@ -26,10 +26,10 @@ type AppDesignDTO struct { LogoURL string `json:"logo_url,omitempty"` FaviconURL string `json:"favicon_url,omitempty"` - id int32 + id int64 } -func (a *AppDesignDTO) ID() int32 { +func (a *AppDesignDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/app_dynamic_registration_config.go b/idp/internal/services/dtos/app_dynamic_registration_config.go index 168fbc6..c77cb43 100644 --- a/idp/internal/services/dtos/app_dynamic_registration_config.go +++ b/idp/internal/services/dtos/app_dynamic_registration_config.go @@ -9,7 +9,7 @@ package dtos import "github.com/tugascript/devlogs/idp/internal/providers/database" type AppDynamicRegistrationConfigDTO struct { - id int32 + id int64 AllowedAppTypes []database.AppType `json:"allowed_app_types"` WhitelistedDomains []string `json:"whitelisted_domains"` @@ -31,7 +31,7 @@ type AppDynamicRegistrationConfigDTO struct { MaxRedirectUris int32 `json:"max_redirect_uris"` } -func (a *AppDynamicRegistrationConfigDTO) ID() int32 { +func (a *AppDynamicRegistrationConfigDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/auth_provider.go b/idp/internal/services/dtos/auth_provider.go index 64b34b3..9c61700 100644 --- a/idp/internal/services/dtos/auth_provider.go +++ b/idp/internal/services/dtos/auth_provider.go @@ -16,10 +16,10 @@ type AuthProviderDTO struct { Provider database.AuthProvider `json:"provider"` RegisteredAt string `json:"registered_at"` - id int32 + id int64 } -func (a *AuthProviderDTO) ID() int32 { +func (a *AuthProviderDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/client_credentials_secrets.go b/idp/internal/services/dtos/client_credentials_secrets.go index 423dcdd..8190bc0 100644 --- a/idp/internal/services/dtos/client_credentials_secrets.go +++ b/idp/internal/services/dtos/client_credentials_secrets.go @@ -26,7 +26,7 @@ const ( ) type ClientCredentialsSecretDTO struct { - id int32 + id int64 PublicID string `json:"id"` ClientSecret string `json:"client_secret,omitempty"` @@ -69,7 +69,7 @@ func (s *ClientCredentialsSecretDTO) UnmarshalJSON(data []byte) error { return nil } -func (s *ClientCredentialsSecretDTO) ID() int32 { +func (s *ClientCredentialsSecretDTO) ID() int64 { return s.id } @@ -95,7 +95,7 @@ func MapCredentialsSecretToDTO( } func CreateCredentialsSecretToDTOWithSecret( - id int32, + id int64, secretID string, secret string, exp time.Time, diff --git a/idp/internal/services/dtos/dynamic_registration_domain.go b/idp/internal/services/dtos/dynamic_registration_domain.go index 509b335..98c318e 100644 --- a/idp/internal/services/dtos/dynamic_registration_domain.go +++ b/idp/internal/services/dtos/dynamic_registration_domain.go @@ -14,7 +14,7 @@ import ( ) type DynamicRegistrationDomainDTO struct { - id int32 + id int64 Domain string `json:"domain"` Verified bool `json:"verified"` @@ -28,7 +28,7 @@ type DynamicRegistrationDomainDTO struct { VerificationCodeExpiresAt int64 `json:"verification_code_expires_at,omitempty"` } -func (a *DynamicRegistrationDomainDTO) ID() int32 { +func (a *DynamicRegistrationDomainDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/dynamic_registration_domain_code.go b/idp/internal/services/dtos/dynamic_registration_domain_code.go index 7fd4ce6..4e60f01 100644 --- a/idp/internal/services/dtos/dynamic_registration_domain_code.go +++ b/idp/internal/services/dtos/dynamic_registration_domain_code.go @@ -14,7 +14,7 @@ import ( ) type DynamicRegistrationDomainCodeDTO struct { - id int32 + id int64 VerificationHost string `json:"verification_host"` VerificationPrefix string `json:"verification_prefix"` @@ -23,7 +23,7 @@ type DynamicRegistrationDomainCodeDTO struct { VerificationCodeExpiresAt int64 `json:"verification_code_expires_at"` } -func (a *DynamicRegistrationDomainCodeDTO) ID() int32 { +func (a *DynamicRegistrationDomainCodeDTO) ID() int64 { return a.id } diff --git a/idp/internal/services/dtos/oidc_configs.go b/idp/internal/services/dtos/oidc_configs.go index 192d503..254e30e 100644 --- a/idp/internal/services/dtos/oidc_configs.go +++ b/idp/internal/services/dtos/oidc_configs.go @@ -11,10 +11,10 @@ type OIDCConfigDTO struct { CustomClaims []string `json:"custom_claims"` CustomScopes []string `json:"custom_scopes"` - id int32 + id int64 } -func (u *OIDCConfigDTO) ID() int32 { +func (u *OIDCConfigDTO) ID() int64 { return u.id } diff --git a/idp/internal/services/dtos/user.go b/idp/internal/services/dtos/user.go index 22ce422..44134ba 100644 --- a/idp/internal/services/dtos/user.go +++ b/idp/internal/services/dtos/user.go @@ -21,13 +21,13 @@ type UserDTO struct { Username string `json:"username"` DataDTO - id int32 + id int64 version int32 emailVerified bool password string } -func (u *UserDTO) ID() int32 { +func (u *UserDTO) ID() int64 { return u.id } diff --git a/idp/internal/services/jwks.go b/idp/internal/services/jwks.go index 047e337..3df65a5 100644 --- a/idp/internal/services/jwks.go +++ b/idp/internal/services/jwks.go @@ -103,7 +103,7 @@ func (s *Services) buildStoreGlobalJWKfn( ) crypto.StorePrivateKey { logger := s.buildLogger(opts.requestID, jwkLocation, "buildStoreGlobalJWKfn") logger.InfoContext(ctx, "Building store global JWK function...") - return func(dekKid string, cryptoSuite utils.SupportedCryptoSuite, kid, encryptedKey string, pubKey utils.JWK) (int32, *exceptions.ServiceError) { + return func(dekKid string, cryptoSuite utils.SupportedCryptoSuite, kid, encryptedKey string, pubKey utils.JWK) (int64, *exceptions.ServiceError) { dbCryptoSuite, err := mapCryptoSuite(cryptoSuite) if err != nil { logger.ErrorContext(ctx, "Failed to map crypto suite", "error", err) @@ -403,7 +403,7 @@ func (s *Services) GetAndCacheGlobalDistributedJWK( type buildStoreAccountJWKfnOptions struct { requestID string - accountID int32 + accountID int64 keyType database.TokenKeyType data map[string]string } @@ -420,7 +420,7 @@ func (s *Services) buildStoreAccountJWKfn( cryptoSuite utils.SupportedCryptoSuite, kid, encryptedKey string, pubKey utils.JWK, - ) (int32, *exceptions.ServiceError) { + ) (int64, *exceptions.ServiceError) { dbCryptoSuite, err := mapCryptoSuite(cryptoSuite) if err != nil { logger.ErrorContext(ctx, "Failed to map crypto suite", "error", err) @@ -491,7 +491,7 @@ func (s *Services) buildStoreAccountJWKfn( type BuildGetEncryptedAccountJWKFnOptions struct { RequestID string KeyType database.TokenKeyType - AccountID int32 + AccountID int64 } func (s *Services) BuildGetEncryptedAccountJWKFn( @@ -615,7 +615,7 @@ func (s *Services) BuildGetEncryptedAccountJWKFn( type BuildGetAccountPublicKeyFnOptions struct { RequestID string - AccountID int32 + AccountID int64 KeyType database.TokenKeyType } @@ -698,7 +698,7 @@ func (s *Services) BuildGetAccountPublicKeyFn( type GetAndCacheAccountDistributedJWKOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) GetAndCacheAccountDistributedJWK( diff --git a/idp/internal/services/keks.go b/idp/internal/services/keks.go index c8a6470..5806c0d 100644 --- a/idp/internal/services/keks.go +++ b/idp/internal/services/keks.go @@ -31,7 +31,7 @@ func (s *Services) createAndCacheGlobalKEK( _, keyID, err := s.crypto.GenerateKEK(ctx, crypto.GenerateKEKOptions{ RequestID: requestID, - StoreFN: func(keyID uuid.UUID) (int32, error) { + StoreFN: func(keyID uuid.UUID) (int64, error) { return s.database.CreateKeyEncryptionKey(ctx, database.CreateKeyEncryptionKeyParams{ Kid: keyID, Usage: database.KekUsageGlobal, @@ -104,7 +104,7 @@ func (s *Services) getAndCacheGlobalKEK( if _, _, err := s.crypto.RotateKEK(ctx, crypto.RotateKEKOptions{ RequestID: requestID, KEKid: kekEntity.Kid, - StoreFN: func(_ uuid.UUID) (int32, error) { + StoreFN: func(_ uuid.UUID) (int64, error) { return s.database.RotateKeyEncryptionKey(ctx, database.RotateKeyEncryptionKeyParams{ ID: kekEntity.ID, NextRotationAt: time.Now().Add(s.kekExpDays), @@ -152,7 +152,7 @@ func (s *Services) GetOrCreateGlobalKEK( type createAndCacheAccountKEKOptions struct { requestID string - accountID int32 + accountID int64 queries *database.Queries } @@ -183,7 +183,7 @@ func (s *Services) createAndCacheAccountKEK( dbID, keyID, err := s.crypto.GenerateKEK(ctx, crypto.GenerateKEKOptions{ RequestID: opts.requestID, - StoreFN: func(keyID uuid.UUID) (int32, error) { + StoreFN: func(keyID uuid.UUID) (int64, error) { return qrs.CreateKeyEncryptionKey(ctx, database.CreateKeyEncryptionKeyParams{ Kid: keyID, Usage: database.KekUsageAccount, @@ -221,7 +221,7 @@ func (s *Services) createAndCacheAccountKEK( type getAndCacheAccountKEKOptions struct { requestID string - accountID int32 + accountID int64 queries *database.Queries } @@ -277,7 +277,7 @@ func (s *Services) getAndCacheAccountKEK( if _, _, err := s.crypto.RotateKEK(ctx, crypto.RotateKEKOptions{ RequestID: opts.requestID, KEKid: kekEntity.Kid, - StoreFN: func(_ uuid.UUID) (int32, error) { + StoreFN: func(_ uuid.UUID) (int64, error) { return qrs.RotateKeyEncryptionKey(ctx, database.RotateKeyEncryptionKeyParams{ ID: kekEntity.ID, NextRotationAt: time.Now().Add(s.kekExpDays), @@ -302,7 +302,7 @@ func (s *Services) getAndCacheAccountKEK( type GetOrCreateAccountKEKOptions struct { RequestID string - AccountID int32 + AccountID int64 Queries *database.Queries } diff --git a/idp/internal/services/oauth.go b/idp/internal/services/oauth.go index 33bb31d..35c20ec 100644 --- a/idp/internal/services/oauth.go +++ b/idp/internal/services/oauth.go @@ -41,7 +41,7 @@ var oauthScopes = []oauth.Scope{oauth.ScopeProfile} type ImplicitOAuthAuthorizationOptions struct { RequestID string - AccountID int32 + AccountID int64 AccountUsername string BackendDomain string ClientID string diff --git a/idp/internal/services/oauth_dynamic_registration_apps.go b/idp/internal/services/oauth_dynamic_registration_apps.go index a3e3274..2a69bd1 100644 --- a/idp/internal/services/oauth_dynamic_registration_apps.go +++ b/idp/internal/services/oauth_dynamic_registration_apps.go @@ -30,7 +30,7 @@ const oauthDynamicRegistrationAppsLocation string = "oauth_dynamic_registration_ // Hostname and AccountID must come from the trusted host middleware, never from // registration form fields. Both are required to avoid an unscoped cache flow. -func validateAppsRegistrationTenant(hostname string, accountID int32) *exceptions.ServiceError { +func validateAppsRegistrationTenant(hostname string, accountID int64) *exceptions.ServiceError { if hostname == "" || accountID <= 0 { return exceptions.NewUnauthorizedError() } @@ -47,7 +47,7 @@ type refreshTokenAppsOAuthDynamicRegistrationIATLoginOptions struct { state string backendDomain string hostname string - accountID int32 + accountID int64 } func (s *Services) refreshTokenAppsOAuthDynamicRegistrationIATLogin( @@ -197,7 +197,7 @@ type generateAppsOAuthDynamicRegistrationIATCallbackOptions struct { redirectURI string state string hostname string - accountID int32 + accountID int64 } func (s *Services) generateAppsOAuthDynamicRegistrationIATCallback( @@ -256,7 +256,7 @@ func (s *Services) generateAppsOAuthDynamicRegistrationIATCallback( }), nil } -func (s *Services) checkAppDynamicRegistrationDomainUsability(ctx context.Context, requestID string, accountID int32, domain string) *exceptions.ServiceError { +func (s *Services) checkAppDynamicRegistrationDomainUsability(ctx context.Context, requestID string, accountID int64, domain string) *exceptions.ServiceError { account, serviceErr := s.GetAccountByID(ctx, GetAccountByIDOptions{RequestID: requestID, ID: accountID}) if serviceErr != nil { return serviceErr @@ -272,7 +272,7 @@ type oauthAppsDynamicRegistrationIATAuthOptions struct { redirectURI string state string hostname string - accountID int32 + accountID int64 } func (s *Services) oauthAppsDynamicRegistrationIATAuth( @@ -343,7 +343,7 @@ type InitiateAppsOAuthDynamicRegistrationIATAuthOptions struct { RedirectURI string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) InitiateAppsOAuthDynamicRegistrationIATAuth( @@ -487,7 +487,7 @@ type AppsOAuthDynamicRegistrationIATAuthRenderOptions struct { CodeChallenge string CodeChallengeMethod string RedirectURI string - AccountID int32 + AccountID int64 Hostname string } @@ -582,7 +582,7 @@ type AppsOAuthDynamicRegistrationIATAuthReRenderOptions struct { CodeChallenge string CodeChallengeMethod string RedirectURI string - AccountID int32 + AccountID int64 Hostname string } @@ -641,7 +641,7 @@ type AppsOAuthDynamicRegistrationIATLoginOptions struct { Password string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) AppsOAuthDynamicRegistrationIATLogin( @@ -838,7 +838,7 @@ type AppsOAuthDynamicRegistrationIAT2FARenderOptions struct { ChallengeMethod string State string RedirectURI string - AccountID int32 + AccountID int64 Hostname string } @@ -924,7 +924,7 @@ type AppsOAuthDynamicRegistrationIAT2FAReRenderOptions struct { ChallengeMethod string State string RedirectURI string - AccountID int32 + AccountID int64 Hostname string } @@ -970,7 +970,7 @@ type AppsOAuthDynamicRegistrationIATVerify2FACodeOptions struct { Code string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) AppsOAuthDynamicRegistrationIATVerify2FACode( @@ -1099,7 +1099,7 @@ type VerifyAppsOAuthDynamicRegistrationIATCodeOptions struct { Code string CodeVerifier string Domain string - AccountID int32 + AccountID int64 Hostname string } @@ -1185,7 +1185,7 @@ type AppsOAuthDynamicRegistrationIATExtGetOptions struct { State string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) AppsOAuthDynamicRegistrationIATExtGet( @@ -1278,7 +1278,7 @@ type AppsOAuthDynamicRegistrationIATExtCBOptions struct { RedirectURL string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) AppsOAuthDynamicRegistrationIATExtCB( @@ -1430,7 +1430,7 @@ type AppsOAuthDynamicRegistrationIATExtAppleCBOptions struct { RedirectURL string BackendDomain string Hostname string - AccountID int32 + AccountID int64 } func (s *Services) AppsOAuthDynamicRegistrationIATExtAppleCB( diff --git a/idp/internal/services/oidc_configs.go b/idp/internal/services/oidc_configs.go index 8321921..0716de8 100644 --- a/idp/internal/services/oidc_configs.go +++ b/idp/internal/services/oidc_configs.go @@ -89,7 +89,7 @@ func (s *Services) CreateOIDCConfig( type GetOIDCConfigByAccountIDOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) GetOIDCConfigByAccountID( @@ -113,7 +113,7 @@ func (s *Services) GetOIDCConfigByAccountID( type createDefaultOIDCConfigOptions struct { requestID string - accountID int32 + accountID int64 } func (s *Services) createDefaultOIDCConfig( @@ -147,7 +147,7 @@ func (s *Services) createDefaultOIDCConfig( type GetOrCreateOIDCConfigOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) GetOrCreateOIDCConfig( @@ -281,7 +281,7 @@ func (s *Services) UpdateOIDCConfig( type GetOIDCConfigUserStructOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) GetOIDCConfigUserStruct( diff --git a/idp/internal/services/registration_credentials.go b/idp/internal/services/registration_credentials.go index 4fa06f7..dfc3efd 100644 --- a/idp/internal/services/registration_credentials.go +++ b/idp/internal/services/registration_credentials.go @@ -11,7 +11,7 @@ import ( "time" ) -func (s *Services) replaceRegistrationSecret(ctx context.Context, requestID string, accountID int32, publicID uuid.UUID, clientID int32, app bool) (string, time.Time, utils.JWK, *exceptions.ServiceError) { +func (s *Services) replaceRegistrationSecret(ctx context.Context, requestID string, accountID int64, publicID uuid.UUID, clientID int64, app bool) (string, time.Time, utils.JWK, *exceptions.ServiceError) { usage := database.CredentialsUsageAccount ttl := s.accountCCExpDays dek := s.BuildGetEncGlobalDEKFn(ctx, BuildGetGlobalDEKFnOptions{RequestID: requestID, Queries: s.database.Queries}) diff --git a/idp/internal/services/registration_management.go b/idp/internal/services/registration_management.go index a5a039e..de4873a 100644 --- a/idp/internal/services/registration_management.go +++ b/idp/internal/services/registration_management.go @@ -97,7 +97,7 @@ func (s *Services) registrationTokenValidator(ctx context.Context, app bool) fun // Bypass the JWK cache for registration authentication: explicit revocation must // take effect immediately. Signing-key expiry does not retire verification keys. -func (s *Services) registrationPublicKey(ctx context.Context, accountID int32) tokens.GetPublicJWK { +func (s *Services) registrationPublicKey(ctx context.Context, accountID int64) tokens.GetPublicJWK { return func(kid string, suite utils.SupportedCryptoSuite) (utils.JWK, error) { var row database.TokenSigningKey var err error @@ -125,7 +125,8 @@ func (s *Services) registrationPublicKey(ctx context.Context, accountID int32) t type registrationStateOptions struct { RequestID, ClientID, BackendDomain, HostUsername, Token, Statement string AccountPublicID uuid.UUID - AccountID, AccountVersion, ID int32 + AccountID, ID int64 + AccountVersion int32 Stored pgtype.UUID Queries *database.Queries App bool diff --git a/idp/internal/services/registration_metadata.go b/idp/internal/services/registration_metadata.go index 194fe87..be5d906 100644 --- a/idp/internal/services/registration_metadata.go +++ b/idp/internal/services/registration_metadata.go @@ -201,7 +201,7 @@ func validateSectorIdentifierHost(ctx context.Context, host string) ([]net.IPAdd type prepareDynamicRegistrationOptions struct { requestID string - accountID int32 + accountID int64 accountPublicID uuid.UUID data ApplicationRegistrationData softwareStatement string diff --git a/idp/internal/services/users.go b/idp/internal/services/users.go index 23f6786..65bf9fb 100644 --- a/idp/internal/services/users.go +++ b/idp/internal/services/users.go @@ -26,7 +26,7 @@ const usersLocation string = "users" func (s *Services) setUserUsername( ctx context.Context, logger *slog.Logger, - accountID int32, + accountID int64, username string, ) (string, *exceptions.ServiceError) { if username == "" { @@ -52,7 +52,7 @@ func (s *Services) setUserUsername( type CreateUserOptions struct { RequestID string - AccountID int32 + AccountID int64 Email string Username string Password string @@ -152,7 +152,7 @@ func (s *Services) CreateUser( type ListUsersOptions struct { RequestID string - AccountID int32 + AccountID int64 Offset int32 Limit int32 Order string @@ -230,7 +230,7 @@ func (s *Services) ListUsers( type FilterUsersOptions struct { RequestID string - AccountID int32 + AccountID int64 Offset int32 Limit int32 Order string @@ -320,8 +320,8 @@ func (s *Services) FilterUsers( type GetUserByIDOptions struct { RequestID string - UserID int32 - AccountID int32 + UserID int64 + AccountID int64 } func (s *Services) GetUserByID( @@ -358,7 +358,7 @@ func (s *Services) GetUserByID( type GetUserByPublicIDAndVersionOptions struct { RequestID string PublicID uuid.UUID - AccountID int32 + AccountID int64 Version int32 } @@ -399,7 +399,7 @@ func (s *Services) GetUserByPublicIDAndVersion( type GetUserByUsernameOptions struct { RequestID string - AccountID int32 + AccountID int64 Username string } @@ -435,8 +435,8 @@ func (s *Services) GetUserByUsername( type UpdateUserOptions struct { RequestID string - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 Email string Username string UserData reflect.Value @@ -525,8 +525,8 @@ func (s *Services) UpdateUser( type UpdateUserPasswordOptions struct { RequestID string - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 Password string } @@ -581,8 +581,8 @@ func (s *Services) UpdateUserPassword( type DeleteUserOptions struct { RequestID string - AccountID int32 - UserID int32 + AccountID int64 + UserID int64 } func (s *Services) DeleteUser( @@ -621,7 +621,7 @@ func (s *Services) DeleteUser( type GetUserByEmailOptions struct { RequestID string - AccountID int32 + AccountID int64 Email string } diff --git a/idp/internal/services/users_auth.go b/idp/internal/services/users_auth.go index 8c7d4a0..d81b54d 100644 --- a/idp/internal/services/users_auth.go +++ b/idp/internal/services/users_auth.go @@ -64,7 +64,7 @@ func mapPurposeTokenTypeToKeyType(tokenType tokens.PurposeTokenType) (database.T type ProcessUserAuthHeaderOptions struct { RequestID string AuthHeader string - AccountID int32 + AccountID int64 TokenType tokens.AuthTokenType } @@ -111,7 +111,7 @@ func (s *Services) ProcessUserAuthHeader( type ProcessUserPurposeHeaderOptions struct { RequestID string AuthHeader string - AccountID int32 + AccountID int64 TokenType tokens.PurposeTokenType } @@ -155,7 +155,7 @@ func (s *Services) ProcessUserPurposeHeader( type sendUserConfirmationEmailOptions struct { requestID string - accountID int32 + accountID int64 accountUsername string appVersion int32 appClientID string @@ -230,7 +230,7 @@ func (s *Services) sendUserConfirmationEmail( type RegisterUserOptions struct { RequestID string - AccountID int32 + AccountID int64 AccountUsername string AppClientID string AppVersion int32 @@ -301,7 +301,7 @@ func (s *Services) generateFullUserAuthDTO( ctx context.Context, logger *slog.Logger, requestID string, - accountID int32, + accountID int64, userDTO *dtos.UserDTO, appDTO *dtos.AppDTO, scopes []string, @@ -396,7 +396,7 @@ func (s *Services) generateFullUserAuthDTO( type ConfirmAuthUserOptions struct { RequestID string - AccountID int32 + AccountID int64 AccountUsername string AppClientID string AppVersion int32 @@ -482,7 +482,7 @@ func (s *Services) ConfirmAuthUser( type GetUserByUsernameOrEmailOptions struct { RequestID string - AccountID int32 + AccountID int64 UsernameColumn database.AppUsernameColumn UsernameOrEmail string } @@ -542,7 +542,7 @@ func (s *Services) GetUserByUsernameOrEmail( type LoginUserOptions struct { RequestID string - AccountID int32 + AccountID int64 AccountUsername string AppClientID string AppVersion int32 @@ -660,7 +660,7 @@ func (s *Services) LoginUser( type VerifyUserTOTPOptions struct { requestID string - userID int32 + userID int64 code string } @@ -677,7 +677,7 @@ func (s *Services) VerifyUserTOTP( RequestID: opts.requestID, Code: opts.code, OwnerID: opts.userID, - GetSecret: func(ownerID int32) (crypto.DEKCiphertext, *exceptions.ServiceError) { + GetSecret: func(ownerID int64) (crypto.DEKCiphertext, *exceptions.ServiceError) { userTOTP, err := s.database.FindUserTotpByUserID(ctx, opts.userID) if err != nil { serviceErr := exceptions.FromDBError(err) @@ -709,8 +709,8 @@ func (s *Services) VerifyUserTOTP( type VerifyUserEmailCodeOptions struct { requestID string - accountID int32 - userID int32 + accountID int64 + userID int64 code string } @@ -746,7 +746,7 @@ func (s *Services) VerifyUserEmailCode( type LogoutUserOptions struct { RequestID string - AccountID int32 + AccountID int64 AppClientID string AppVersion int32 UserPublicID uuid.UUID @@ -861,7 +861,7 @@ func (s *Services) LogoutUser( type RefreshUserAccessOptions struct { RequestID string - AccountID int32 + AccountID int64 AppClientID string AppVersion int32 AccountUsername string @@ -980,7 +980,7 @@ func (s *Services) RefreshUserAccess( type ForgotUserPasswordOptions struct { RequestID string - AccountID int32 + AccountID int64 AccountUsername string AppClientID string AppVersion int32 @@ -1103,7 +1103,7 @@ func (s *Services) ForgotUserPassword( type ResetUserPasswordOptions struct { RequestID string - AccountID int32 + AccountID int64 AppClientID string AppVersion int32 Password string diff --git a/idp/internal/services/well_known.go b/idp/internal/services/well_known.go index 6dd19ae..c2959d0 100644 --- a/idp/internal/services/well_known.go +++ b/idp/internal/services/well_known.go @@ -18,7 +18,7 @@ const wellKnownLocation = "well_known" type WellKnownJWKsOptions struct { RequestID string - AccountID int32 + AccountID int64 } func (s *Services) WellKnownJWKs( @@ -41,7 +41,7 @@ func (s *Services) WellKnownJWKs( type WellKnownOIDCConfigurationWithCacheOptions struct { RequestID string - AccountID int32 + AccountID int64 BackendDomain string AccountUsername string } diff --git a/idp/tests/dynamic_registration_test.go b/idp/tests/dynamic_registration_test.go index 31bc1b8..f47b7cf 100644 --- a/idp/tests/dynamic_registration_test.go +++ b/idp/tests/dynamic_registration_test.go @@ -102,7 +102,7 @@ func approveSoftwareStatementKey(t *testing.T, account dtos.AccountDTO, publicJS if err != nil { t.Fatal(err) } - var approvedID int32 + var approvedID int64 err = db.RawQueryRow(ctx, `INSERT INTO dynamic_registration_software_statement_keys (account_id,account_public_id,credentials_key_id,credentials_key_kid,root_domain) VALUES ($1,$2,$3,$4,$5) RETURNING id`, []interface{}{account.ID(), account.PublicID, key.ID, kid, "example.com"}).Scan(&approvedID) if err != nil { t.Fatal(err) @@ -123,7 +123,7 @@ type dcrSetup struct { func cleanupAccount(t *testing.T, account dtos.AccountDTO) { t.Helper() t.Cleanup(func() { - var id int32 + var id int64 if err := GetTestDatabase(t).RawQueryRow(context.Background(), `DELETE FROM accounts WHERE id=$1 RETURNING id`, []interface{}{account.ID()}).Scan(&id); err != nil { t.Errorf("cleanup account: %v", err) }