mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-07 02:20:28 +08:00
feat: support "permissionNames" field in JWT-Custom token (#4154)
This commit is contained in:
@@ -370,6 +370,12 @@ func getClaimsCustom(claims Claims, tokenField []string) jwt.MapClaims {
|
|||||||
res[fieldName] = finalField.Interface()
|
res[fieldName] = finalField.Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if field == "permissionNames" {
|
||||||
|
permissionNames := []string{}
|
||||||
|
for _, val := range claims.User.Permissions {
|
||||||
|
permissionNames = append(permissionNames, val.Name)
|
||||||
|
}
|
||||||
|
res[util.SnakeToCamel(util.CamelToSnakeCase(field))] = permissionNames
|
||||||
} else { // Use selected user field as claims.
|
} else { // Use selected user field as claims.
|
||||||
userField := userValue.FieldByName(field)
|
userField := userValue.FieldByName(field)
|
||||||
if userField.IsValid() {
|
if userField.IsValid() {
|
||||||
|
@@ -463,7 +463,7 @@ class ApplicationEditPage extends React.Component {
|
|||||||
<Select virtual={false} disabled={this.state.application.tokenFormat !== "JWT-Custom"} mode="tags" showSearch style={{width: "100%"}} value={this.state.application.tokenFields} onChange={(value => {this.updateApplicationField("tokenFields", value);})}>
|
<Select virtual={false} disabled={this.state.application.tokenFormat !== "JWT-Custom"} mode="tags" showSearch style={{width: "100%"}} value={this.state.application.tokenFields} onChange={(value => {this.updateApplicationField("tokenFields", value);})}>
|
||||||
<Option key={"provider"} value={"provider"}>{"Provider"}</Option>)
|
<Option key={"provider"} value={"provider"}>{"Provider"}</Option>)
|
||||||
{
|
{
|
||||||
Setting.getUserCommonFields().map((item, index) => <Option key={index} value={item}>{item}</Option>)
|
[...Setting.getUserCommonFields(), "permissionNames"].map((item, index) => <Option key={index} value={item}>{item}</Option>)
|
||||||
}
|
}
|
||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
|
Reference in New Issue
Block a user