// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1

syntax = "proto3";

// Package store provides protobufs for storing types in the password package.
package controller.storage.auth.password.store.v1;

import "controller/custom_options/v1/options.proto";
import "controller/storage/timestamp/v1/timestamp.proto";

option go_package = "github.com/hashicorp/boundary/internal/auth/password/store;store";

message AuthMethod {
  // @inject_tag: `gorm:"primary_key"`
  string public_id = 1;

  // The create_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 2;

  // The update_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 3;

  // name is optional. If set, it must be unique within scope_id.
  // @inject_tag: `gorm:"default:null"`
  string name = 4 [(custom_options.v1.mask_mapping) = {
    this: "Name"
    that: "name"
  }];

  // description is optional.
  // @inject_tag: `gorm:"default:null"`
  string description = 5 [(custom_options.v1.mask_mapping) = {
    this: "Description"
    that: "description"
  }];

  // The scope_id of the owning scope. Must be set.
  // @inject_tag: `gorm:"not_null"`
  string scope_id = 6;

  // @inject_tag: `gorm:"default:null"`
  uint32 version = 7;

  // @inject_tag: `gorm:"not_null"`
  string password_conf_id = 8;

  // @inject_tag: `gorm:"default:null"`
  uint32 min_login_name_length = 9 [(custom_options.v1.mask_mapping) = {
    this: "MinLoginNameLength"
    that: "attributes.min_login_name_length"
  }];

  // @inject_tag: `gorm:"default:null"`
  uint32 min_password_length = 10 [(custom_options.v1.mask_mapping) = {
    this: "MinPasswordLength"
    that: "attributes.min_password_length"
  }];

  // is_primary_auth_method is a read-only output field which indicates if the
  // auth method is set as the scope's primary auth method.
  // @inject_tag: `gorm:"->"`
  bool is_primary_auth_method = 20;
}

message Account {
  // @inject_tag: `gorm:"primary_key"`
  string public_id = 1;

  // The create_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp create_time = 2;

  // The update_time is set by the database.
  // @inject_tag: `gorm:"default:current_timestamp"`
  timestamp.v1.Timestamp update_time = 3;

  // name is optional. If set, it must be unique within scope_id.
  // @inject_tag: `gorm:"default:null"`
  string name = 4 [(custom_options.v1.mask_mapping) = {
    this: "Name"
    that: "name"
  }];

  // description is optional.
  // @inject_tag: `gorm:"default:null"`
  string description = 5 [(custom_options.v1.mask_mapping) = {
    this: "Description"
    that: "description"
  }];

  // @inject_tag: `gorm:"default:null"`
  uint32 version = 6;

  // @inject_tag: `gorm:"not_null"`
  string auth_method_id = 7;

  // @inject_tag: `gorm:"not_null"`
  string login_name = 8 [(custom_options.v1.mask_mapping) = {
    this: "LoginName"
    that: "attributes.login_name"
  }];

  // the scope_id column is not included here as it is used only to ensure
  // data integrity in the database between iam users and auth methods.
}

message Credential {
  // @inject_tag: `gorm:"primary_key"`
  string private_id = 1;
  // @inject_tag: `gorm:"not_null"`
  string password_account_id = 2;
  // @inject_tag: `gorm:"not_null"`
  string password_conf_id = 3;
  // @inject_tag: `gorm:"not_null"`
  string password_method_id = 4;
}
