feat(actions): add org metadata in complement token and saml response flows (#7263)

* feat(actions): add org metadata in complement token and saml response flows

* document actions
This commit is contained in:
Livio Spring
2024-01-26 09:56:10 +01:00
committed by GitHub
parent 17953e9040
commit 121f9f8da1
6 changed files with 116 additions and 0 deletions

View File

@@ -491,6 +491,24 @@ func (o *OPStorage) userinfoFlows(ctx context.Context, user *query.User, userGra
return object.UserGrantsFromQuery(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)
}
}),
),
),
)
@@ -690,6 +708,24 @@ func (o *OPStorage) privateClaimsFlows(ctx context.Context, userID string, userG
return object.UserGrantsFromQuery(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)
}
}),
),
),
)

View File

@@ -194,6 +194,24 @@ func (s *Server) userinfoFlows(ctx context.Context, qu *query.OIDCUserInfo, user
return object.UserGrantsFromSlice(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)
}
}),
),
),
)