Skip to content

feat(auth): add a phone-number format policy - #1

Closed
SandyTAP wants to merge 1 commit into
mainfrom
feature/phone-format-policy
Closed

SandyTAP wants to merge 1 commit into
mainfrom
feature/phone-format-policy

Conversation

@SandyTAP

Copy link
Copy Markdown
Owner

TELESRV_CHECK_NUMBER_FORMAT selects the login identity format gate.

Lenient (default, false): a calling code with a plausible length is enough; a number the numbering plan cannot describe is accepted when it is 4-32 digits and carries no leading trunk zero, so short and unassigned ranges such as +7 123 or +1488 stay usable. Strict (true): the number must sit in an assigned range of a real country calling code.

A national number without its calling code stays refused in both modes, and the reserved service number +42777 never becomes a login identity.

Policy is installed in the server and the admin process before stores and RPC services are constructed.

Tests: internal/domain/phone_format_policy_test.go, internal/app/auth/phone_format_test.go. go test ./... -count=1 passes (96 packages).

Docs: .env.example, docs/configuration.en.md, docs/configuration.zh-CN.md.

TELESRV_CHECK_NUMBER_FORMAT selects the login identity format gate.

The default lenient policy keeps the structural country-code gate and adds a
fallback for numbers the numbering plan cannot describe, so short and
unassigned international ranges such as "+7 123" or "+1488" are usable
login identities. A national number that omits its country calling code
(a leading trunk zero) stays refused, and the stored identity is canonical
on every later normalization pass.

The strict policy additionally requires the number to sit in an assigned
range of a real country calling code, so short and unassigned ranges are
rejected.

The reserved service number +42777 stays resolvable under both policies so
auth recognizes it as a system account; SendCode, SignIn and SignUp refuse
it before any code is issued.

The policy is installed in both the server and the admin process before
stores and RPC services are constructed, so a number written from the panel
is judged by the same rules.
@SandyTAP

Copy link
Copy Markdown
Owner Author

Closing: this repository takes changes directly on main; the pull-request flow is only used for the td schema work upstream (iamxvbaba/td#3).

@SandyTAP SandyTAP closed this Oct 20, 2026
@SandyTAP
SandyTAP deleted the feature/phone-format-policy branch October 20, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant