mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-07 19:50:33 +08:00
Add PasswordSalt to org.
This commit is contained in:
@@ -65,7 +65,7 @@ func checkPassword(user *User, password string) string {
|
|||||||
return "password incorrect"
|
return "password incorrect"
|
||||||
}
|
}
|
||||||
} else if organization.PasswordType == "salt" {
|
} else if organization.PasswordType == "salt" {
|
||||||
if getSaltedPassword(password) == user.Password {
|
if getSaltedPassword(password, organization.PasswordSalt) == user.Password {
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else {
|
||||||
return "password incorrect"
|
return "password incorrect"
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
// Copyright 2021 The casbin Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package object
|
|
||||||
|
|
||||||
var salt = "123"
|
|
@@ -28,6 +28,7 @@ type Organization struct {
|
|||||||
WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"`
|
WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"`
|
||||||
Favicon string `xorm:"varchar(100)" json:"favicon"`
|
Favicon string `xorm:"varchar(100)" json:"favicon"`
|
||||||
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
||||||
|
PasswordSalt string `xorm:"varchar(100)" json:"passwordSalt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOrganizations(owner string) []*Organization {
|
func GetOrganizations(owner string) []*Organization {
|
||||||
|
@@ -30,7 +30,7 @@ func getSha256HexDigest(s string) string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSaltedPassword(password string) string {
|
func getSaltedPassword(password string, salt string) string {
|
||||||
hash1 := getSha256HexDigest(password)
|
hash1 := getSha256HexDigest(password)
|
||||||
res := getSha256HexDigest(hash1 + salt)
|
res := getSha256HexDigest(hash1 + salt)
|
||||||
return res
|
return res
|
||||||
|
@@ -47,5 +47,6 @@ func TestSyncIds(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetSaltedPassword(t *testing.T) {
|
func TestGetSaltedPassword(t *testing.T) {
|
||||||
password := "123456"
|
password := "123456"
|
||||||
fmt.Printf("%s -> %s\n", password, getSaltedPassword(password))
|
salt := "123"
|
||||||
|
fmt.Printf("%s -> %s\n", password, getSaltedPassword(password, salt))
|
||||||
}
|
}
|
||||||
|
@@ -139,6 +139,16 @@ class OrganizationEditPage extends React.Component {
|
|||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row style={{marginTop: '20px'}} >
|
||||||
|
<Col style={{marginTop: '5px'}} span={2}>
|
||||||
|
{i18next.t("general:Password salt")}:
|
||||||
|
</Col>
|
||||||
|
<Col span={22} >
|
||||||
|
<Input value={this.state.organization.passwordSalt} onChange={e => {
|
||||||
|
this.updateOrganizationField('passwordSalt', e.target.value);
|
||||||
|
}} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,8 @@ class OrganizationListPage extends React.Component {
|
|||||||
displayName: `New Organization - ${this.state.organizations.length}`,
|
displayName: `New Organization - ${this.state.organizations.length}`,
|
||||||
websiteUrl: "https://door.casbin.com",
|
websiteUrl: "https://door.casbin.com",
|
||||||
favicon: "https://cdn.casbin.com/static/favicon.ico",
|
favicon: "https://cdn.casbin.com/static/favicon.ico",
|
||||||
|
passwordType: "plain",
|
||||||
|
PasswordSalt: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +151,13 @@ class OrganizationListPage extends React.Component {
|
|||||||
width: '150px',
|
width: '150px',
|
||||||
sorter: (a, b) => a.passwordType.localeCompare(b.passwordType),
|
sorter: (a, b) => a.passwordType.localeCompare(b.passwordType),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("general:Password salt"),
|
||||||
|
dataIndex: 'passwordSalt',
|
||||||
|
key: 'passwordSalt',
|
||||||
|
width: '150px',
|
||||||
|
sorter: (a, b) => a.passwordSalt.localeCompare(b.passwordSalt),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("general:Action"),
|
title: i18next.t("general:Action"),
|
||||||
dataIndex: '',
|
dataIndex: '',
|
||||||
|
@@ -49,7 +49,6 @@ class UserListPage extends React.Component {
|
|||||||
createdTime: moment().format(),
|
createdTime: moment().format(),
|
||||||
type: "normal-user",
|
type: "normal-user",
|
||||||
password: "123",
|
password: "123",
|
||||||
passwordType: "plain",
|
|
||||||
displayName: `New User - ${this.state.users.length}`,
|
displayName: `New User - ${this.state.users.length}`,
|
||||||
avatar: "https://casbin.org/img/casbin.svg",
|
avatar: "https://casbin.org/img/casbin.svg",
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
@@ -58,6 +57,8 @@ class UserListPage extends React.Component {
|
|||||||
affiliation: "Example Inc.",
|
affiliation: "Example Inc.",
|
||||||
tag: "staff",
|
tag: "staff",
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
|
isGlobalAdmin: false,
|
||||||
|
IsForbidden: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"Preview": "Preview",
|
"Preview": "Preview",
|
||||||
"User type": "User type",
|
"User type": "User type",
|
||||||
"Password type": "Password type",
|
"Password type": "Password type",
|
||||||
|
"Password salt": "Password salt",
|
||||||
"Password": "Password",
|
"Password": "Password",
|
||||||
"Email": "Email",
|
"Email": "Email",
|
||||||
"Phone": "Phone",
|
"Phone": "Phone",
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
"Preview": "预览",
|
"Preview": "预览",
|
||||||
"User type": "用户类型",
|
"User type": "用户类型",
|
||||||
"Password type": "密码类型",
|
"Password type": "密码类型",
|
||||||
|
"Password salt": "密码Salt值",
|
||||||
"Password": "密码",
|
"Password": "密码",
|
||||||
"Email": "电子邮箱",
|
"Email": "电子邮箱",
|
||||||
"Phone": "手机号",
|
"Phone": "手机号",
|
||||||
|
Reference in New Issue
Block a user