mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8024 from swordqiu/feature/qj-apigateway-userinfo-include-project-metadata
fix: apigateway userinfo includes project metadata
This commit is contained in:
@@ -258,6 +258,15 @@ func fetchUserInfoFromToken(ctx context.Context, req *http.Request, token mcclie
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func FetchProjectMetadata(ctx context.Context, req *http.Request, pid string) (jsonutils.JSONObject, error) {
|
||||
s := auth.GetAdminSession(ctx, FetchRegion(req), "")
|
||||
meta, err := modules.Projects.GetSpecific(s, pid, "metadata", nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetProjectMetadata")
|
||||
}
|
||||
return meta, nil
|
||||
}
|
||||
|
||||
func isUserEnableTotp(userInfo jsonutils.JSONObject) bool {
|
||||
return jsonutils.QueryBoolean(userInfo, "enable_mfa", false)
|
||||
}
|
||||
@@ -779,6 +788,14 @@ func getUserInfo(ctx context.Context, req *http.Request) (*jsonutils.JSONDict, e
|
||||
data.Add(jsonutils.NewString(token.GetProjectDomain()), "projectDomain")
|
||||
data.Add(jsonutils.NewString(token.GetProjectDomainId()), "projectDomainId")
|
||||
|
||||
pmeta, err := FetchProjectMetadata(ctx, req, token.GetProjectId())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "FetchProjectMetadata")
|
||||
}
|
||||
if pmeta != nil {
|
||||
data.Add(pmeta, "project_meta")
|
||||
}
|
||||
|
||||
log.Infof("getUserInfo modules.RoleAssignments.List")
|
||||
query := jsonutils.NewDict()
|
||||
query.Add(jsonutils.JSONNull, "effective")
|
||||
|
||||
Reference in New Issue
Block a user