mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-07 14:52:15 +00:00
perf(oidc): optimize the introspection endpoint (#6909)
* get key by id and cache them * userinfo from events for v2 tokens * improve keyset caching * concurrent token and client checks * client and project in single query * logging and otel * drop owner_removed column on apps and authN tables * userinfo and project roles in go routines * get oidc user info from projections and add actions * add avatar URL * some cleanup * pull oidc work branch * remove storage from server * add config flag for experimental introspection * legacy introspection flag * drop owner_removed column on user projections * drop owner_removed column on useer_metadata * query userinfo unit test * query introspection client test * add user_grants to the userinfo query * handle PAT scopes * bring triggers back * test instance keys query * add userinfo unit tests * unit test keys * go mod tidy * solve some bugs * fix missing preferred login name * do not run triggers in go routines, they seem to deadlock * initialize the trigger handlers late with a sync.OnceValue * Revert "do not run triggers in go routines, they seem to deadlock" This reverts commit 2a03da2127b7dc74552ec25d4772282a82cc1cba. * add missing translations * chore: update go version for linting * pin oidc version * parse a global time location for query test * fix linter complains * upgrade go lint * fix more linting issues --------- Co-authored-by: Stefan Benz <[email protected]>
This commit is contained in:
co-authored by
Stefan Benz
parent
ad3563d58b
commit
ba9b807854
@@ -347,7 +347,7 @@ func (l *Login) runPostCreationActions(
|
||||
actions.SetFields("v1",
|
||||
actions.SetFields("getUser", func(c *actions.FieldConfig) interface{} {
|
||||
return func(call goja.FunctionCall) goja.Value {
|
||||
user, err := l.query.GetUserByID(actionCtx, true, userID, false)
|
||||
user, err := l.query.GetUserByID(actionCtx, true, userID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ func (l *Login) registerExternalUser(w http.ResponseWriter, r *http.Request, aut
|
||||
|
||||
// updateExternalUser will update the existing user (email, phone, profile) with data provided by the IDP
|
||||
func (l *Login) updateExternalUser(ctx context.Context, authReq *domain.AuthRequest, externalUser *domain.ExternalUser) error {
|
||||
user, err := l.query.GetUserByID(ctx, true, authReq.UserID, false)
|
||||
user, err := l.query.GetUserByID(ctx, true, authReq.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (l *Login) resendPasswordSet(w http.ResponseWriter, r *http.Request, authRe
|
||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
||||
return
|
||||
}
|
||||
user, err := l.query.GetUser(setContext(r.Context(), userOrg), false, false, loginName)
|
||||
user, err := l.query.GetUser(setContext(r.Context(), userOrg), false, loginName)
|
||||
if err != nil {
|
||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
||||
return
|
||||
@@ -144,7 +144,7 @@ func (l *Login) renderInitPassword(w http.ResponseWriter, r *http.Request, authR
|
||||
}
|
||||
}
|
||||
if authReq == nil {
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID, false)
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID)
|
||||
if err == nil {
|
||||
l.customTexts(r.Context(), translator, user.ResourceOwner)
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func (l *Login) renderInitUser(w http.ResponseWriter, r *http.Request, authReq *
|
||||
}
|
||||
}
|
||||
if authReq == nil {
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID, false)
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID)
|
||||
if err == nil {
|
||||
l.customTexts(r.Context(), translator, user.ResourceOwner)
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func (l *Login) getClaimedUserIDsOfOrgDomain(ctx context.Context, orgName string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
users, err := l.query.SearchUsers(ctx, &query.UserSearchQueries{Queries: []query.SearchQuery{loginName}}, false)
|
||||
users, err := l.query.SearchUsers(ctx, &query.UserSearchQueries{Queries: []query.SearchQuery{loginName}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (l *Login) renderMailVerification(w http.ResponseWriter, r *http.Request, a
|
||||
profileData: l.getProfileData(authReq),
|
||||
}
|
||||
if authReq == nil {
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID, false)
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID)
|
||||
if err == nil {
|
||||
l.customTexts(r.Context(), translator, user.ResourceOwner)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ type smsInitFormData struct {
|
||||
// It will also add a successful OTP SMS check to the auth request.
|
||||
// If there's no verified phone number, the potential last phone number will be used to render the registration page
|
||||
func (l *Login) handleRegisterOTPSMS(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest) {
|
||||
user, err := l.query.GetNotifyUserByID(r.Context(), true, authReq.UserID, false)
|
||||
user, err := l.query.GetNotifyUserByID(r.Context(), true, authReq.UserID)
|
||||
if err != nil {
|
||||
l.renderError(w, r, authReq, err)
|
||||
return
|
||||
|
||||
@@ -22,7 +22,7 @@ func (l *Login) getPasswordComplexityPolicy(r *http.Request, orgID string) *iam_
|
||||
}
|
||||
|
||||
func (l *Login) getPasswordComplexityPolicyByUserID(r *http.Request, userID string) *iam_model.PasswordComplexityPolicyView {
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID, false)
|
||||
user, err := l.query.GetUserByID(r.Context(), false, userID)
|
||||
if err != nil {
|
||||
logging.WithFields("userID", userID).OnError(err).Error("could not load user for password complexity policy")
|
||||
return nil
|
||||
|
||||
@@ -23,7 +23,7 @@ func (l *Login) handlePasswordReset(w http.ResponseWriter, r *http.Request) {
|
||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
||||
return
|
||||
}
|
||||
user, err := l.query.GetUser(setContext(r.Context(), authReq.UserOrgID), true, false, loginName)
|
||||
user, err := l.query.GetUser(setContext(r.Context(), authReq.UserOrgID), true, loginName)
|
||||
if err != nil {
|
||||
if authReq.LoginPolicy.IgnoreUnknownUsernames && errors.IsNotFound(err) {
|
||||
err = nil
|
||||
|
||||
Reference in New Issue
Block a user