From 4147fbeba0c96581f5701ede8a84248d283c166d Mon Sep 17 00:00:00 2001 From: Kevin Schu Date: Thu, 1 Jul 2021 15:12:28 +0200 Subject: [PATCH] subiss needs to be part of selected fields, otherwise this attribute would be empty and will cause issues when working with the user object later on. Signed-off-by: Kevin Schu --- src/pkg/oidc/dao/meta.go | 2 +- src/pkg/oidc/dao/meta_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/oidc/dao/meta.go b/src/pkg/oidc/dao/meta.go index 2c280ba41..a1904c191 100644 --- a/src/pkg/oidc/dao/meta.go +++ b/src/pkg/oidc/dao/meta.go @@ -43,7 +43,7 @@ func NewMetaDao() MetaDAO { type metaDAO struct{} func (md *metaDAO) GetByUsername(ctx context.Context, username string) (*models.OIDCUser, error) { - sql := `SELECT oidc_user.id, oidc_user.user_id, oidc_user.secret, oidc_user.token, + sql := `SELECT oidc_user.id, oidc_user.user_id, oidc_user.secret, oidc_user.subiss, oidc_user.token, oidc_user.creation_time, oidc_user.update_time FROM oidc_user JOIN harbor_user ON oidc_user.user_id = harbor_user.user_id WHERE harbor_user.username = ?` diff --git a/src/pkg/oidc/dao/meta_test.go b/src/pkg/oidc/dao/meta_test.go index d10637d96..cb9867856 100644 --- a/src/pkg/oidc/dao/meta_test.go +++ b/src/pkg/oidc/dao/meta_test.go @@ -63,6 +63,7 @@ func (suite *MetaDaoTestSuite) TestGetByUsername() { ou, err := suite.dao.GetByUsername(ctx, suite.username) suite.Nil(err) suite.Equal(suite.userID, ou.UserID) + suite.Equal("ca4bb144-4b5c-4d1b-9469-69cb3768af8fhttps://sso.andrea.muellerpublic.de/auth/realms/harbor", ou.SubIss) suite.Equal("xxxx", ou.Token) }