@tachybase/plugin-password-policy 1.3.18 → 1.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/schema"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/schema","antd"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["@tachybase/plugin-password-policy"]={},s["@tachybase/client"],s.jsxRuntime,s["@tachybase/schema"],s.antd))})(this,function(s,t,n,l,d){"use strict";var
|
|
1
|
+
(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/schema"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/schema","antd"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["@tachybase/plugin-password-policy"]={},s["@tachybase/client"],s.jsxRuntime,s["@tachybase/schema"],s.antd))})(this,function(s,t,n,l,d){"use strict";var W=Object.defineProperty;var g=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var f=(s,t,n)=>t in s?W(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,h=(s,t)=>{for(var n in t||(t={}))G.call(t,n)&&f(s,n,t[n]);if(g)for(var n of g(t))H.call(t,n)&&f(s,n,t[n]);return s};var y=(s,t,n)=>new Promise((l,d)=>{var b=p=>{try{x(n.next(p))}catch(e){d(e)}},m=p=>{try{x(n.throw(p))}catch(e){d(e)}},x=p=>p.done?l(p.value):Promise.resolve(p.value).then(b,m);x((n=n.apply(s,t)).next())});const b="password-policy";var m=(o=>(o[o.None=0]="None",o[o.NumberAndLetter=1]="NumberAndLetter",o[o.NumberAndLetterAndSymbol=2]="NumberAndLetterAndSymbol",o[o.NumberAndLetterAndUpperAndLower=3]="NumberAndLetterAndUpperAndLower",o[o.NumberAndLetterAndUpperAndLowerAndSymbol=4]="NumberAndLetterAndUpperAndLowerAndSymbol",o[o.NumberAndLetterAndUpperAndLowerAndSymbol3=5]="NumberAndLetterAndUpperAndLowerAndSymbol3",o))(m||{});const x="passwordPolicy";function p(){return{t:(r,a={})=>t.i18n.t(r,h({ns:b},a))}}const e=o=>t.tval(o,{ns:b}),v=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource("ipFilter").get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},w=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),a=t.useAPIClient(),{t:i}=p();return{run(){return y(this,null,function*(){yield o.submit();try{yield a.request({url:"ipFilter:put",method:"post",data:o.values}),r.success(i("Settings saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},P={type:"object",properties:{ipFilter:{"x-component":"FormV2","x-use-component-props":"useIPFilterValues",type:"void",title:e("IP Filter Settings"),properties:{allowFirst:{type:"boolean",title:e("Filter Mode"),default:!0,description:e("Choose how to apply white and black lists"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:e("Allow first (whitelist priority)"),value:!0},{label:e("Block first (blacklist priority)"),value:!1}]},allowList:{type:"string",title:e("Allow List (Whitelist)"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{rows:6,placeholder:`127.0.0.1
|
|
2
2
|
192.168.0.0/16
|
|
3
3
|
10.0.0.0/8`},description:e("One IP or CIDR per line. Example: 192.168.1.0/24 or 10.0.0.1")},blockList:{type:"string",title:e("Block List (Blacklist)"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{rows:6,placeholder:`1.2.3.4
|
|
4
|
-
5.6.0.0/16`},description:e("One IP or CIDR per line. Example: 1.2.3.4 or 5.6.7.0/24")},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:e("Save"),"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveIPFilterValues }}"}}}}}}}},S=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:P,scope:{useIPFilterValues:v,useSaveIPFilterValues:w}})}),C=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource(x).get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},k=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),p=t.useAPIClient(),{t:i}=t.useTranslation();return{run(){return y(this,null,function*(){yield o.submit();try{yield p.request({url:`${x}:set`,method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},F=()=>({type:"object",properties:{passwordValidityPeriod:{type:"void",title:e("Password validity period"),"x-decorator":"CardItem","x-component":"FormV2","x-use-component-props":"usePasswordPolicyValues",properties:{validityPeriod:{type:"number",title:e("Password validity period (days)"),description:e("Default value is never."),"x-decorator":"FormItem","x-component":"Select","x-component-props":{defaultValue:0,options:[{label:"30",value:30},{label:"60",value:60},{label:"90",value:90},{label:"180",value:180},{label:"365",value:365},{label:e("Never expire"),value:0}]}},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordPolicyValues }}"}}}}}}}}),I=()=>{const o=F();return n.jsx(t.SchemaComponent,{schema:o,scope:{usePasswordPolicyValues:C,useSavePasswordPolicyValues:k}})},L=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource("passwordAttempt").get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},V=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),p=t.useAPIClient(),{t:i}=a();return{run(){return y(this,null,function*(){yield o.submit();try{yield p.request({url:"passwordAttempt:put",method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},T={type:"object",properties:{passwordAttempt:{"x-component":"FormV2","x-use-component-props":"usePasswordPolicyValues",type:"void",title:e("Password policy"),properties:{maxAttempts:{type:"digit",title:e("Max invalid password sign-in attempts"),description:e("Default value is 5. Set to 0 to disable."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:0}},windowSeconds:{type:"digit",title:e("Max invalid password sign-in attempts interval (seconds)"),description:e("Default value is 300 seconds (5 minutes)."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:1}},lockSeconds:{type:"digit",title:e("Lockout duration (seconds)"),description:e("Default value is 1800 seconds (30 minutes)."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:1}},strictLock:{type:"boolean",title:e("Can not access any api after locked"),description:e("Default value is off."),"x-decorator":"FormItem","x-component":"Checkbox"},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordPolicyValues }}"}}}}}}}},N=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:T,scope:{usePasswordPolicyValues:L,useSavePasswordPolicyValues:V}})}),D=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource("passwordStrengthConfig").get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},B=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),p=t.useAPIClient(),{t:i}=a();return{run(){return y(this,null,function*(){yield o.submit();try{yield p.request({url:"passwordStrengthConfig:put",method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},U={type:"object",properties:{passwordStrength:{"x-component":"FormV2","x-use-component-props":"usePasswordStrengthValues",type:"void",title:e("Password Strength Settings"),properties:{minLength:{type:"number",title:e("Minimum Password Length"),"x-decorator":"FormItem","x-component":"InputNumber",default:0},strengthLevel:{type:"number",title:e("Password Strength Requirements"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("No restrictions"),value:m.None},{label:e("Must contain letters and numbers"),value:m.NumberAndLetter},{label:e("Must contain letters, numbers, and symbols"),value:m.NumberAndLetterAndSymbol},{label:e("Must contain numbers, uppercase and lowercase letters"),value:m.NumberAndLetterAndUpperAndLower},{label:e("Must contain numbers, uppercase and lowercase letters, and symbols"),value:m.NumberAndLetterAndUpperAndLowerAndSymbol},{label:e("Must contain at least 3 of the following: numbers, uppercase letters, lowercase letters, and symbols"),value:m.NumberAndLetterAndUpperAndLowerAndSymbol3}],default:0},notContainUsername:{type:"boolean",title:e("Password cannot contain username"),"x-decorator":"FormItem","x-component":"Checkbox",default:!1},historyCount:{type:"number",title:e("Remember password history (0-24)"),description:e("Number of previous passwords to remember. 0 means no restriction."),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:24},default:0},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordStrengthValues }}"}}}}}}}},M=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:U,scope:{usePasswordStrengthValues:D,useSavePasswordStrengthValues:B}})}),O={name:"signInFails",fields:[{type:"string",name:"username",interface:"input",uiSchema:{type:"string",title:'{{ t("Username") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.username}}},{type:"string",name:"nickname",interface:"input",uiSchema:{type:"string",title:'{{ t("Nickname") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.nickname}}},{type:"string",name:"ip",interface:"input",uiSchema:{type:"string",title:"IP","x-read-pretty":!0}},{type:"string",name:"address",interface:"input",uiSchema:{type:"string",title:e("Location"),"x-read-pretty":!0}},{type:"datetime",name:"createdAt",interface:"datetime",uiSchema:{type:"string",title:e("Time"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"user",type:"belongsTo",target:"users",targetKey:"id",foreignKey:"userId",interface:"m2o",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},E={type:"void",properties:{signInFails:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"signInFails:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"signInFails",action:"list",params:{pageSize:20,appends:["user"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps","x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},ip:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{ip:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},address:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{address:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},q=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[O],children:n.jsx(t.SchemaComponent,{schema:E})}),R={name:"userLocks",fields:[{type:"string",name:"username",interface:"input",uiSchema:{type:"string",title:'{{ t("Username") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.username}}},{type:"string",name:"nickname",interface:"input",uiSchema:{type:"string",title:'{{ t("Nickname") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.nickname}}},{type:"datetime",name:"updatedAt",interface:"datetime",uiSchema:{type:"string",title:e("Updated At"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{type:"datetime",name:"expireAt",interface:"datetime",uiSchema:{type:"string",title:e("Lock Expires At"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"user",type:"belongsTo",target:"users",targetKey:"id",foreignKey:"userId",interface:"m2o",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},j={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"userLocks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}},userId:{type:"string",title:e("Username or Email"),required:!0,"x-component":"RemoteSelect","x-decorator":"FormItem","x-component-props":{placeholder:e("Please enter username, nickname or email"),fieldNames:{label:"nickname",value:"id"},service:{resource:"users",action:"list",params:{filter:{$or:[{lock:{id:{$notExists:!0}}},{lock:{expireAt:{$lt:"{{ new Date() }}"}}}]},pageSize:20,sort:["-id"],appends:["lock"]}},manual:!1}},expireAt:{type:"string",title:e("Lock Until"),required:!0,"x-component":"DatePicker","x-decorator":"FormItem","x-component-props":{showTime:!0,disabledDate:"{{ (current) => current && current < new Date() }}",placeholder:e("Please select lock expiration time")}}}}}},K={type:"void","x-action":"create","x-acl-action":"create",title:e("Lock New User"),"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:t.OpenMode.DRAWER_MODE,type:"primary",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:e("Lock New User"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:j}}}},_={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:t.OpenMode.DRAWER_MODE,icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks",action:"get",useParams:"{{ useParamsFromRecord }}",params:{appends:["user"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},skipValidator:!1},type:"void"}}},expireAt:{type:"date",title:e("Lock Until"),required:!0,"x-component":"DatePicker","x-component-props":{showTime:!0,disabledDate:"{{ (current) => current && current < new Date() }}",placeholder:e("Please select lock expiration time")},"x-decorator":"FormItem"}}}}}}}}},W={type:"void",properties:{userLocks:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"userLocks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks",action:"list",params:{pageSize:20,appends:["user"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps","x-align":"right"},create:K}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedAt:{type:"void",title:e("Updated At"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{updatedAt:{"x-collection-field":"userLocks.updatedAt","x-component":"CollectionField","x-component-props":{ellipsis:!0,showTime:!0},"x-read-pretty":!0,"x-decorator":null}}},expireAt:{type:"void",title:e("Lock Expires At"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{expireAt:{"x-collection-field":"userLocks.expireAt","x-component":"CollectionField","x-component-props":{ellipsis:!0,showTime:!0},"x-read-pretty":!0,"x-decorator":null}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:200,fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:_,destroy:{type:"void",title:e("Unlock"),"x-action":"destroy","x-component":"Action.Link","x-component-props":{danger:!0,confirm:{title:e("Unlock User"),content:e("Are you sure you want to unlock this user?")}},"x-decorator":"ACLActionProvider","x-use-component-props":"useDestroyActionProps"}}}}}}}}}}},$=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[R],children:n.jsx(t.SchemaComponent,{schema:W})});class A extends t.Plugin{load(){return y(this,null,function*(){this.app.systemSettingsManager.add("security.password-attempt",{icon:"SettingOutlined",title:e("Password policy"),Component:N,aclSnippet:"pm.security.password-attempt"}),this.app.systemSettingsManager.add("security.user-lock",{icon:"UserOutlined",title:e("User lock"),Component:$,aclSnippet:"pm.security.user-lock"}),this.app.systemSettingsManager.add("security.ip-filter",{icon:"GlobalOutlined",title:e("IP policy"),Component:S,aclSnippet:"pm.security.ip-filter"}),this.app.systemSettingsManager.add("security.password-strength",{icon:"LockOutlined",title:e("Password strength"),Component:M,aclSnippet:"pm.security.password-strength"}),this.app.systemSettingsManager.add("security.sign-in-fails",{icon:"HistoryOutlined",title:e("Sign-in fails history"),Component:q,aclSnippet:"pm.security.sign-in-fails"}),this.app.systemSettingsManager.add("security.password-validity-period",{icon:"LockOutlined",title:e("Password validity period"),Component:I,aclSnippet:"pm.security.password-validity-period"})})}}s.PasswordPolicyClient=A,s.default=A,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
4
|
+
5.6.0.0/16`},description:e("One IP or CIDR per line. Example: 1.2.3.4 or 5.6.7.0/24")},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:e("Save"),"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveIPFilterValues }}"}}}}}}}},S=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:P,scope:{useIPFilterValues:v,useSaveIPFilterValues:w}})}),C=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource(x).get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},k=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),a=t.useAPIClient(),{t:i}=t.useTranslation();return{run(){return y(this,null,function*(){yield o.submit();try{yield a.request({url:`${x}:set`,method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},F=()=>({type:"object",properties:{passwordValidityPeriod:{type:"void",title:e("Password validity period"),"x-decorator":"CardItem","x-component":"FormV2","x-use-component-props":"usePasswordPolicyValues",properties:{validityPeriod:{type:"number",title:e("Password validity period (days)"),description:e("Default value is never."),"x-decorator":"FormItem","x-component":"Select","x-component-props":{defaultValue:0,options:[{label:"30",value:30},{label:"60",value:60},{label:"90",value:90},{label:"180",value:180},{label:"365",value:365},{label:e("Never expire"),value:0}]}},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordPolicyValues }}"}}}}}}}}),I=()=>{const o=F();return n.jsx(t.SchemaComponent,{schema:o,scope:{usePasswordPolicyValues:C,useSavePasswordPolicyValues:k}})},L=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource("passwordAttempt").get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},V=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),a=t.useAPIClient(),{t:i}=p();return{run(){return y(this,null,function*(){yield o.submit();try{yield a.request({url:"passwordAttempt:put",method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},T={type:"object",properties:{passwordAttempt:{"x-component":"FormV2","x-use-component-props":"usePasswordPolicyValues",type:"void",title:e("Password policy"),properties:{maxAttempts:{type:"digit",title:e("Max invalid password sign-in attempts"),description:e("Default value is 5. Set to 0 to disable."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:0}},windowSeconds:{type:"digit",title:e("Max invalid password sign-in attempts interval (seconds)"),description:e("Default value is 300 seconds (5 minutes)."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:1}},lockSeconds:{type:"digit",title:e("Lockout duration (seconds)"),description:e("Default value is 1800 seconds (30 minutes)."),"x-decorator":"FormItem","x-component":"InputNumber","x-validator":{required:!0},"x-component-props":{min:1}},strictLock:{type:"boolean",title:e("Can not access any api after locked"),description:e("Default value is off."),"x-decorator":"FormItem","x-component":"Checkbox"},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordPolicyValues }}"}}}}}}}},N=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:T,scope:{usePasswordPolicyValues:L,useSavePasswordPolicyValues:V}})}),D=()=>{const o=t.useAPIClient(),{data:r}=t.useRequest(()=>o.resource("passwordStrengthConfig").get().then(i=>{var c;return(c=i.data)==null?void 0:c.data}));return{form:l.createForm({values:r})}},B=()=>{const o=l.useForm(),{message:r}=d.App.useApp(),a=t.useAPIClient(),{t:i}=p();return{run(){return y(this,null,function*(){yield o.submit();try{yield a.request({url:"passwordStrengthConfig:put",method:"post",data:o.values}),r.success(i("Saved successfully"))}catch(u){throw r.error(i("Failed to save settings")),u}})}}},U={type:"object",properties:{passwordStrength:{"x-component":"FormV2","x-use-component-props":"usePasswordStrengthValues",type:"void",title:e("Password Strength Settings"),properties:{minLength:{type:"number",title:e("Minimum Password Length"),"x-decorator":"FormItem","x-component":"InputNumber",default:0},strengthLevel:{type:"number",title:e("Password Strength Requirements"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("No restrictions"),value:m.None},{label:e("Must contain letters and numbers"),value:m.NumberAndLetter},{label:e("Must contain letters, numbers, and symbols"),value:m.NumberAndLetterAndSymbol},{label:e("Must contain numbers, uppercase and lowercase letters"),value:m.NumberAndLetterAndUpperAndLower},{label:e("Must contain numbers, uppercase and lowercase letters, and symbols"),value:m.NumberAndLetterAndUpperAndLowerAndSymbol},{label:e("Must contain at least 3 of the following: numbers, uppercase letters, lowercase letters, and symbols"),value:m.NumberAndLetterAndUpperAndLowerAndSymbol3}],default:0},notContainUsername:{type:"boolean",title:e("Password cannot contain username"),"x-decorator":"FormItem","x-component":"Checkbox",default:!1},historyCount:{type:"number",title:e("Remember password history (0-24)"),description:e("Number of previous passwords to remember. 0 means no restriction."),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:24},default:0},footer:{type:"void","x-component":"ActionBar",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSavePasswordStrengthValues }}"}}}}}}}},M=()=>n.jsx(d.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:U,scope:{usePasswordStrengthValues:D,useSavePasswordStrengthValues:B}})}),q={name:"signInFails",fields:[{type:"string",name:"username",interface:"input",uiSchema:{type:"string",title:'{{ t("Username") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.username}}},{type:"string",name:"nickname",interface:"input",uiSchema:{type:"string",title:'{{ t("Nickname") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.nickname}}},{type:"string",name:"ip",interface:"input",uiSchema:{type:"string",title:"IP","x-read-pretty":!0}},{type:"string",name:"address",interface:"input",uiSchema:{type:"string",title:e("Location"),"x-read-pretty":!0}},{type:"datetime",name:"createdAt",interface:"datetime",uiSchema:{type:"string",title:e("Time"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"user",type:"belongsTo",target:"users",targetKey:"id",foreignKey:"userId",interface:"m2o",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},O={type:"void",properties:{signInFails:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"signInFails:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"signInFails",action:"list",params:{pageSize:20,appends:["user"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps","x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},ip:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{ip:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},address:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{address:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"CollectionField",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},E=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[q],children:n.jsx(t.SchemaComponent,{schema:O})}),R={name:"userLocks",fields:[{type:"string",name:"username",interface:"input",uiSchema:{type:"string",title:'{{ t("Username") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.username}}},{type:"string",name:"nickname",interface:"input",uiSchema:{type:"string",title:'{{ t("Nickname") }}',"x-read-pretty":!0,"x-component"(){var r;return(r=t.useRecord().user)==null?void 0:r.nickname}}},{type:"datetime",name:"updatedAt",interface:"datetime",uiSchema:{type:"string",title:e("Updated At"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{type:"datetime",name:"expireAt",interface:"datetime",uiSchema:{type:"string",title:e("Lock Expires At"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"user",type:"belongsTo",target:"users",targetKey:"id",foreignKey:"userId",interface:"m2o",uiSchema:{type:"object",title:'{{t("User")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},j={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"userLocks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}},userId:{type:"string",title:e("Username or Email"),required:!0,"x-component":"RemoteSelect","x-decorator":"FormItem","x-component-props":{placeholder:e("Please enter username, nickname or email"),fieldNames:{label:"nickname",value:"id"},service:{resource:"users",action:"list",params:{filter:{$or:[{lock:{id:{$notExists:!0}}},{lock:{expireAt:{$lt:"{{ new Date() }}"}}}]},pageSize:20,sort:["-id"],appends:["lock"]}},manual:!1}},expireAt:{type:"string",title:e("Lock Until"),required:!0,"x-component":"DatePicker","x-decorator":"FormItem","x-component-props":{showTime:!0,disabledDate:"{{ (current) => current && current < new Date() }}",placeholder:e("Please select lock expiration time")}}}}}},K={type:"void","x-action":"create","x-acl-action":"create",title:e("Lock New User"),"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:e("Lock New User"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:j}}}},$={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks",action:"get",useParams:"{{ useParamsFromRecord }}",params:{appends:["user"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},skipValidator:!1},type:"void"}}},expireAt:{type:"date",title:e("Lock Until"),required:!0,"x-component":"DatePicker","x-component-props":{showTime:!0,disabledDate:"{{ (current) => current && current < new Date() }}",placeholder:e("Please select lock expiration time")},"x-decorator":"FormItem"}}}}}}}}},_={type:"void",properties:{userLocks:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"userLocks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"userLocks",action:"list",params:{pageSize:20,appends:["user"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps","x-align":"right"},create:K}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{username:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedAt:{type:"void",title:e("Updated At"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{updatedAt:{"x-collection-field":"userLocks.updatedAt","x-component":"CollectionField","x-component-props":{ellipsis:!0,showTime:!0},"x-read-pretty":!0,"x-decorator":null}}},expireAt:{type:"void",title:e("Lock Expires At"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{expireAt:{"x-collection-field":"userLocks.expireAt","x-component":"CollectionField","x-component-props":{ellipsis:!0,showTime:!0},"x-read-pretty":!0,"x-decorator":null}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:200,fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:$,destroy:{type:"void",title:e("Unlock"),"x-action":"destroy","x-component":"Action.Link","x-component-props":{danger:!0,confirm:{title:e("Unlock User"),content:e("Are you sure you want to unlock this user?")}},"x-decorator":"ACLActionProvider","x-use-component-props":"useDestroyActionProps"}}}}}}}}}}},z=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[R],children:n.jsx(t.SchemaComponent,{schema:_})});class A extends t.Plugin{load(){return y(this,null,function*(){this.app.systemSettingsManager.add("security.password-attempt",{icon:"SettingOutlined",title:e("Password policy"),Component:N,aclSnippet:"pm.security.password-attempt"}),this.app.systemSettingsManager.add("security.user-lock",{icon:"UserOutlined",title:e("User lock"),Component:z,aclSnippet:"pm.security.user-lock"}),this.app.systemSettingsManager.add("security.ip-filter",{icon:"GlobalOutlined",title:e("IP policy"),Component:S,aclSnippet:"pm.security.ip-filter"}),this.app.systemSettingsManager.add("security.password-strength",{icon:"LockOutlined",title:e("Password strength"),Component:M,aclSnippet:"pm.security.password-strength"}),this.app.systemSettingsManager.add("security.sign-in-fails",{icon:"HistoryOutlined",title:e("Sign-in fails history"),Component:E,aclSnippet:"pm.security.sign-in-fails"}),this.app.systemSettingsManager.add("security.password-validity-period",{icon:"LockOutlined",title:e("Password validity period"),Component:I,aclSnippet:"pm.security.password-validity-period"})})}}s.PasswordPolicyClient=A,s.default=A,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.3.
|
|
4
|
-
"@tachybase/schema": "1.3.
|
|
3
|
+
"@tachybase/client": "1.3.20",
|
|
4
|
+
"@tachybase/schema": "1.3.20",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/server": "1.3.
|
|
7
|
-
"@tachybase/actions": "1.3.
|
|
8
|
-
"@tachybase/utils": "1.3.
|
|
9
|
-
"@tachybase/database": "1.3.
|
|
6
|
+
"@tachybase/server": "1.3.20",
|
|
7
|
+
"@tachybase/actions": "1.3.20",
|
|
8
|
+
"@tachybase/utils": "1.3.20",
|
|
9
|
+
"@tachybase/database": "1.3.20"
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"geoip-lite","version":"1.4.10","description":"A light weight native JavaScript implementation of GeoIP API from MaxMind","keywords":["geo","geoip","ip","ipv4","ipv6","geolookup","maxmind","geolite"],"homepage":"https://github.com/geoip-lite/node-geoip","author":"Philip Tellis <philip@bluesmoon.info> (http://bluesmoon.info/)","files":["lib/","data/","test/","scripts/"],"main":"lib/geoip.js","repository":{"type":"git","url":"git://github.com/geoip-lite/node-geoip.git"},"engines":{"node":">=10.3.0"},"scripts":{"pretest":"eslint .","test":"nodeunit --reporter=minimal test/tests.js","updatedb":"node scripts/updatedb.js","updatedb-debug":"node scripts/updatedb.js debug","updatedb-force":"node scripts/updatedb.js force"},"dependencies":{"async":"2.1 - 2.6.4","chalk":"4.1 - 4.1.2","iconv-lite":"0.4.13 - 0.6.3","ip-address":"5.8.9 - 5.9.4","lazy":"1.0.11","rimraf":"2.5.2 - 2.7.1","yauzl":"2.9.2 - 2.10.0"},"config":{"update":true},"devDependencies":{"eslint":"^5.12.1","nodeunit":"^0.11.2"},"license":"Apache-2.0","_lastModified":"2025-07-
|
|
1
|
+
{"name":"geoip-lite","version":"1.4.10","description":"A light weight native JavaScript implementation of GeoIP API from MaxMind","keywords":["geo","geoip","ip","ipv4","ipv6","geolookup","maxmind","geolite"],"homepage":"https://github.com/geoip-lite/node-geoip","author":"Philip Tellis <philip@bluesmoon.info> (http://bluesmoon.info/)","files":["lib/","data/","test/","scripts/"],"main":"lib/geoip.js","repository":{"type":"git","url":"git://github.com/geoip-lite/node-geoip.git"},"engines":{"node":">=10.3.0"},"scripts":{"pretest":"eslint .","test":"nodeunit --reporter=minimal test/tests.js","updatedb":"node scripts/updatedb.js","updatedb-debug":"node scripts/updatedb.js debug","updatedb-force":"node scripts/updatedb.js force"},"dependencies":{"async":"2.1 - 2.6.4","chalk":"4.1 - 4.1.2","iconv-lite":"0.4.13 - 0.6.3","ip-address":"5.8.9 - 5.9.4","lazy":"1.0.11","rimraf":"2.5.2 - 2.7.1","yauzl":"2.9.2 - 2.10.0"},"config":{"update":true},"devDependencies":{"eslint":"^5.12.1","nodeunit":"^0.11.2"},"license":"Apache-2.0","_lastModified":"2025-07-24T06:22:39.874Z"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-password-policy",
|
|
3
3
|
"displayName": "Password policy",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.20",
|
|
5
5
|
"description": "Password policy, including password strength, password attempt limit, password lock time, ip whitelist/blacklist, etc.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Security"
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"ipaddr.js": "^2.1.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@tachybase/actions": "1.3.
|
|
18
|
-
"@tachybase/client": "1.3.
|
|
19
|
-
"@tachybase/
|
|
20
|
-
"@tachybase/
|
|
21
|
-
"@tachybase/
|
|
22
|
-
"@tachybase/
|
|
17
|
+
"@tachybase/actions": "1.3.20",
|
|
18
|
+
"@tachybase/client": "1.3.20",
|
|
19
|
+
"@tachybase/server": "1.3.20",
|
|
20
|
+
"@tachybase/database": "1.3.20",
|
|
21
|
+
"@tachybase/utils": "1.3.20",
|
|
22
|
+
"@tachybase/schema": "1.3.20"
|
|
23
23
|
},
|
|
24
24
|
"description.zh-CN": "密码策略, 包含密码强度、密码尝试次数限制、密码锁定时间、ip黑白名单等",
|
|
25
25
|
"displayName.zh-CN": "密码策略"
|