mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-09 10:13:42 +00:00
solve some bugs
This commit is contained in:
parent
728f838a09
commit
953e9433eb
@ -25,7 +25,7 @@ func (s *Server) Introspect(ctx context.Context, r *op.Request[op.IntrospectionR
|
|||||||
}
|
}
|
||||||
if s.features.TriggerIntrospectionProjections {
|
if s.features.TriggerIntrospectionProjections {
|
||||||
// Execute all triggers in one concurrent sweep.
|
// Execute all triggers in one concurrent sweep.
|
||||||
ctx = query.TriggerIntrospectionProjections(ctx)
|
query.TriggerIntrospectionProjections(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
@ -78,8 +78,8 @@ func (s *Server) Introspect(ctx context.Context, r *op.Request[op.IntrospectionR
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.getLogger(ctx).ErrorContext(ctx, "oidc introspection", "err", err)
|
s.getLogger(ctx).ErrorContext(ctx, "oidc introspection", "err", err)
|
||||||
|
resp, err = op.NewResponse(new(oidc.IntrospectionResponse)), nil
|
||||||
}
|
}
|
||||||
resp, err = op.NewResponse(new(oidc.IntrospectionResponse)), nil
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
with config as (
|
with config as (
|
||||||
select app_id, client_id, client_secret
|
select app_id, client_id, client_secret
|
||||||
from projections.apps5_api_configs
|
from projections.apps6_api_configs
|
||||||
where instance_id = $1
|
where instance_id = $1
|
||||||
and client_id = $2
|
and client_id = $2
|
||||||
union
|
union
|
||||||
select app_id, client_id, client_secret
|
select app_id, client_id, client_secret
|
||||||
from projections.apps5_oidc_configs
|
from projections.apps6_oidc_configs
|
||||||
where instance_id = $1
|
where instance_id = $1
|
||||||
and client_id = $2
|
and client_id = $2
|
||||||
),
|
),
|
||||||
keys as (
|
keys as (
|
||||||
select identifier as client_id, json_object_agg(id, public_key) as public_keys
|
select identifier as client_id, json_object_agg(id, encode(public_key, 'base64')) as public_keys
|
||||||
from projections.authn_keys2
|
from projections.authn_keys2
|
||||||
where $3 = true -- when argument is false, don't waste time on trying to query for keys.
|
where $3 = true -- when argument is false, don't waste time on trying to query for keys.
|
||||||
and instance_id = $1
|
and instance_id = $1
|
||||||
@ -19,5 +19,5 @@ keys as (
|
|||||||
group by identifier
|
group by identifier
|
||||||
)
|
)
|
||||||
select config.client_id, config.client_secret, apps.project_id, keys.public_keys from config
|
select config.client_id, config.client_secret, apps.project_id, keys.public_keys from config
|
||||||
join projections.apps5 apps on apps.id = config.app_id
|
join projections.apps6 apps on apps.id = config.app_id
|
||||||
left join keys on keys.client_id = config.client_id;
|
left join keys on keys.client_id = config.client_id;
|
||||||
|
@ -18,8 +18,8 @@ var introspectionTriggerHandlers = append(oidcUserInfoTriggerHandlers,
|
|||||||
projection.AuthNKeyProjection,
|
projection.AuthNKeyProjection,
|
||||||
)
|
)
|
||||||
|
|
||||||
func TriggerIntrospectionProjections(ctx context.Context) context.Context {
|
func TriggerIntrospectionProjections(ctx context.Context) {
|
||||||
return triggerBatch(ctx, introspectionTriggerHandlers...)
|
triggerBatch(ctx, introspectionTriggerHandlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
type IntrospectionClient struct {
|
type IntrospectionClient struct {
|
||||||
|
@ -153,22 +153,21 @@ func init() {
|
|||||||
|
|
||||||
// triggerBatch calls Trigger on every handler in a seperate Go routine.
|
// triggerBatch calls Trigger on every handler in a seperate Go routine.
|
||||||
// The returned context is the context returned by the Trigger that finishes last.
|
// The returned context is the context returned by the Trigger that finishes last.
|
||||||
func triggerBatch(ctx context.Context, handlers ...*handler.Handler) context.Context {
|
func triggerBatch(ctx context.Context, handlers ...*handler.Handler) {
|
||||||
ctxChan := make(chan context.Context)
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(len(handlers))
|
||||||
|
|
||||||
for _, h := range handlers {
|
for _, h := range handlers {
|
||||||
go func(ctx context.Context, h *handler.Handler, ctxChan chan<- context.Context) {
|
go func(ctx context.Context, h *handler.Handler) {
|
||||||
name := h.ProjectionName()
|
name := h.ProjectionName()
|
||||||
_, traceSpan := tracing.NewNamedSpan(ctx, fmt.Sprintf("Trigger%s", name))
|
_, traceSpan := tracing.NewNamedSpan(ctx, fmt.Sprintf("Trigger%s", name))
|
||||||
newCtx, err := h.Trigger(ctx, handler.WithAwaitRunning())
|
_, err := h.Trigger(ctx, handler.WithAwaitRunning())
|
||||||
logging.OnError(err).WithField("projection", name).Debug("trigger failed")
|
logging.OnError(err).WithField("projection", name).Debug("trigger failed")
|
||||||
traceSpan.EndWithError(err)
|
traceSpan.EndWithError(err)
|
||||||
ctxChan <- newCtx
|
|
||||||
}(ctx, h, ctxChan)
|
wg.Done()
|
||||||
|
}(ctx, h)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(handlers); i++ {
|
wg.Wait()
|
||||||
ctx = <-ctxChan
|
|
||||||
}
|
|
||||||
return ctx
|
|
||||||
}
|
}
|
||||||
|
@ -706,8 +706,8 @@ func NewUserLoginNameExistsQuery(value string, comparison TextComparison) (Searc
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func triggerUserProjections(ctx context.Context) context.Context {
|
func triggerUserProjections(ctx context.Context) {
|
||||||
return triggerBatch(ctx, projection.UserProjection, projection.LoginNameProjection)
|
triggerBatch(ctx, projection.UserProjection, projection.LoginNameProjection)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareLoginNamesQuery() (string, []interface{}, error) {
|
func prepareLoginNamesQuery() (string, []interface{}, error) {
|
||||||
|
@ -22,8 +22,8 @@ var oidcUserInfoTriggerHandlers = []*handler.Handler{
|
|||||||
projection.ProjectProjection,
|
projection.ProjectProjection,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TriggerOIDCUserInfoProjections(ctx context.Context) context.Context {
|
func TriggerOIDCUserInfoProjections(ctx context.Context) {
|
||||||
return triggerBatch(ctx, oidcUserInfoTriggerHandlers...)
|
triggerBatch(ctx, oidcUserInfoTriggerHandlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed embed/userinfo_by_id.sql
|
//go:embed embed/userinfo_by_id.sql
|
||||||
|
Loading…
x
Reference in New Issue
Block a user