MigrationAssistant: Restrict dashboards, folders and datasources by the org id of the signed in user (#96339)

apply security patch: main/206-202410241510.patch
This commit is contained in:
lean.dev
2024-11-12 13:03:16 -06:00
committed by GitHub
parent 9f02acd4ca
commit 750a0bed71
12 changed files with 188 additions and 115 deletions
+7 -1
View File
@@ -21,6 +21,7 @@ var (
// CloudMigrationSession represents a configured migration token
type CloudMigrationSession struct {
ID int64 `xorm:"pk autoincr 'id'"`
OrgID int64 `xorm:"org_id"`
UID string `xorm:"uid"`
AuthToken string
Slug string
@@ -144,6 +145,8 @@ type CloudMigrationRunList struct {
type CloudMigrationSessionRequest struct {
AuthToken string
// OrgId in the on prem instance
OrgID int64
}
type CloudMigrationSessionResponse struct {
@@ -159,6 +162,7 @@ type CloudMigrationSessionListResponse struct {
type GetSnapshotsQuery struct {
SnapshotUID string
OrgID int64
SessionUID string
ResultPage int
ResultLimit int
@@ -166,6 +170,7 @@ type GetSnapshotsQuery struct {
type ListSnapshotsQuery struct {
SessionUID string
OrgID int64
Page int
Limit int
Sort string
@@ -189,13 +194,14 @@ type Base64EncodedTokenPayload struct {
Instance Base64HGInstance
}
func (p Base64EncodedTokenPayload) ToMigration() CloudMigrationSession {
func (p Base64EncodedTokenPayload) ToMigration(orgID int64) CloudMigrationSession {
return CloudMigrationSession{
AuthToken: p.Token,
Slug: p.Instance.Slug,
StackID: p.Instance.StackID,
RegionSlug: p.Instance.RegionSlug,
ClusterSlug: p.Instance.ClusterSlug,
OrgID: orgID,
}
}