mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fix: read key data for system api users from config (#3731)
This commit is contained in:
parent
b3f50702f8
commit
992892a8bb
@ -77,7 +77,19 @@ type systemJWTStorage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SystemAPIUser struct {
|
type SystemAPIUser struct {
|
||||||
Path string
|
Path string //if a path is specified, the key will be read from that path
|
||||||
|
KeyData []byte //else you can also specify the data directly in the KeyData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SystemAPIUser) readKey() (*rsa.PublicKey, error) {
|
||||||
|
if s.Path != "" {
|
||||||
|
var err error
|
||||||
|
s.KeyData, err = os.ReadFile(s.Path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, caos_errs.ThrowInternal(err, "AUTHZ-JK31F", "Errors.NotFound")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crypto.BytesToPublicKey(s.KeyData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemJWTStorage) GetKeyByIDAndUserID(_ context.Context, _, userID string) (*jose.JSONWebKey, error) {
|
func (s *systemJWTStorage) GetKeyByIDAndUserID(_ context.Context, _, userID string) (*jose.JSONWebKey, error) {
|
||||||
@ -91,11 +103,7 @@ func (s *systemJWTStorage) GetKeyByIDAndUserID(_ context.Context, _, userID stri
|
|||||||
}
|
}
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
keyData, err := os.ReadFile(key.Path)
|
publicKey, err := key.readKey()
|
||||||
if err != nil {
|
|
||||||
return nil, caos_errs.ThrowInternal(err, "AUTHZ-JK31F", "Errors.NotFound")
|
|
||||||
}
|
|
||||||
publicKey, err := crypto.BytesToPublicKey(keyData)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user