Skip to content
Merged
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
12 changes: 12 additions & 0 deletions server/action/admin/user/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"time"

"github.com/factly/kavach-server/model"
"github.com/factly/x/errorx"
Expand Down Expand Up @@ -50,6 +51,17 @@ func create(w http.ResponseWriter, r *http.Request) {
},
},
},
"verifiable_addresses": []map[string]interface{}{
{
"created_at": time.Now(),
"status": "completed",
"updated_at": time.Now(),
"value": user.Email,
"verified": true,
"verified_at": time.Now(),
"via": "email",
},
},
Comment on lines +54 to +64
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the schema against Kratos Admin API documentation.

The verifiable_addresses field structure must exactly match what the Kratos Admin API expects. Additionally, auto-verifying users bypasses the email verification flow, which may have security or compliance implications for your use case.

Please verify:

  1. The field names, types, and structure match the Kratos Admin API schema for your version
  2. The timestamp format (time.Now() serializes to RFC3339 in JSON) is compatible with Kratos
  3. All required fields are present and no unsupported fields are included
  4. Auto-verification aligns with your security and compliance requirements

Run the following script to check for other usages of verifiable_addresses in the codebase for reference:

Additionally, please verify the Kratos Admin API documentation for the identity creation endpoint:


🏁 Script executed:

#!/bin/bash
# Search for other usages of verifiable_addresses to verify schema consistency
rg -n -C5 'verifiable_addresses' --type=go

Length of output: 687


🌐 Web query:

Ory Kratos Admin API verifiable_addresses schema for identity creation

💡 Result:

You can set verifiable addresses when creating/importing an identity via the Admin API by including a verifiable_addresses array on the identity payload. Each address object uses these fields (examples from Ory Kratos docs):

  • value (string) — the address (e.g. email).
  • verified (boolean) — whether the address is already verified.
  • via (string) — channel, e.g. "email" or "sms".
  • status (string) — e.g. "pending" or "completed".
  • id, created_at, updated_at, verified_at (server-generated on return).

Example create/import payload:

{
"schema_id": "preset://email",
"traits": { "email": "user@example.org" },
"verifiable_addresses": [
{
"value": "user@example.org",
"verified": true,
"via": "email",
"status": "completed"
}
]
}

See Ory Kratos docs for creating/importing identities and verifiable addresses. [1][2]

Sources:
[1] Ory — Import user accounts / importing verified addresses (Admin identities).
[2] Ory — Create/manage identities (example responses showing verifiable_addresses).


Remove server-generated fields from verifiable_addresses payload.

The Kratos Admin API documentation states that id, created_at, updated_at, verified_at are server-generated fields, meaning they should not be included in the client request payload. Remove the following lines from the verifiable_addresses object:

  • "created_at": time.Now()
  • "updated_at": time.Now()
  • "verified_at": time.Now()

Keep only: value, verified, via, and status.

🤖 Prompt for AI Agents
In server/action/admin/user/create.go around lines 54 to 64, the
verifiable_addresses payload currently includes server-generated timestamp
fields (created_at, updated_at, verified_at) which should not be sent; remove
the "created_at": time.Now(), "updated_at": time.Now(), and "verified_at":
time.Now() entries and leave only "value", "verified", "via", and "status" in
the verifiable_addresses map so the request conforms to Kratos Admin API
expectations.

}

buf := new(bytes.Buffer)
Expand Down
Loading