mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
feat(actions): allow getting metadata of organizations from user grants (#7782)
* feat(actions): allow getting metadata of (other) organizations from user grants * docs add action example
This commit is contained in:
@@ -490,25 +490,16 @@ func (o *OPStorage) userinfoFlows(ctx context.Context, user *query.User, userGra
|
||||
return object.UserMetadataListFromQuery(c, metadata)
|
||||
}
|
||||
}),
|
||||
actions.SetFields("grants", func(c *actions.FieldConfig) interface{} {
|
||||
return object.UserGrantsFromQuery(c, userGrants)
|
||||
}),
|
||||
actions.SetFields("grants",
|
||||
func(c *actions.FieldConfig) interface{} {
|
||||
return object.UserGrantsFromQuery(ctx, o.query, c, userGrants)
|
||||
},
|
||||
),
|
||||
),
|
||||
actions.SetFields("org",
|
||||
actions.SetFields("getMetadata", func(c *actions.FieldConfig) interface{} {
|
||||
return func(goja.FunctionCall) goja.Value {
|
||||
metadata, err := o.query.SearchOrgMetadata(
|
||||
ctx,
|
||||
true,
|
||||
user.ResourceOwner,
|
||||
&query.OrgMetadataSearchQueries{},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
logging.WithError(err).Info("unable to get org metadata in action")
|
||||
panic(err)
|
||||
}
|
||||
return object.OrgMetadataListFromQuery(c, metadata)
|
||||
return object.GetOrganizationMetadata(ctx, o.query, c, user.ResourceOwner)
|
||||
}
|
||||
}),
|
||||
),
|
||||
@@ -714,24 +705,13 @@ func (o *OPStorage) privateClaimsFlows(ctx context.Context, userID string, userG
|
||||
}
|
||||
}),
|
||||
actions.SetFields("grants", func(c *actions.FieldConfig) interface{} {
|
||||
return object.UserGrantsFromQuery(c, userGrants)
|
||||
return object.UserGrantsFromQuery(ctx, o.query, c, userGrants)
|
||||
}),
|
||||
),
|
||||
actions.SetFields("org",
|
||||
actions.SetFields("getMetadata", func(c *actions.FieldConfig) interface{} {
|
||||
return func(goja.FunctionCall) goja.Value {
|
||||
metadata, err := o.query.SearchOrgMetadata(
|
||||
ctx,
|
||||
true,
|
||||
user.ResourceOwner,
|
||||
&query.OrgMetadataSearchQueries{},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
logging.WithError(err).Info("unable to get org metadata in action")
|
||||
panic(err)
|
||||
}
|
||||
return object.OrgMetadataListFromQuery(c, metadata)
|
||||
return object.GetOrganizationMetadata(ctx, o.query, c, user.ResourceOwner)
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
@@ -252,24 +252,13 @@ func (s *Server) userinfoFlows(ctx context.Context, qu *query.OIDCUserInfo, user
|
||||
}
|
||||
}),
|
||||
actions.SetFields("grants", func(c *actions.FieldConfig) interface{} {
|
||||
return object.UserGrantsFromSlice(c, qu.UserGrants)
|
||||
return object.UserGrantsFromSlice(ctx, s.query, c, qu.UserGrants)
|
||||
}),
|
||||
),
|
||||
actions.SetFields("org",
|
||||
actions.SetFields("getMetadata", func(c *actions.FieldConfig) interface{} {
|
||||
return func(goja.FunctionCall) goja.Value {
|
||||
metadata, err := s.query.SearchOrgMetadata(
|
||||
ctx,
|
||||
true,
|
||||
qu.User.ResourceOwner,
|
||||
&query.OrgMetadataSearchQueries{},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
logging.WithError(err).Info("unable to get org metadata in action")
|
||||
panic(err)
|
||||
}
|
||||
return object.OrgMetadataListFromQuery(c, metadata)
|
||||
return object.GetOrganizationMetadata(ctx, s.query, c, qu.User.ResourceOwner)
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
@@ -246,24 +246,13 @@ func (p *Storage) getCustomAttributes(ctx context.Context, user *query.User, use
|
||||
}
|
||||
}),
|
||||
actions.SetFields("grants", func(c *actions.FieldConfig) interface{} {
|
||||
return object.UserGrantsFromQuery(c, userGrants)
|
||||
return object.UserGrantsFromQuery(ctx, p.query, c, userGrants)
|
||||
}),
|
||||
),
|
||||
actions.SetFields("org",
|
||||
actions.SetFields("getMetadata", func(c *actions.FieldConfig) interface{} {
|
||||
return func(goja.FunctionCall) goja.Value {
|
||||
metadata, err := p.query.SearchOrgMetadata(
|
||||
ctx,
|
||||
true,
|
||||
user.ResourceOwner,
|
||||
&query.OrgMetadataSearchQueries{},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
logging.WithError(err).Info("unable to get org metadata in action")
|
||||
panic(err)
|
||||
}
|
||||
return object.OrgMetadataListFromQuery(c, metadata)
|
||||
return object.GetOrganizationMetadata(ctx, p.query, c, user.ResourceOwner)
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
Reference in New Issue
Block a user