Files
grafana/pkg/services/sqlstore/migrations/externalsession/migrations.go
T
Misi bd7850853e Auth: Attach external session info to Grafana session (#93849)
* initial from poc changes

* wip

* Remove public external session service

* Update swagger

* Fix merge

* Cleanup

* Add backgroud service for cleanup

* Add auth_module to user_external_session

* Add tests for token revocation functions

* Add secret migration capabilities for user_external_session fields

* Cleanup, refactor to address feedback

* Fix test
2024-10-08 11:03:29 +02:00

32 lines
1.4 KiB
Go

package externalsession
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
func AddMigration(mg *migrator.Migrator) {
externalSessionV1 := migrator.Table{
Name: "user_external_session",
Columns: []*migrator.Column{
{Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "user_auth_id", Type: migrator.DB_BigInt, Nullable: false},
{Name: "user_id", Type: migrator.DB_BigInt, Nullable: false},
{Name: "auth_module", Type: migrator.DB_NVarchar, Length: 190, Nullable: false},
{Name: "access_token", Type: migrator.DB_Text, Nullable: true},
{Name: "id_token", Type: migrator.DB_Text, Nullable: true},
{Name: "refresh_token", Type: migrator.DB_Text, Nullable: true},
{Name: "session_id", Type: migrator.DB_NVarchar, Length: 255, Nullable: true},
{Name: "session_id_hash", Type: migrator.DB_Char, Length: 44, Nullable: true},
{Name: "name_id", Type: migrator.DB_NVarchar, Length: 255, Nullable: true},
{Name: "name_id_hash", Type: migrator.DB_Char, Length: 44, Nullable: true},
{Name: "expires_at", Type: migrator.DB_DateTime, Nullable: true},
{Name: "created_at", Type: migrator.DB_DateTime, Nullable: false},
},
Indices: []*migrator.Index{
{Cols: []string{"user_id"}},
{Cols: []string{"session_id_hash"}},
{Cols: []string{"name_id_hash"}},
},
}
mg.AddMigration("create user_external_session table", migrator.NewAddTableMigration(externalSessionV1))
}