Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 108 additions & 108 deletions idp/initial_schema.dbml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions idp/internal/controllers/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion idp/internal/controllers/params/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ type GetUserURLParams struct {
}

type MutateUserURLParams struct {
UserID int32 `validate:"required,min=1"`
UserID int64 `validate:"required,min=1"`
}
10 changes: 5 additions & 5 deletions idp/internal/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions idp/internal/providers/cache/account_username.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (

type AddAccountUsernameOptions struct {
RequestID string
ID int32
ID int64
Username string
}

Expand All @@ -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,
)
}
Expand All @@ -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",
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions idp/internal/providers/cache/apps_dynamic_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -36,7 +36,7 @@ type AppsDynamicRegistrationIATAuthData struct {
type SaveAppsDynamicRegistrationIATAuthOptions struct {
RequestID string
Hostname string
AccountID int32
AccountID int64
Domain string
State string
RedirectURI string
Expand Down
10 changes: 5 additions & 5 deletions idp/internal/providers/cache/two_factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion idp/internal/providers/crypto/dek.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion idp/internal/providers/crypto/hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion idp/internal/providers/crypto/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions idp/internal/providers/crypto/kek.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions idp/internal/providers/crypto/totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
)
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions idp/internal/providers/database/account_2fa_configs.sql.go

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

20 changes: 10 additions & 10 deletions idp/internal/providers/database/account_credential_secrets.sql.go

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

Loading
Loading