-
Notifications
You must be signed in to change notification settings - Fork 7
/
helpers.go
47 lines (41 loc) · 1.35 KB
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package clients
import (
"fmt"
"strings"
"time"
)
type AppPassword struct {
ClientID string `json:"clientId"`
Secret string `json:"secret"`
Description string `json:"description"`
Owner string `json:"owner"`
CreatedAt time.Time `json:"created_at"`
}
type Region string
// Role represents the Frontegg role structure.
type Role struct {
ID string `json:"id"`
VendorID string `json:"vendorId"`
TenantID *string `json:"tenantId,omitempty"`
Key string `json:"key"`
Name string `json:"name"`
Description string `json:"description"`
IsDefault bool `json:"isDefault"`
FirstUserRole bool `json:"firstUserRole"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Permissions []string `json:"permissions"`
Level int `json:"level"`
}
// Helper function to construct app password from clientId and secret.
func ConstructAppPassword(clientID, secret string) string {
// Remove dashes and concatenate with "mzp_" prefix.
clientIDClean := strings.ReplaceAll(clientID, "-", "")
secretClean := strings.ReplaceAll(secret, "-", "")
return fmt.Sprintf("mzp_%s%s", clientIDClean, secretClean)
}
const (
AwsUsEast1 Region = "aws/us-east-1"
AwsUsWest2 Region = "aws/us-west-2"
AwsEuWest1 Region = "aws/eu-west-1"
)