| 1 |
package client |
| 2 |
|
| 3 |
import ( |
| 4 |
"encoding/json" |
| 5 |
"os" |
| 6 |
) |
| 7 |
|
| 8 |
const ( |
| 9 |
serviceAccountKey = "serviceaccount" |
| 10 |
applicationKey = "application" |
| 11 |
) |
| 12 |
|
| 13 |
// Deprecated: use [github.com/zitadel/zitadel-go/v3/pkg/client.KeyFile] instead. |
| 14 |
// The type will be removed in the next major release. |
| 15 |
type KeyFile struct { |
| 16 |
Type string `json:"type"` // serviceaccount or application |
| 17 |
KeyID string `json:"keyId"` |
| 18 |
Key string `json:"key"` |
| 19 |
Issuer string `json:"issuer"` // not yet in file |
| 20 |
|
| 21 |
// serviceaccount |
| 22 |
UserID string `json:"userId"` |
| 23 |
|
| 24 |
// application |
| 25 |
ClientID string `json:"clientId"` |
| 26 |
} |
| 27 |
|
| 28 |
// Deprecated: use [github.com/zitadel/zitadel-go/v3/pkg/client.ConfigFromKeyFile] instead. |
| 29 |
// The type will be removed in the next major release. |
| 30 |
func ConfigFromKeyFile(path string) (*KeyFile, error) { |
| 31 |
data, err := os.ReadFile(path) |
| 32 |
if err != nil { |
| 33 |
return nil, err |
| 34 |
} |
| 35 |
return ConfigFromKeyFileData(data) |
| 36 |
} |
| 37 |
|
| 38 |
// Deprecated: use [github.com/zitadel/zitadel-go/v3/pkg/client.ConfigFromKeyFileData] instead. |
| 39 |
// The type will be removed in the next major release. |
| 40 |
func ConfigFromKeyFileData(data []byte) (*KeyFile, error) { |
| 41 |
var f KeyFile |
| 42 |
if err := json.Unmarshal(data, &f); err != nil { |
| 43 |
return nil, err |
| 44 |
} |
| 45 |
return &f, nil |
| 46 |
} |