@@ -9,15 +9,6 @@ import kotlin.reflect.KClass
99
1010private const val USERNAME_REGEX = " [a-zA-Z0-9]+$"
1111
12- // root, admin,
13- // search, post, edit,
14- // join, login, logout,
15- // setting, settings, support, notifications,
16- // article, articles, series, question, questions, topic, topics
17- private const val USERNAME_RESERVED =
18- " root|admin|search|post|edit|join|login|logout|setting|settings|support|notifications|article|articles|series|question|questions|topic|topics"
19- private const val USERNAME_RESERVED_REGEX = " ^(?!.*\\ b($USERNAME_RESERVED )\\ b).*$"
20-
2112@Constraint(validatedBy = [])
2213@Target(
2314 AnnotationTarget .FIELD ,
@@ -28,10 +19,101 @@ private const val USERNAME_RESERVED_REGEX = "^(?!.*\\b($USERNAME_RESERVED)\\b).*
2819@NotBlank(message = " 유저네임은 필수 입력 항목입니다." )
2920@Size(min = 4 , max = 12 , message = " 유저네임은 4자 이상 12자 이하이어야 합니다." )
3021@Pattern(regexp = USERNAME_REGEX , message = " 유저네임은 영문 소문자와 숫자로만 입력해주세요." )
31- @Pattern(regexp = USERNAME_RESERVED_REGEX , message = " 유저네임에 사용할 수 없는 단어가 포함되어 있습니다." )
3222@Trimmed
3323annotation class UsernameValidation (
3424 val message : String = " 잘못된 유저네임입니다." ,
3525 val groups : Array <KClass <* >> = [],
3626 val payload : Array <KClass <out Payload >> = []
37- )
27+ )
28+
29+ private val RESERVED_USERNAMES : Set <String > = setOf (
30+ // System / Admin
31+ " root" , " admin" , " administrator" , " superadmin" , " superuser" , " owner" , " master" ,
32+ " moderator" , " mod" , " staff" , " team" , " developers" , " devs" ,
33+
34+ // Dashboard / Access
35+ " dashboard" , " adminpanel" , " system" , " sys" ,
36+ " config" , " configs" , " configuration" ,
37+ " internal" , " private" , " public" ,
38+
39+ // API / Tech
40+ " api" , " apis" , " api-doc" , " api-docs" ,
41+ " graphql" , " rest" , " soap" , " rpc" , " ws" , " websocket" ,
42+ " static" , " assets" , " fonts" , " icons" , " images" , " media" ,
43+ " file" , " files" , " upload" , " uploads" ,
44+ " download" , " downloads" ,
45+
46+ // Environments
47+ " dev" , " prod" , " test" ,
48+
49+ // Exec / Command injection
50+ " sh" , " shell" , " cmd" , " command" , " commands" ,
51+ " exec" , " execute" , " run" , " eval" ,
52+ " php" , " bin" ,
53+ " cdn" , " cdn-cgi" , " cgi" ,
54+
55+ // Security / Logs / Monitoring
56+ " secure" , " security" , " audit" ,
57+ " log" , " logs" , " error" , " errors" ,
58+ " status" , " statuspage" ,
59+ " health" , " healthcheck" ,
60+ " metrics" ,
61+ " monitor" , " monitoring" ,
62+ " trace" , " debug" , " debugger" ,
63+
64+ // Billing / Payment
65+ " billing" , " payment" , " payments" ,
66+ " subscribe" , " subscription" ,
67+
68+ // Common pages
69+ " index" , " home" , " about" , " contact" , " help" , " faq" ,
70+ " docs" , " manual" , " documentation" ,
71+ " terms" , " privacy" , " policy" ,
72+ " feed" , " rss" , " sitemap" , " robots" , " license" ,
73+
74+ // Auth / Account
75+ " auth" , " authenticate" , " authorize" ,
76+ " account" , " accounts" ,
77+ " profile" , " profiles" ,
78+ " user" , " users" , " my" , " me" , " self" ,
79+ " register" , " signup" , " signin" ,
80+ " join" , " login" , " logout" ,
81+ " password" , " forgot" , " reset" ,
82+ " verify" , " confirm" ,
83+ " oauth" , " oauth2" , " callback" ,
84+ " session" , " sessions" ,
85+ " token" , " tokens" ,
86+ " setting" , " settings" ,
87+ " legal" , " support" ,
88+
89+ // Content routes
90+ " article" , " articles" ,
91+ " series" ,
92+ " question" , " questions" ,
93+ " topic" , " topics" ,
94+ " tag" , " tags" ,
95+ " comment" , " comments" ,
96+ " search" , " post" , " edit" ,
97+
98+ // Additional conflict-prone words
99+ " new" , " create" , " update" , " delete" ,
100+ " remove" , " add" , " list" ,
101+ " page" , " pages" ,
102+ " reply" , " replies" ,
103+ " inbox" , " outbox" ,
104+ " message" , " messages" ,
105+ " chat" , " chats" ,
106+ " notification" , " notifications" ,
107+
108+ // Anti-phishing
109+ " admin123" , " support-team" , " helpdesk" ,
110+ " service" , " services" ,
111+ " official" , " official-team" ,
112+ " secure-login" ,
113+
114+ // Domain
115+ " loghub" ,
116+ ).map { it.lowercase() }.toSet()
117+
118+ fun String.isReservedUsername (): Boolean =
119+ this .lowercase() in RESERVED_USERNAMES
0 commit comments