diff --git a/agent/cli.go b/agent/cli.go index 1a77dfeacf..0bc285573d 100644 --- a/agent/cli.go +++ b/agent/cli.go @@ -309,7 +309,7 @@ var getConfig = &cobra.Command{ cmd.Println() cmd.Println("Haproxy Configuration:") cmd.Printf(" • Enabled ------------ %t\n", config.HaproxyConfig.Enabled) - cmd.Printf(" • Username ---------- %s\n", config.HaproxyConfig.Username) + cmd.Printf(" • userID ---------- %s\n", config.HaproxyConfig.Username) cmd.Printf(" • Password ---------- %s\n", config.HaproxyConfig.Password) }, } diff --git a/agent/haproxy_utils.go b/agent/haproxy_utils.go index 283785c052..2cd9c9912d 100644 --- a/agent/haproxy_utils.go +++ b/agent/haproxy_utils.go @@ -54,7 +54,7 @@ func installHAProxy(swiftwaveAddress string, dnsServer string, username string, // Write default dataplaneapi config dataplaneapiConfigContent := dataplaneapiConfig - dataplaneapiConfigContent = strings.ReplaceAll(dataplaneapiConfigContent, "{{ .Username }}", username) + dataplaneapiConfigContent = strings.ReplaceAll(dataplaneapiConfigContent, "{{ .userID }}", username) passwordHash, err := GenerateBasicAuthPassword(password) if err != nil { return err @@ -175,7 +175,7 @@ dataplaneapi: scheme: - http user: - - name: {{ .Username }} + - name: {{ .userID }} insecure: false password: {{ .Password }} resources: diff --git a/go.mod b/go.mod index b956943307..d53ccfd250 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golang-migrate/migrate/v4 v4.17.1 github.com/hashicorp/go-set v0.1.14 - github.com/labstack/echo-jwt/v4 v4.3.0 github.com/labstack/echo/v4 v4.13.3 github.com/lib/pq v1.10.9 github.com/mholt/acmez v1.2.0 @@ -46,7 +45,7 @@ require ( github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/gorilla/websocket v1.5.2 + github.com/gorilla/websocket v1.5.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect @@ -138,7 +137,7 @@ require ( github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect go.uber.org/atomic v1.11.0 // indirect diff --git a/go.sum b/go.sum index f6f5f75aa1..454aa45aaf 100644 --- a/go.sum +++ b/go.sum @@ -199,8 +199,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo-jwt/v4 v4.3.0 h1:8JcvVCrK9dRkPx/aWY3ZempZLO336Bebh4oAtBcxAv4= -github.com/labstack/echo-jwt/v4 v4.3.0/go.mod h1:OlWm3wqfnq3Ma8DLmmH7GiEAz2S7Bj23im2iPMEAR+Q= github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY= github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= diff --git a/swiftwave_service/cmd/user.go b/swiftwave_service/cmd/user.go index 49291eac38..10fab44626 100644 --- a/swiftwave_service/cmd/user.go +++ b/swiftwave_service/cmd/user.go @@ -15,10 +15,10 @@ func init() { userManagementCmd.AddCommand(createUserCmd) userManagementCmd.AddCommand(deleteUserCmd) userManagementCmd.AddCommand(disableTotpCmd) - createUserCmd.Flags().StringP("username", "u", "", "Username") + createUserCmd.Flags().StringP("username", "u", "", "userID") createUserCmd.Flags().StringP("password", "p", "", "Password [Optional]") - deleteUserCmd.Flags().StringP("username", "u", "", "Username") - disableTotpCmd.Flags().StringP("username", "u", "", "Username") + deleteUserCmd.Flags().StringP("username", "u", "", "userID") + disableTotpCmd.Flags().StringP("username", "u", "", "userID") } var userManagementCmd = &cobra.Command{ @@ -41,7 +41,7 @@ var createUserCmd = &cobra.Command{ username := cmd.Flag("username").Value.String() password := cmd.Flag("password").Value.String() if username == "" { - printError("Username is required") + printError("userID is required") err := cmd.Help() if err != nil { return @@ -108,7 +108,7 @@ var deleteUserCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { username := cmd.Flag("username").Value.String() if username == "" { - printError("Username is required") + printError("userID is required") err := cmd.Help() if err != nil { return @@ -146,7 +146,7 @@ var disableTotpCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { username := cmd.Flag("username").Value.String() if username == "" { - printError("Username is required") + printError("userID is required") err := cmd.Help() if err != nil { return diff --git a/swiftwave_service/core/models.go b/swiftwave_service/core/models.go index 019889d9e6..b443116fb3 100644 --- a/swiftwave_service/core/models.go +++ b/swiftwave_service/core/models.go @@ -37,12 +37,21 @@ type ServerLog struct { // User hold information about user type User struct { - ID uint `json:"id" gorm:"primaryKey"` - Username string `json:"username" gorm:"unique"` - Role UserRole `json:"role" gorm:"default:'user'"` - PasswordHash string `json:"password_hash"` - TotpEnabled bool `json:"totp_enabled" gorm:"default:false"` - TotpSecret string `json:"totp_secret"` + ID uint `json:"id" gorm:"primaryKey"` + Username string `json:"username" gorm:"unique"` + Role UserRole `json:"role" gorm:"default:'user'"` + PasswordHash string `json:"password_hash"` + TotpEnabled bool `json:"totp_enabled" gorm:"default:false"` + TotpSecret string `json:"totp_secret"` + Sessions []UserSession `json:"sessions" gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` +} + +// UserSession hold information about +type UserSession struct { + ID uint `json:"id" gorm:"primaryKey"` + UserID uint `json:"user_id"` + SessionID string `json:"session_id" gorm:"index"` + ExpiresAt time.Time `json:"expires_at"` } // ************************************************************************************* // diff --git a/swiftwave_service/core/user_session.operations.go b/swiftwave_service/core/user_session.operations.go new file mode 100644 index 0000000000..2eb3c7bab1 --- /dev/null +++ b/swiftwave_service/core/user_session.operations.go @@ -0,0 +1,45 @@ +package core + +import ( + "context" + "errors" + "github.com/labstack/gommon/random" + "gorm.io/gorm" + "time" +) + +// This file contains the operations for the User Sessions model. +// This functions will perform necessary validation before doing the actual database operation. + +// Each function's argument format should be (ctx context.Context, db gorm.DB, ...) +// context used to pass some data to the function e.g. user id, auth info, etc. + +// CreateSession : create session for user +func CreateSession(ctx context.Context, db gorm.DB, user User) (string, error) { + sessionRecord := &UserSession{ + UserID: user.ID, + SessionID: random.String(128), + ExpiresAt: time.Now().Add(time.Hour * 720), + } + // Create record + err := db.Create(sessionRecord).Error + if err != nil { + return "", err + } + return sessionRecord.SessionID, nil +} + +// DeleteSessionBySessionID : delete session record by session id +func DeleteSessionBySessionID(ctx context.Context, db gorm.DB, sessionID string) error { + return db.Where("session_id = ?", sessionID).Delete(&UserSession{}).Error +} + +// FetchUserIDBySessionID : get user by session id +func FetchUserIDBySessionID(ctx context.Context, db gorm.DB, sessionID string) (uint, error) { + var session UserSession + err := db.Where("session_id = ?", sessionID).Select("user_id").First(&session).Error + if err != nil { + return 0, errors.New("invalid session") + } + return session.UserID, nil +} diff --git a/swiftwave_service/db/migrations/20250213190430_test.down.sql b/swiftwave_service/db/migrations/20250213190430_test.down.sql new file mode 100644 index 0000000000..6bcacd9f12 --- /dev/null +++ b/swiftwave_service/db/migrations/20250213190430_test.down.sql @@ -0,0 +1,4 @@ +-- reverse: create index "idx_user_sessions_session_id" to table: "user_sessions" +DROP INDEX "public"."idx_user_sessions_session_id"; +-- reverse: create "user_sessions" table +DROP TABLE "public"."user_sessions"; diff --git a/swiftwave_service/db/migrations/20250213190430_test.up.sql b/swiftwave_service/db/migrations/20250213190430_test.up.sql new file mode 100644 index 0000000000..044f1ad02a --- /dev/null +++ b/swiftwave_service/db/migrations/20250213190430_test.up.sql @@ -0,0 +1,11 @@ +-- create "user_sessions" table +CREATE TABLE "public"."user_sessions" ( + "id" bigserial NOT NULL, + "user_id" bigint NULL, + "session_id" text NULL, + "expires_at" timestamptz NULL, + PRIMARY KEY ("id"), + CONSTRAINT "fk_users_sessions" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE CASCADE ON DELETE CASCADE +); +-- create index "idx_user_sessions_session_id" to table: "user_sessions" +CREATE INDEX "idx_user_sessions_session_id" ON "public"."user_sessions" ("session_id"); diff --git a/swiftwave_service/db/migrations/atlas.sum b/swiftwave_service/db/migrations/atlas.sum index 59632620e1..84a3322b5d 100644 --- a/swiftwave_service/db/migrations/atlas.sum +++ b/swiftwave_service/db/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:dFMxl02tstPc5Nmao8FA3S7sM7mIXqsSy34VElMP2gk= +h1:SwRv04ZCBJM2kVRlT9CroRjbfMlf4sOror5mPG2X/EM= 20240413191732_init.down.sql h1:HoitObGwuKF/akF4qg3dol2FfNTLCEuf6wHYDuCez8I= 20240413191732_init.up.sql h1:USKdQx/yTz1KJ0+mDwYGhKm3WzX7k+I9+6B6SxImwaE= 20240414051823_server_custom_ssh_port_added.down.sql h1:IC1DFQBQceTPTRdZOo5/WqytH+ZbgcKrQuMCkhArF/0= @@ -47,3 +47,5 @@ h1:dFMxl02tstPc5Nmao8FA3S7sM7mIXqsSy34VElMP2gk= 20240628175617_add_extra_fields_in_app_group.up.sql h1:+qBOQc/2bhG1igFdUbWSsZEy01aORuPyBPvxKVXJJoA= 20240906153014_add_hostname_in_application.down.sql h1:tFY94wo3G+UYA51UYt9jbfwwPTS/hCd3pG2F7smUEB8= 20240906153014_add_hostname_in_application.up.sql h1:JAhs73vgSIUzt0l8M8ltRp98dVkwL5lXrdkfHvJ+arE= +20250213190430_test.down.sql h1:ra8BJ92iaL0/Kc7MThF+wzbM1/szBVKHxJUWLq1hf5o= +20250213190430_test.up.sql h1:EDgRcbJknAyddUQ9X3+uGw/MNDilVWHRKcC+9Xuxuxg= diff --git a/swiftwave_service/db_models_loader/main.go b/swiftwave_service/db_models_loader/main.go index 25c6f4f113..dcaa5a9ca3 100644 --- a/swiftwave_service/db_models_loader/main.go +++ b/swiftwave_service/db_models_loader/main.go @@ -17,6 +17,7 @@ func main() { &core.Server{}, &core.ServerLog{}, &core.User{}, + &core.UserSession{}, &core.Domain{}, &core.RedirectRule{}, &core.PersistentVolume{}, diff --git a/swiftwave_service/graphql/authentication.resolvers.go b/swiftwave_service/graphql/authentication.resolvers.go new file mode 100644 index 0000000000..016df0caf6 --- /dev/null +++ b/swiftwave_service/graphql/authentication.resolvers.go @@ -0,0 +1,64 @@ +package graphql + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.48 + +import ( + "context" + "errors" + "net/http" + + "github.com/swiftwave-org/swiftwave/swiftwave_service/core" + "github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model" +) + +// Login is the resolver for the login field. +func (r *mutationResolver) Login(ctx context.Context, input model.UserCredential) (bool, error) { + // validate input + + if input.Username == "" || input.Password == "" { + return false, errors.New("username and password cannot be empty") + } + + user, err := core.FindUserByUsername(ctx, r.ServiceManager.DbClient, input.Username) + if err != nil { + return false, errors.New("invalid username or password") + } + if !user.CheckPassword(input.Password) { + return false, errors.New("invalid username or password") + } + + token, err := core.CreateSession(ctx, r.ServiceManager.DbClient, user) + if err != nil { + return false, errors.New("failed to create session") + } + + // Extract Echo context + eCtx, err := GetEchoContext(ctx) + if err != nil { + return false, err + } + eCtx.SetCookie(&http.Cookie{ + Name: "session_id", + Value: token, + HttpOnly: false, + Secure: false, + Path: "/", + }) + + return true, nil +} + +// Logout is the resolver for the logout field. +func (r *mutationResolver) Logout(ctx context.Context) (bool, error) { + auth := GetAuthInfo(ctx) + if !auth.IsAuthorized() { + return true, nil + } + err := core.DeleteSessionBySessionID(ctx, r.ServiceManager.DbClient, auth.GetSessionID()) + if err != nil { + return false, errors.New("failed to remove session") + } + return true, nil +} diff --git a/swiftwave_service/graphql/generated.go b/swiftwave_service/graphql/generated.go index 83a0557919..4d753e6040 100644 --- a/swiftwave_service/graphql/generated.go +++ b/swiftwave_service/graphql/generated.go @@ -60,6 +60,7 @@ type ResolverRoot interface { } type DirectiveRoot struct { + IsAuthenticated func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) } type ComplexityRoot struct { @@ -354,6 +355,8 @@ type ComplexityRoot struct { FetchAnalyticsServiceToken func(childComplexity int, id uint, rotate bool) int InstallDependenciesOnServer func(childComplexity int, id uint) int IssueSsl func(childComplexity int, id uint) int + Login func(childComplexity int, input model.UserCredential) int + Logout func(childComplexity int) int PromoteServerToManager func(childComplexity int, id uint) int ProtectIngressRuleUsingBasicAuth func(childComplexity int, id uint, appBasicAuthAccessControlListID uint) int PutServerInMaintenanceMode func(childComplexity int, id uint) int @@ -645,6 +648,8 @@ type MutationResolver interface { WakeApplication(ctx context.Context, id string) (bool, error) CreateApplicationGroup(ctx context.Context, input model.ApplicationGroupInput) (*model.ApplicationGroup, error) DeleteApplicationGroup(ctx context.Context, id string) (bool, error) + Login(ctx context.Context, input model.UserCredential) (bool, error) + Logout(ctx context.Context) (bool, error) CancelDeployment(ctx context.Context, id string) (bool, error) AddDomain(ctx context.Context, input model.DomainInput) (*model.Domain, error) RemoveDomain(ctx context.Context, id uint) (bool, error) @@ -2574,6 +2579,25 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.IssueSsl(childComplexity, args["id"].(uint)), true + case "Mutation.login": + if e.complexity.Mutation.Login == nil { + break + } + + args, err := ec.field_Mutation_login_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.Login(childComplexity, args["input"].(model.UserCredential)), true + + case "Mutation.logout": + if e.complexity.Mutation.Logout == nil { + break + } + + return e.complexity.Mutation.Logout(childComplexity), true + case "Mutation.promoteServerToManager": if e.complexity.Mutation.PromoteServerToManager == nil { break @@ -4018,6 +4042,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputServerSetupInput, ec.unmarshalInputStackInput, ec.unmarshalInputStackVariableType, + ec.unmarshalInputUserCredential, ec.unmarshalInputUserInput, ) first := true @@ -4132,7 +4157,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } -//go:embed "schema/app_authentication.graphqls" "schema/application.graphqls" "schema/application_group.graphqls" "schema/application_healthcheck.graphqls" "schema/base.graphqls" "schema/build_arg.graphqls" "schema/cifs_config.graphqls" "schema/config_mount.graphqls" "schema/deployment.graphqls" "schema/deployment_log.graphqls" "schema/docker_config_generator.graphqls" "schema/docker_proxy_config.graphqls" "schema/domain.graphqls" "schema/environment_variable.graphqls" "schema/git.graphqls" "schema/git_credential.graphqls" "schema/image_registry_credential.graphqls" "schema/ingress_rule.graphqls" "schema/nfs_config.graphqls" "schema/persistent_volume.graphqls" "schema/persistent_volume_backup.graphqls" "schema/persistent_volume_binding.graphqls" "schema/persistent_volume_restore.graphqls" "schema/redirect_rule.graphqls" "schema/runtime_log.graphqls" "schema/server.graphqls" "schema/server_log.graphqls" "schema/stack.graphqls" "schema/system.graphqls" "schema/system_log.graphqls" "schema/totp.graphqls" "schema/user.graphqls.graphqls" +//go:embed "schema/app_authentication.graphqls" "schema/application.graphqls" "schema/application_group.graphqls" "schema/application_healthcheck.graphqls" "schema/authentication.graphqls" "schema/base.graphqls" "schema/build_arg.graphqls" "schema/cifs_config.graphqls" "schema/config_mount.graphqls" "schema/deployment.graphqls" "schema/deployment_log.graphqls" "schema/directive.graphqls" "schema/docker_config_generator.graphqls" "schema/docker_proxy_config.graphqls" "schema/domain.graphqls" "schema/environment_variable.graphqls" "schema/git.graphqls" "schema/git_credential.graphqls" "schema/image_registry_credential.graphqls" "schema/ingress_rule.graphqls" "schema/nfs_config.graphqls" "schema/persistent_volume.graphqls" "schema/persistent_volume_backup.graphqls" "schema/persistent_volume_binding.graphqls" "schema/persistent_volume_restore.graphqls" "schema/redirect_rule.graphqls" "schema/runtime_log.graphqls" "schema/server.graphqls" "schema/server_log.graphqls" "schema/stack.graphqls" "schema/system.graphqls" "schema/system_log.graphqls" "schema/totp.graphqls" "schema/user.graphqls.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { @@ -4148,12 +4173,14 @@ var sources = []*ast.Source{ {Name: "schema/application.graphqls", Input: sourceData("schema/application.graphqls"), BuiltIn: false}, {Name: "schema/application_group.graphqls", Input: sourceData("schema/application_group.graphqls"), BuiltIn: false}, {Name: "schema/application_healthcheck.graphqls", Input: sourceData("schema/application_healthcheck.graphqls"), BuiltIn: false}, + {Name: "schema/authentication.graphqls", Input: sourceData("schema/authentication.graphqls"), BuiltIn: false}, {Name: "schema/base.graphqls", Input: sourceData("schema/base.graphqls"), BuiltIn: false}, {Name: "schema/build_arg.graphqls", Input: sourceData("schema/build_arg.graphqls"), BuiltIn: false}, {Name: "schema/cifs_config.graphqls", Input: sourceData("schema/cifs_config.graphqls"), BuiltIn: false}, {Name: "schema/config_mount.graphqls", Input: sourceData("schema/config_mount.graphqls"), BuiltIn: false}, {Name: "schema/deployment.graphqls", Input: sourceData("schema/deployment.graphqls"), BuiltIn: false}, {Name: "schema/deployment_log.graphqls", Input: sourceData("schema/deployment_log.graphqls"), BuiltIn: false}, + {Name: "schema/directive.graphqls", Input: sourceData("schema/directive.graphqls"), BuiltIn: false}, {Name: "schema/docker_config_generator.graphqls", Input: sourceData("schema/docker_config_generator.graphqls"), BuiltIn: false}, {Name: "schema/docker_proxy_config.graphqls", Input: sourceData("schema/docker_proxy_config.graphqls"), BuiltIn: false}, {Name: "schema/domain.graphqls", Input: sourceData("schema/domain.graphqls"), BuiltIn: false}, @@ -4933,6 +4960,21 @@ func (ec *executionContext) field_Mutation_issueSSL_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.UserCredential + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNUserCredential2githubᚗcomᚋswiftwaveᚑorgᚋswiftwaveᚋswiftwave_serviceᚋgraphqlᚋmodelᚐUserCredential(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_promoteServerToManager_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -14144,8 +14186,28 @@ func (ec *executionContext) _Mutation_createAppBasicAuthAccessControlList(ctx co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateAppBasicAuthAccessControlList(rctx, fc.Args["input"].(model.AppBasicAuthAccessControlListInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateAppBasicAuthAccessControlList(rctx, fc.Args["input"].(model.AppBasicAuthAccessControlListInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.AppBasicAuthAccessControlList); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.AppBasicAuthAccessControlList`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14209,8 +14271,28 @@ func (ec *executionContext) _Mutation_deleteAppBasicAuthAccessControlList(ctx co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteAppBasicAuthAccessControlList(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteAppBasicAuthAccessControlList(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14264,8 +14346,28 @@ func (ec *executionContext) _Mutation_createAppBasicAuthAccessControlUser(ctx co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateAppBasicAuthAccessControlUser(rctx, fc.Args["input"].(model.AppBasicAuthAccessControlUserInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateAppBasicAuthAccessControlUser(rctx, fc.Args["input"].(model.AppBasicAuthAccessControlUserInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.AppBasicAuthAccessControlUser); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.AppBasicAuthAccessControlUser`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14325,8 +14427,28 @@ func (ec *executionContext) _Mutation_updateAppBasicAuthAccessControlUserPasswor } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateAppBasicAuthAccessControlUserPassword(rctx, fc.Args["id"].(uint), fc.Args["password"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateAppBasicAuthAccessControlUserPassword(rctx, fc.Args["id"].(uint), fc.Args["password"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14380,8 +14502,28 @@ func (ec *executionContext) _Mutation_deleteAppBasicAuthAccessControlUser(ctx co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteAppBasicAuthAccessControlUser(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteAppBasicAuthAccessControlUser(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14435,8 +14577,28 @@ func (ec *executionContext) _Mutation_createApplication(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateApplication(rctx, fc.Args["input"].(model.ApplicationInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateApplication(rctx, fc.Args["input"].(model.ApplicationInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Application); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Application`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14544,8 +14706,28 @@ func (ec *executionContext) _Mutation_updateApplication(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateApplication(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ApplicationInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateApplication(rctx, fc.Args["id"].(string), fc.Args["input"].(model.ApplicationInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Application); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Application`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14653,8 +14835,28 @@ func (ec *executionContext) _Mutation_updateApplicationGroup(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateApplicationGroup(rctx, fc.Args["id"].(string), fc.Args["groupId"].(*string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateApplicationGroup(rctx, fc.Args["id"].(string), fc.Args["groupId"].(*string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14708,8 +14910,28 @@ func (ec *executionContext) _Mutation_deleteApplication(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteApplication(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteApplication(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14763,8 +14985,28 @@ func (ec *executionContext) _Mutation_rebuildApplication(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RebuildApplication(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RebuildApplication(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14818,8 +15060,28 @@ func (ec *executionContext) _Mutation_restartApplication(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RestartApplication(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RestartApplication(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14873,8 +15135,28 @@ func (ec *executionContext) _Mutation_regenerateWebhookToken(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RegenerateWebhookToken(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RegenerateWebhookToken(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14928,8 +15210,28 @@ func (ec *executionContext) _Mutation_sleepApplication(ctx context.Context, fiel } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SleepApplication(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().SleepApplication(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14983,8 +15285,28 @@ func (ec *executionContext) _Mutation_wakeApplication(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().WakeApplication(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().WakeApplication(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15038,8 +15360,28 @@ func (ec *executionContext) _Mutation_createApplicationGroup(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateApplicationGroup(rctx, fc.Args["input"].(model.ApplicationGroupInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateApplicationGroup(rctx, fc.Args["input"].(model.ApplicationGroupInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ApplicationGroup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ApplicationGroup`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15103,8 +15445,28 @@ func (ec *executionContext) _Mutation_deleteApplicationGroup(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteApplicationGroup(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteApplicationGroup(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15145,6 +15507,105 @@ func (ec *executionContext) fieldContext_Mutation_deleteApplicationGroup(ctx con return fc, nil } +func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_login(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().Login(rctx, fc.Args["input"].(model.UserCredential)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_logout(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().Logout(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Mutation_cancelDeployment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_cancelDeployment(ctx, field) if err != nil { @@ -15158,8 +15619,28 @@ func (ec *executionContext) _Mutation_cancelDeployment(ctx context.Context, fiel } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CancelDeployment(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CancelDeployment(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15213,8 +15694,28 @@ func (ec *executionContext) _Mutation_addDomain(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AddDomain(rctx, fc.Args["input"].(model.DomainInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AddDomain(rctx, fc.Args["input"].(model.DomainInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Domain); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Domain`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15290,8 +15791,28 @@ func (ec *executionContext) _Mutation_removeDomain(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RemoveDomain(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RemoveDomain(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15345,8 +15866,28 @@ func (ec *executionContext) _Mutation_issueSSL(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IssueSsl(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().IssueSsl(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Domain); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Domain`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15422,8 +15963,28 @@ func (ec *executionContext) _Mutation_addCustomSSL(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AddCustomSsl(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.CustomSSLInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AddCustomSsl(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.CustomSSLInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Domain); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Domain`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15499,8 +16060,28 @@ func (ec *executionContext) _Mutation_createGitCredential(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateGitCredential(rctx, fc.Args["input"].(model.GitCredentialInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateGitCredential(rctx, fc.Args["input"].(model.GitCredentialInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.GitCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.GitCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15568,8 +16149,28 @@ func (ec *executionContext) _Mutation_updateGitCredential(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateGitCredential(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.GitCredentialInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateGitCredential(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.GitCredentialInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.GitCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.GitCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15637,8 +16238,28 @@ func (ec *executionContext) _Mutation_deleteGitCredential(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteGitCredential(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteGitCredential(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15692,8 +16313,28 @@ func (ec *executionContext) _Mutation_createImageRegistryCredential(ctx context. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateImageRegistryCredential(rctx, fc.Args["input"].(model.ImageRegistryCredentialInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateImageRegistryCredential(rctx, fc.Args["input"].(model.ImageRegistryCredentialInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ImageRegistryCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ImageRegistryCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15759,8 +16400,28 @@ func (ec *executionContext) _Mutation_updateImageRegistryCredential(ctx context. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateImageRegistryCredential(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.ImageRegistryCredentialInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateImageRegistryCredential(rctx, fc.Args["id"].(uint), fc.Args["input"].(model.ImageRegistryCredentialInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ImageRegistryCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ImageRegistryCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15826,8 +16487,28 @@ func (ec *executionContext) _Mutation_deleteImageRegistryCredential(ctx context. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteImageRegistryCredential(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteImageRegistryCredential(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15881,8 +16562,28 @@ func (ec *executionContext) _Mutation_createIngressRule(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateIngressRule(rctx, fc.Args["input"].(model.IngressRuleInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateIngressRule(rctx, fc.Args["input"].(model.IngressRuleInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.IngressRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.IngressRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15972,8 +16673,28 @@ func (ec *executionContext) _Mutation_recreateIngressRule(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RecreateIngressRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RecreateIngressRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16027,8 +16748,28 @@ func (ec *executionContext) _Mutation_enableHttpsRedirectIngressRule(ctx context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().EnableHTTPSRedirectIngressRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().EnableHTTPSRedirectIngressRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16082,8 +16823,28 @@ func (ec *executionContext) _Mutation_disableHttpsRedirectIngressRule(ctx contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DisableHTTPSRedirectIngressRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DisableHTTPSRedirectIngressRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16137,8 +16898,28 @@ func (ec *executionContext) _Mutation_deleteIngressRule(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteIngressRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteIngressRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16192,8 +16973,28 @@ func (ec *executionContext) _Mutation_protectIngressRuleUsingBasicAuth(ctx conte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ProtectIngressRuleUsingBasicAuth(rctx, fc.Args["id"].(uint), fc.Args["appBasicAuthAccessControlListId"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ProtectIngressRuleUsingBasicAuth(rctx, fc.Args["id"].(uint), fc.Args["appBasicAuthAccessControlListId"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16247,8 +17048,28 @@ func (ec *executionContext) _Mutation_disableIngressRuleProtection(ctx context.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DisableIngressRuleProtection(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DisableIngressRuleProtection(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16302,8 +17123,28 @@ func (ec *executionContext) _Mutation_createPersistentVolume(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreatePersistentVolume(rctx, fc.Args["input"].(model.PersistentVolumeInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreatePersistentVolume(rctx, fc.Args["input"].(model.PersistentVolumeInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.PersistentVolume); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.PersistentVolume`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16372,8 +17213,28 @@ func (ec *executionContext) _Mutation_deletePersistentVolume(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeletePersistentVolume(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeletePersistentVolume(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16427,8 +17288,28 @@ func (ec *executionContext) _Mutation_backupPersistentVolume(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().BackupPersistentVolume(rctx, fc.Args["input"].(model.PersistentVolumeBackupInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().BackupPersistentVolume(rctx, fc.Args["input"].(model.PersistentVolumeBackupInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.PersistentVolumeBackup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.PersistentVolumeBackup`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16493,8 +17374,28 @@ func (ec *executionContext) _Mutation_deletePersistentVolumeBackup(ctx context.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeletePersistentVolumeBackup(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeletePersistentVolumeBackup(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16548,8 +17449,28 @@ func (ec *executionContext) _Mutation_deletePersistentVolumeBackupsByPersistentV } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeletePersistentVolumeBackupsByPersistentVolumeID(rctx, fc.Args["persistentVolumeId"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeletePersistentVolumeBackupsByPersistentVolumeID(rctx, fc.Args["persistentVolumeId"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16603,8 +17524,28 @@ func (ec *executionContext) _Mutation_deletePersistentVolumeRestore(ctx context. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeletePersistentVolumeRestore(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeletePersistentVolumeRestore(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16658,8 +17599,28 @@ func (ec *executionContext) _Mutation_deletePersistentVolumeRestoresByPersistent } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeletePersistentVolumeRestoresByPersistentVolumeID(rctx, fc.Args["persistentVolumeId"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeletePersistentVolumeRestoresByPersistentVolumeID(rctx, fc.Args["persistentVolumeId"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16713,8 +17674,28 @@ func (ec *executionContext) _Mutation_createRedirectRule(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateRedirectRule(rctx, fc.Args["input"].(model.RedirectRuleInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateRedirectRule(rctx, fc.Args["input"].(model.RedirectRuleInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.RedirectRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.RedirectRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16786,8 +17767,28 @@ func (ec *executionContext) _Mutation_deleteRedirectRule(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteRedirectRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteRedirectRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16841,8 +17842,28 @@ func (ec *executionContext) _Mutation_createServer(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateServer(rctx, fc.Args["input"].(model.NewServerInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateServer(rctx, fc.Args["input"].(model.NewServerInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Server); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Server`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16926,8 +17947,28 @@ func (ec *executionContext) _Mutation_deleteServer(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16981,8 +18022,28 @@ func (ec *executionContext) _Mutation_testSSHAccessToServer(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().TestSSHAccessToServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().TestSSHAccessToServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17036,8 +18097,28 @@ func (ec *executionContext) _Mutation_checkDependenciesOnServer(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CheckDependenciesOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CheckDependenciesOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.Dependency); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Dependency`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17094,8 +18175,28 @@ func (ec *executionContext) _Mutation_installDependenciesOnServer(ctx context.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().InstallDependenciesOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().InstallDependenciesOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17149,8 +18250,28 @@ func (ec *executionContext) _Mutation_setupServer(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetupServer(rctx, fc.Args["input"].(model.ServerSetupInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().SetupServer(rctx, fc.Args["input"].(model.ServerSetupInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17204,8 +18325,28 @@ func (ec *executionContext) _Mutation_promoteServerToManager(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().PromoteServerToManager(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().PromoteServerToManager(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17259,8 +18400,28 @@ func (ec *executionContext) _Mutation_demoteServerToWorker(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DemoteServerToWorker(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DemoteServerToWorker(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17314,8 +18475,28 @@ func (ec *executionContext) _Mutation_restrictDeploymentOnServer(ctx context.Con } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RestrictDeploymentOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RestrictDeploymentOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17369,8 +18550,28 @@ func (ec *executionContext) _Mutation_allowDeploymentOnServer(ctx context.Contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AllowDeploymentOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AllowDeploymentOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17424,8 +18625,28 @@ func (ec *executionContext) _Mutation_putServerInMaintenanceMode(ctx context.Con } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().PutServerInMaintenanceMode(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().PutServerInMaintenanceMode(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17479,8 +18700,28 @@ func (ec *executionContext) _Mutation_putServerOutOfMaintenanceMode(ctx context. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().PutServerOutOfMaintenanceMode(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().PutServerOutOfMaintenanceMode(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17534,8 +18775,28 @@ func (ec *executionContext) _Mutation_removeServerFromSwarmCluster(ctx context.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RemoveServerFromSwarmCluster(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RemoveServerFromSwarmCluster(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17589,8 +18850,28 @@ func (ec *executionContext) _Mutation_enableProxyOnServer(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().EnableProxyOnServer(rctx, fc.Args["id"].(uint), fc.Args["type"].(model.ProxyType)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().EnableProxyOnServer(rctx, fc.Args["id"].(uint), fc.Args["type"].(model.ProxyType)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17644,8 +18925,28 @@ func (ec *executionContext) _Mutation_disableProxyOnServer(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DisableProxyOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DisableProxyOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17699,8 +19000,28 @@ func (ec *executionContext) _Mutation_fetchAnalyticsServiceToken(ctx context.Con } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FetchAnalyticsServiceToken(rctx, fc.Args["id"].(uint), fc.Args["rotate"].(bool)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().FetchAnalyticsServiceToken(rctx, fc.Args["id"].(uint), fc.Args["rotate"].(bool)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17754,8 +19075,28 @@ func (ec *executionContext) _Mutation_changeServerIpAddress(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ChangeServerIPAddress(rctx, fc.Args["id"].(uint), fc.Args["ip"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ChangeServerIPAddress(rctx, fc.Args["id"].(uint), fc.Args["ip"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17809,8 +19150,28 @@ func (ec *executionContext) _Mutation_changeServerSSHPort(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ChangeServerSSHPort(rctx, fc.Args["id"].(uint), fc.Args["port"].(int)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ChangeServerSSHPort(rctx, fc.Args["id"].(uint), fc.Args["port"].(int)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17864,8 +19225,28 @@ func (ec *executionContext) _Mutation_cleanupStack(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CleanupStack(rctx, fc.Args["input"].(model.StackInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CleanupStack(rctx, fc.Args["input"].(model.StackInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17919,8 +19300,28 @@ func (ec *executionContext) _Mutation_verifyStack(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().VerifyStack(rctx, fc.Args["input"].(model.StackInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().VerifyStack(rctx, fc.Args["input"].(model.StackInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.StackVerifyResult); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.StackVerifyResult`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -17994,8 +19395,28 @@ func (ec *executionContext) _Mutation_deployStack(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeployStack(rctx, fc.Args["input"].(model.StackInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeployStack(rctx, fc.Args["input"].(model.StackInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ApplicationDeployResult); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ApplicationDeployResult`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18057,8 +19478,28 @@ func (ec *executionContext) _Mutation_restartSystem(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RestartSystem(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RestartSystem(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18101,8 +19542,28 @@ func (ec *executionContext) _Mutation_requestTotpEnable(ctx context.Context, fie } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().RequestTotpEnable(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().RequestTotpEnable(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.RequestTotpEnable); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.RequestTotpEnable`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18151,8 +19612,28 @@ func (ec *executionContext) _Mutation_enableTotp(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().EnableTotp(rctx, fc.Args["totp"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().EnableTotp(rctx, fc.Args["totp"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18206,8 +19687,28 @@ func (ec *executionContext) _Mutation_disableTotp(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DisableTotp(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DisableTotp(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18250,8 +19751,28 @@ func (ec *executionContext) _Mutation_createUser(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(*model.UserInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(*model.UserInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.User`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18310,8 +19831,28 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18365,8 +19906,28 @@ func (ec *executionContext) _Mutation_changePassword(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ChangePassword(rctx, fc.Args["input"].(*model.PasswordUpdateInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ChangePassword(rctx, fc.Args["input"].(*model.PasswordUpdateInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -19878,8 +21439,28 @@ func (ec *executionContext) _Query_appBasicAuthAccessControlLists(ctx context.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AppBasicAuthAccessControlLists(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AppBasicAuthAccessControlLists(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.AppBasicAuthAccessControlList); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.AppBasicAuthAccessControlList`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -19932,8 +21513,28 @@ func (ec *executionContext) _Query_application(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Application(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Application(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Application); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Application`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20041,8 +21642,28 @@ func (ec *executionContext) _Query_applications(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Applications(rctx, fc.Args["includeGroupedApplications"].(bool)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Applications(rctx, fc.Args["includeGroupedApplications"].(bool)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.Application); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Application`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20150,8 +21771,28 @@ func (ec *executionContext) _Query_isExistApplicationName(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IsExistApplicationName(rctx, fc.Args["name"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().IsExistApplicationName(rctx, fc.Args["name"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20205,8 +21846,28 @@ func (ec *executionContext) _Query_applicationResourceAnalytics(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ApplicationResourceAnalytics(rctx, fc.Args["id"].(string), fc.Args["timeframe"].(model.ApplicationResourceAnalyticsTimeframe)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ApplicationResourceAnalytics(rctx, fc.Args["id"].(string), fc.Args["timeframe"].(model.ApplicationResourceAnalyticsTimeframe)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ApplicationResourceAnalytics); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ApplicationResourceAnalytics`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20282,8 +21943,28 @@ func (ec *executionContext) _Query_applicationGroups(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ApplicationGroups(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ApplicationGroups(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ApplicationGroup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ApplicationGroup`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20336,8 +22017,28 @@ func (ec *executionContext) _Query_applicationGroup(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ApplicationGroup(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ApplicationGroup(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ApplicationGroup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ApplicationGroup`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20401,8 +22102,28 @@ func (ec *executionContext) _Query_deployment(ctx context.Context, field graphql } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Deployment(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Deployment(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Deployment); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Deployment`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20508,8 +22229,28 @@ func (ec *executionContext) _Query_dockerConfigGenerator(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DockerConfigGenerator(rctx, fc.Args["input"].(model.DockerConfigGeneratorInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DockerConfigGenerator(rctx, fc.Args["input"].(model.DockerConfigGeneratorInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.DockerConfigGeneratorOutput); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.DockerConfigGeneratorOutput`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20568,8 +22309,28 @@ func (ec *executionContext) _Query_availableDockerConfigs(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AvailableDockerConfigs(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().AvailableDockerConfigs(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20609,8 +22370,28 @@ func (ec *executionContext) _Query_dockerConfigFromServiceName(ctx context.Conte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DockerConfigFromServiceName(rctx, fc.Args["serviceName"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DockerConfigFromServiceName(rctx, fc.Args["serviceName"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.DockerConfigGeneratorOutput); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.DockerConfigGeneratorOutput`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20669,8 +22450,28 @@ func (ec *executionContext) _Query_domains(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Domains(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Domains(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.Domain); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Domain`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20735,8 +22536,28 @@ func (ec *executionContext) _Query_domain(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Domain(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Domain(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Domain); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Domain`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20812,8 +22633,28 @@ func (ec *executionContext) _Query_verifyDomainConfiguration(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().VerifyDomainConfiguration(rctx, fc.Args["name"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VerifyDomainConfiguration(rctx, fc.Args["name"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20867,8 +22708,28 @@ func (ec *executionContext) _Query_gitBranches(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GitBranches(rctx, fc.Args["input"].(model.GitBranchesQueryInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GitBranches(rctx, fc.Args["input"].(model.GitBranchesQueryInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20922,8 +22783,28 @@ func (ec *executionContext) _Query_gitCredentials(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GitCredentials(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GitCredentials(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.GitCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.GitCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -20980,8 +22861,28 @@ func (ec *executionContext) _Query_gitCredential(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GitCredential(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GitCredential(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.GitCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.GitCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21049,8 +22950,28 @@ func (ec *executionContext) _Query_checkGitCredentialRepositoryAccess(ctx contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CheckGitCredentialRepositoryAccess(rctx, fc.Args["input"].(model.GitCredentialRepositoryAccessInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().CheckGitCredentialRepositoryAccess(rctx, fc.Args["input"].(model.GitCredentialRepositoryAccessInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21104,8 +23025,28 @@ func (ec *executionContext) _Query_imageRegistryCredentials(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ImageRegistryCredentials(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ImageRegistryCredentials(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ImageRegistryCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ImageRegistryCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21160,8 +23101,28 @@ func (ec *executionContext) _Query_imageRegistryCredential(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ImageRegistryCredential(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ImageRegistryCredential(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ImageRegistryCredential); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ImageRegistryCredential`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21227,8 +23188,28 @@ func (ec *executionContext) _Query_ingressRule(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IngressRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().IngressRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.IngressRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.IngressRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21318,8 +23299,28 @@ func (ec *executionContext) _Query_ingressRules(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IngressRules(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().IngressRules(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.IngressRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.IngressRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21398,8 +23399,28 @@ func (ec *executionContext) _Query_isNewIngressRuleValid(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IsNewIngressRuleValid(rctx, fc.Args["input"].(model.IngressRuleValidationInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().IsNewIngressRuleValid(rctx, fc.Args["input"].(model.IngressRuleValidationInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21453,8 +23474,28 @@ func (ec *executionContext) _Query_persistentVolumes(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PersistentVolumes(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PersistentVolumes(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.PersistentVolume); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.PersistentVolume`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21512,8 +23553,28 @@ func (ec *executionContext) _Query_persistentVolume(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PersistentVolume(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PersistentVolume(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.PersistentVolume); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.PersistentVolume`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21582,8 +23643,28 @@ func (ec *executionContext) _Query_persistentVolumeSizeMb(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PersistentVolumeSizeMb(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PersistentVolumeSizeMb(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(float64); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be float64`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21637,8 +23718,28 @@ func (ec *executionContext) _Query_isExistPersistentVolume(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IsExistPersistentVolume(rctx, fc.Args["name"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().IsExistPersistentVolume(rctx, fc.Args["name"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21692,8 +23793,28 @@ func (ec *executionContext) _Query_redirectRule(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().RedirectRule(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().RedirectRule(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.RedirectRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.RedirectRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21765,8 +23886,28 @@ func (ec *executionContext) _Query_redirectRules(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().RedirectRules(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().RedirectRules(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.RedirectRule); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.RedirectRule`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21827,8 +23968,28 @@ func (ec *executionContext) _Query_noOfServers(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NoOfServers(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NoOfServers(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(int); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21871,8 +24032,28 @@ func (ec *executionContext) _Query_noOfPreparedServers(ctx context.Context, fiel } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NoOfPreparedServers(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NoOfPreparedServers(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(int); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21915,8 +24096,28 @@ func (ec *executionContext) _Query_servers(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Servers(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Servers(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.Server); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Server`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -21986,8 +24187,28 @@ func (ec *executionContext) _Query_server(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Server(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Server(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.Server); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.Server`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22071,8 +24292,28 @@ func (ec *executionContext) _Query_publicSSHKey(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PublicSSHKey(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PublicSSHKey(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22115,8 +24356,28 @@ func (ec *executionContext) _Query_serverResourceAnalytics(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ServerResourceAnalytics(rctx, fc.Args["id"].(uint), fc.Args["timeframe"].(model.ServerResourceAnalyticsTimeframe)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ServerResourceAnalytics(rctx, fc.Args["id"].(uint), fc.Args["timeframe"].(model.ServerResourceAnalyticsTimeframe)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ServerResourceAnalytics); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ServerResourceAnalytics`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22190,8 +24451,28 @@ func (ec *executionContext) _Query_serverDiskUsage(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ServerDiskUsage(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ServerDiskUsage(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.ServerDisksUsage); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ServerDisksUsage`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22251,8 +24532,28 @@ func (ec *executionContext) _Query_serverLatestResourceAnalytics(ctx context.Con } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ServerLatestResourceAnalytics(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ServerLatestResourceAnalytics(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ServerResourceAnalytics); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ServerResourceAnalytics`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22326,8 +24627,28 @@ func (ec *executionContext) _Query_serverLatestDiskUsage(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ServerLatestDiskUsage(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ServerLatestDiskUsage(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ServerDisksUsage); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.ServerDisksUsage`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22387,8 +24708,28 @@ func (ec *executionContext) _Query_networkInterfacesOnServer(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NetworkInterfacesOnServer(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NetworkInterfacesOnServer(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.NetworkInterface); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.NetworkInterface`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22448,8 +24789,28 @@ func (ec *executionContext) _Query_fetchServerLogContent(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FetchServerLogContent(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().FetchServerLogContent(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22503,8 +24864,28 @@ func (ec *executionContext) _Query_fetchSystemLogRecords(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FetchSystemLogRecords(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().FetchSystemLogRecords(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.FileInfo); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.FileInfo`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22553,8 +24934,28 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Users(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.User`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22605,8 +25006,28 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().User(rctx, fc.Args["id"].(uint)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx, fc.Args["id"].(uint)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.User`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -22665,8 +25086,28 @@ func (ec *executionContext) _Query_currentUser(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CurrentUser(rctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().CurrentUser(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.User`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -25618,8 +28059,28 @@ func (ec *executionContext) _Subscription_fetchDeploymentLog(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Subscription().FetchDeploymentLog(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().FetchDeploymentLog(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(<-chan *model.DeploymentLog); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be <-chan *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.DeploymentLog`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -25693,8 +28154,28 @@ func (ec *executionContext) _Subscription_fetchRuntimeLog(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Subscription().FetchRuntimeLog(rctx, fc.Args["applicationId"].(string), fc.Args["timeframe"].(model.RuntimeLogTimeframe)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().FetchRuntimeLog(rctx, fc.Args["applicationId"].(string), fc.Args["timeframe"].(model.RuntimeLogTimeframe)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsAuthenticated == nil { + return nil, errors.New("directive isAuthenticated is not implemented") + } + return ec.directives.IsAuthenticated(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(<-chan *model.RuntimeLog); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be <-chan *github.com/swiftwave-org/swiftwave/swiftwave_service/graphql/model.RuntimeLog`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -29314,6 +31795,40 @@ func (ec *executionContext) unmarshalInputStackVariableType(ctx context.Context, return it, nil } +func (ec *executionContext) unmarshalInputUserCredential(ctx context.Context, obj interface{}) (model.UserCredential, error) { + var it model.UserCredential + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"username", "password"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "username": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Username = data + case "password": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Password = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj interface{}) (model.UserInput, error) { var it model.UserInput asMap := map[string]interface{}{} @@ -31758,6 +34273,20 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "login": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_login(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "logout": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_logout(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "cancelDeployment": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_cancelDeployment(ctx, field) @@ -37074,6 +39603,11 @@ func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋswiftwaveᚑorgᚋswi return ec._User(ctx, sel, v) } +func (ec *executionContext) unmarshalNUserCredential2githubᚗcomᚋswiftwaveᚑorgᚋswiftwaveᚋswiftwave_serviceᚋgraphqlᚋmodelᚐUserCredential(ctx context.Context, v interface{}) (model.UserCredential, error) { + res, err := ec.unmarshalInputUserCredential(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } diff --git a/swiftwave_service/graphql/helpers.go b/swiftwave_service/graphql/helpers.go index ffcbc7b0ac..8b501000ed 100644 --- a/swiftwave_service/graphql/helpers.go +++ b/swiftwave_service/graphql/helpers.go @@ -4,6 +4,8 @@ import ( "context" "errors" "fmt" + "github.com/labstack/echo/v4" + swiftwaveMiddleware "github.com/swiftwave-org/swiftwave/swiftwave_service/middleware" "log" "os" "os/user" @@ -178,3 +180,23 @@ func (r *mutationResolver) RunActionsInAllHAProxyNodes(ctx context.Context, db * return nil } } + +func GetEchoContext(ctx context.Context) (echo.Context, error) { + if c, ok := ctx.Value("echoContext").(echo.Context); ok { + return c, nil + } else { + return nil, errors.New("failed to get echo context") + } +} + +func GetAuthInfo(ctx context.Context) swiftwaveMiddleware.AuthInfo { + eCtx, err := GetEchoContext(ctx) + if err != nil { + return swiftwaveMiddleware.AuthInfo{} + } + if m, ok := eCtx.Get("auth").(swiftwaveMiddleware.AuthInfo); ok { + return m + } else { + return swiftwaveMiddleware.AuthInfo{} + } +} diff --git a/swiftwave_service/graphql/model/models_gen.go b/swiftwave_service/graphql/model/models_gen.go index ef774c3044..6a616da9f8 100644 --- a/swiftwave_service/graphql/model/models_gen.go +++ b/swiftwave_service/graphql/model/models_gen.go @@ -653,6 +653,11 @@ type User struct { TotpEnabled bool `json:"totpEnabled"` } +type UserCredential struct { + Username string `json:"username"` + Password string `json:"password"` +} + type UserInput struct { Username string `json:"username"` Password string `json:"password"` diff --git a/swiftwave_service/graphql/schema/app_authentication.graphqls b/swiftwave_service/graphql/schema/app_authentication.graphqls index f371834ce0..05ff85f314 100644 --- a/swiftwave_service/graphql/schema/app_authentication.graphqls +++ b/swiftwave_service/graphql/schema/app_authentication.graphqls @@ -21,13 +21,13 @@ type AppBasicAuthAccessControlUser { } extend type Query { - appBasicAuthAccessControlLists: [AppBasicAuthAccessControlList!]! + appBasicAuthAccessControlLists: [AppBasicAuthAccessControlList!]! @isAuthenticated } extend type Mutation { - createAppBasicAuthAccessControlList(input: AppBasicAuthAccessControlListInput!): AppBasicAuthAccessControlList! - deleteAppBasicAuthAccessControlList(id: Uint!): Boolean! - createAppBasicAuthAccessControlUser(input: AppBasicAuthAccessControlUserInput!): AppBasicAuthAccessControlUser! - updateAppBasicAuthAccessControlUserPassword(id: Uint!, password: String!): Boolean! - deleteAppBasicAuthAccessControlUser(id: Uint!): Boolean! + createAppBasicAuthAccessControlList(input: AppBasicAuthAccessControlListInput!): AppBasicAuthAccessControlList! @isAuthenticated + deleteAppBasicAuthAccessControlList(id: Uint!): Boolean! @isAuthenticated + createAppBasicAuthAccessControlUser(input: AppBasicAuthAccessControlUserInput!): AppBasicAuthAccessControlUser! @isAuthenticated + updateAppBasicAuthAccessControlUserPassword(id: Uint!, password: String!): Boolean! @isAuthenticated + deleteAppBasicAuthAccessControlUser(id: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/application.graphqls b/swiftwave_service/graphql/schema/application.graphqls index 40ecc8778c..e2046f3f8b 100644 --- a/swiftwave_service/graphql/schema/application.graphqls +++ b/swiftwave_service/graphql/schema/application.graphqls @@ -118,20 +118,20 @@ input ApplicationInput { } extend type Query { - application(id: String!): Application! - applications(includeGroupedApplications: Boolean!): [Application!]! - isExistApplicationName(name: String!): Boolean! - applicationResourceAnalytics(id: String!, timeframe: ApplicationResourceAnalyticsTimeframe!): [ApplicationResourceAnalytics!]! + application(id: String!): Application! @isAuthenticated + applications(includeGroupedApplications: Boolean!): [Application!]! @isAuthenticated + isExistApplicationName(name: String!): Boolean! @isAuthenticated + applicationResourceAnalytics(id: String!, timeframe: ApplicationResourceAnalyticsTimeframe!): [ApplicationResourceAnalytics!]! @isAuthenticated } extend type Mutation { - createApplication(input: ApplicationInput!): Application! - updateApplication(id: String!, input: ApplicationInput!): Application! - updateApplicationGroup(id: String!, groupId: String): Boolean! - deleteApplication(id: String!): Boolean! - rebuildApplication(id: String!): Boolean! - restartApplication(id: String!): Boolean! - regenerateWebhookToken(id: String!): String! - sleepApplication(id: String!): Boolean! - wakeApplication(id: String!): Boolean! + createApplication(input: ApplicationInput!): Application! @isAuthenticated + updateApplication(id: String!, input: ApplicationInput!): Application! @isAuthenticated + updateApplicationGroup(id: String!, groupId: String): Boolean! @isAuthenticated + deleteApplication(id: String!): Boolean! @isAuthenticated + rebuildApplication(id: String!): Boolean! @isAuthenticated + restartApplication(id: String!): Boolean! @isAuthenticated + regenerateWebhookToken(id: String!): String! @isAuthenticated + sleepApplication(id: String!): Boolean! @isAuthenticated + wakeApplication(id: String!): Boolean! @isAuthenticated } diff --git a/swiftwave_service/graphql/schema/application_group.graphqls b/swiftwave_service/graphql/schema/application_group.graphqls index e630cba21f..23f1503833 100644 --- a/swiftwave_service/graphql/schema/application_group.graphqls +++ b/swiftwave_service/graphql/schema/application_group.graphqls @@ -10,11 +10,11 @@ input ApplicationGroupInput { } extend type Query { - applicationGroups: [ApplicationGroup!]! - applicationGroup(id: String!): ApplicationGroup! + applicationGroups: [ApplicationGroup!]! @isAuthenticated + applicationGroup(id: String!): ApplicationGroup! @isAuthenticated } extend type Mutation { - createApplicationGroup(input: ApplicationGroupInput!): ApplicationGroup! - deleteApplicationGroup(id: String!): Boolean! + createApplicationGroup(input: ApplicationGroupInput!): ApplicationGroup! @isAuthenticated + deleteApplicationGroup(id: String!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/authentication.graphqls b/swiftwave_service/graphql/schema/authentication.graphqls new file mode 100644 index 0000000000..3c7bcf07e9 --- /dev/null +++ b/swiftwave_service/graphql/schema/authentication.graphqls @@ -0,0 +1,10 @@ +input UserCredential { + username: String! + password: String! +} + + +extend type Mutation { + login(input: UserCredential!): Boolean! + logout: Boolean! +} \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/deployment.graphqls b/swiftwave_service/graphql/schema/deployment.graphqls index c010c8a096..33ed59e159 100644 --- a/swiftwave_service/graphql/schema/deployment.graphqls +++ b/swiftwave_service/graphql/schema/deployment.graphqls @@ -53,9 +53,9 @@ type Deployment { } extend type Query { - deployment(id: String!): Deployment! + deployment(id: String!): Deployment! @isAuthenticated } extend type Mutation { - cancelDeployment(id: String!): Boolean! + cancelDeployment(id: String!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/deployment_log.graphqls b/swiftwave_service/graphql/schema/deployment_log.graphqls index 175d03f200..f5f739b2af 100644 --- a/swiftwave_service/graphql/schema/deployment_log.graphqls +++ b/swiftwave_service/graphql/schema/deployment_log.graphqls @@ -4,5 +4,5 @@ type DeploymentLog { } extend type Subscription { - fetchDeploymentLog(id: String!): DeploymentLog! + fetchDeploymentLog(id: String!): DeploymentLog! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/directive.graphqls b/swiftwave_service/graphql/schema/directive.graphqls new file mode 100644 index 0000000000..9e48614606 --- /dev/null +++ b/swiftwave_service/graphql/schema/directive.graphqls @@ -0,0 +1 @@ +directive @isAuthenticated on FIELD_DEFINITION diff --git a/swiftwave_service/graphql/schema/docker_config_generator.graphqls b/swiftwave_service/graphql/schema/docker_config_generator.graphqls index 8798344761..b0ccb41285 100644 --- a/swiftwave_service/graphql/schema/docker_config_generator.graphqls +++ b/swiftwave_service/graphql/schema/docker_config_generator.graphqls @@ -31,7 +31,7 @@ type DockerConfigGeneratorOutput { } extend type Query { - dockerConfigGenerator(input: DockerConfigGeneratorInput!): DockerConfigGeneratorOutput - availableDockerConfigs: [String!] - dockerConfigFromServiceName(serviceName: String!): DockerConfigGeneratorOutput + dockerConfigGenerator(input: DockerConfigGeneratorInput!): DockerConfigGeneratorOutput @isAuthenticated + availableDockerConfigs: [String!] @isAuthenticated + dockerConfigFromServiceName(serviceName: String!): DockerConfigGeneratorOutput @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/domain.graphqls b/swiftwave_service/graphql/schema/domain.graphqls index 03ec7c7de0..31db9c21dd 100644 --- a/swiftwave_service/graphql/schema/domain.graphqls +++ b/swiftwave_service/graphql/schema/domain.graphqls @@ -35,14 +35,14 @@ type Domain { } extend type Query { - domains: [Domain!]! - domain(id: Uint!): Domain! - verifyDomainConfiguration(name: String!): Boolean! + domains: [Domain!]! @isAuthenticated + domain(id: Uint!): Domain! @isAuthenticated + verifyDomainConfiguration(name: String!): Boolean! @isAuthenticated } extend type Mutation { - addDomain(input: DomainInput!): Domain! - removeDomain(id: Uint!): Boolean! - issueSSL(id: Uint!): Domain! - addCustomSSL(id: Uint!, input: CustomSSLInput!): Domain! + addDomain(input: DomainInput!): Domain! @isAuthenticated + removeDomain(id: Uint!): Boolean! @isAuthenticated + issueSSL(id: Uint!): Domain! @isAuthenticated + addCustomSSL(id: Uint!, input: CustomSSLInput!): Domain! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/git.graphqls b/swiftwave_service/graphql/schema/git.graphqls index a9bc64344f..6ee54f0efb 100644 --- a/swiftwave_service/graphql/schema/git.graphqls +++ b/swiftwave_service/graphql/schema/git.graphqls @@ -4,5 +4,5 @@ input GitBranchesQueryInput { } extend type Query { - gitBranches(input: GitBranchesQueryInput!): [String!]! + gitBranches(input: GitBranchesQueryInput!): [String!]! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/git_credential.graphqls b/swiftwave_service/graphql/schema/git_credential.graphqls index c86f6ade2d..3b771dffef 100644 --- a/swiftwave_service/graphql/schema/git_credential.graphqls +++ b/swiftwave_service/graphql/schema/git_credential.graphqls @@ -22,13 +22,13 @@ input GitCredentialRepositoryAccessInput { extend type Query { - gitCredentials: [GitCredential!]! - gitCredential(id: Uint!): GitCredential! - checkGitCredentialRepositoryAccess(input: GitCredentialRepositoryAccessInput!): Boolean! + gitCredentials: [GitCredential!]! @isAuthenticated + gitCredential(id: Uint!): GitCredential! @isAuthenticated + checkGitCredentialRepositoryAccess(input: GitCredentialRepositoryAccessInput!): Boolean! @isAuthenticated } extend type Mutation { - createGitCredential(input: GitCredentialInput!): GitCredential! - updateGitCredential(id: Uint!, input: GitCredentialInput!): GitCredential! - deleteGitCredential(id: Uint!): Boolean! + createGitCredential(input: GitCredentialInput!): GitCredential! @isAuthenticated + updateGitCredential(id: Uint!, input: GitCredentialInput!): GitCredential! @isAuthenticated + deleteGitCredential(id: Uint!): Boolean! @isAuthenticated } diff --git a/swiftwave_service/graphql/schema/image_registry_credential.graphqls b/swiftwave_service/graphql/schema/image_registry_credential.graphqls index 1a5d013f48..f0404acea8 100644 --- a/swiftwave_service/graphql/schema/image_registry_credential.graphqls +++ b/swiftwave_service/graphql/schema/image_registry_credential.graphqls @@ -13,12 +13,12 @@ input ImageRegistryCredentialInput { } extend type Query { - imageRegistryCredentials: [ImageRegistryCredential!]! - imageRegistryCredential(id: Uint!): ImageRegistryCredential! + imageRegistryCredentials: [ImageRegistryCredential!]! @isAuthenticated + imageRegistryCredential(id: Uint!): ImageRegistryCredential! @isAuthenticated } extend type Mutation { - createImageRegistryCredential(input: ImageRegistryCredentialInput!): ImageRegistryCredential! - updateImageRegistryCredential(id: Uint!, input: ImageRegistryCredentialInput!): ImageRegistryCredential! - deleteImageRegistryCredential(id: Uint!): Boolean! + createImageRegistryCredential(input: ImageRegistryCredentialInput!): ImageRegistryCredential! @isAuthenticated + updateImageRegistryCredential(id: Uint!, input: ImageRegistryCredentialInput!): ImageRegistryCredential! @isAuthenticated + deleteImageRegistryCredential(id: Uint!): Boolean! @isAuthenticated } diff --git a/swiftwave_service/graphql/schema/ingress_rule.graphqls b/swiftwave_service/graphql/schema/ingress_rule.graphqls index d9cbe3ff4e..9fea8a1335 100644 --- a/swiftwave_service/graphql/schema/ingress_rule.graphqls +++ b/swiftwave_service/graphql/schema/ingress_rule.graphqls @@ -52,17 +52,17 @@ type IngressRule { } extend type Query { - ingressRule(id: Uint!): IngressRule! - ingressRules: [IngressRule!]! - isNewIngressRuleValid(input: IngressRuleValidationInput!): Boolean! + ingressRule(id: Uint!): IngressRule! @isAuthenticated + ingressRules: [IngressRule!]! @isAuthenticated + isNewIngressRuleValid(input: IngressRuleValidationInput!): Boolean! @isAuthenticated } extend type Mutation { - createIngressRule(input: IngressRuleInput!): IngressRule! - recreateIngressRule(id: Uint!): Boolean! - enableHttpsRedirectIngressRule(id: Uint!): Boolean! - disableHttpsRedirectIngressRule(id: Uint!): Boolean! - deleteIngressRule(id: Uint!): Boolean! - protectIngressRuleUsingBasicAuth(id: Uint!, appBasicAuthAccessControlListId: Uint!): Boolean! - disableIngressRuleProtection(id: Uint!): Boolean! + createIngressRule(input: IngressRuleInput!): IngressRule! @isAuthenticated + recreateIngressRule(id: Uint!): Boolean! @isAuthenticated + enableHttpsRedirectIngressRule(id: Uint!): Boolean! @isAuthenticated + disableHttpsRedirectIngressRule(id: Uint!): Boolean! @isAuthenticated + deleteIngressRule(id: Uint!): Boolean! @isAuthenticated + protectIngressRuleUsingBasicAuth(id: Uint!, appBasicAuthAccessControlListId: Uint!): Boolean! @isAuthenticated + disableIngressRuleProtection(id: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/persistent_volume.graphqls b/swiftwave_service/graphql/schema/persistent_volume.graphqls index 39695d3021..6d7f2d08f9 100644 --- a/swiftwave_service/graphql/schema/persistent_volume.graphqls +++ b/swiftwave_service/graphql/schema/persistent_volume.graphqls @@ -23,13 +23,13 @@ input PersistentVolumeInput { } extend type Query { - persistentVolumes: [PersistentVolume] - persistentVolume(id: Uint!): PersistentVolume - persistentVolumeSizeMb(id: Uint!): Float! - isExistPersistentVolume(name: String!): Boolean! + persistentVolumes: [PersistentVolume] @isAuthenticated + persistentVolume(id: Uint!): PersistentVolume @isAuthenticated + persistentVolumeSizeMb(id: Uint!): Float! @isAuthenticated + isExistPersistentVolume(name: String!): Boolean! @isAuthenticated } extend type Mutation { - createPersistentVolume(input: PersistentVolumeInput!): PersistentVolume - deletePersistentVolume(id: Uint!): Boolean! + createPersistentVolume(input: PersistentVolumeInput!): PersistentVolume @isAuthenticated + deletePersistentVolume(id: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/persistent_volume_backup.graphqls b/swiftwave_service/graphql/schema/persistent_volume_backup.graphqls index cb50954e74..6fbf80a7ad 100644 --- a/swiftwave_service/graphql/schema/persistent_volume_backup.graphqls +++ b/swiftwave_service/graphql/schema/persistent_volume_backup.graphqls @@ -24,7 +24,7 @@ type PersistentVolumeBackup { } extend type Mutation { - backupPersistentVolume(input: PersistentVolumeBackupInput!): PersistentVolumeBackup - deletePersistentVolumeBackup(id: Uint!): Boolean! - deletePersistentVolumeBackupsByPersistentVolumeId(persistentVolumeId: Uint!): Boolean! + backupPersistentVolume(input: PersistentVolumeBackupInput!): PersistentVolumeBackup @isAuthenticated + deletePersistentVolumeBackup(id: Uint!): Boolean! @isAuthenticated + deletePersistentVolumeBackupsByPersistentVolumeId(persistentVolumeId: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/persistent_volume_restore.graphqls b/swiftwave_service/graphql/schema/persistent_volume_restore.graphqls index 2021de519d..819e5617ff 100644 --- a/swiftwave_service/graphql/schema/persistent_volume_restore.graphqls +++ b/swiftwave_service/graphql/schema/persistent_volume_restore.graphqls @@ -22,6 +22,6 @@ type PersistentVolumeRestore { } extend type Mutation { - deletePersistentVolumeRestore(id: Uint!): Boolean! - deletePersistentVolumeRestoresByPersistentVolumeId(persistentVolumeId: Uint!): Boolean! + deletePersistentVolumeRestore(id: Uint!): Boolean! @isAuthenticated + deletePersistentVolumeRestoresByPersistentVolumeId(persistentVolumeId: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/redirect_rule.graphqls b/swiftwave_service/graphql/schema/redirect_rule.graphqls index a52b75a3d0..d456eb03ce 100644 --- a/swiftwave_service/graphql/schema/redirect_rule.graphqls +++ b/swiftwave_service/graphql/schema/redirect_rule.graphqls @@ -23,11 +23,11 @@ type RedirectRule { } extend type Query { - redirectRule(id: Uint!): RedirectRule! - redirectRules: [RedirectRule!]! + redirectRule(id: Uint!): RedirectRule! @isAuthenticated + redirectRules: [RedirectRule!]! @isAuthenticated } extend type Mutation { - createRedirectRule(input: RedirectRuleInput!): RedirectRule! - deleteRedirectRule(id: Uint!): Boolean! + createRedirectRule(input: RedirectRuleInput!): RedirectRule! @isAuthenticated + deleteRedirectRule(id: Uint!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/runtime_log.graphqls b/swiftwave_service/graphql/schema/runtime_log.graphqls index 5ee35ea083..96324843c7 100644 --- a/swiftwave_service/graphql/schema/runtime_log.graphqls +++ b/swiftwave_service/graphql/schema/runtime_log.graphqls @@ -14,5 +14,5 @@ enum RuntimeLogTimeframe { } extend type Subscription { - fetchRuntimeLog(applicationId: String!, timeframe: RuntimeLogTimeframe!): RuntimeLog! + fetchRuntimeLog(applicationId: String!, timeframe: RuntimeLogTimeframe!): RuntimeLog! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/server.graphqls b/swiftwave_service/graphql/schema/server.graphqls index 33aef4f632..88aee62db2 100644 --- a/swiftwave_service/graphql/schema/server.graphqls +++ b/swiftwave_service/graphql/schema/server.graphqls @@ -91,35 +91,35 @@ type NetworkInterface { } extend type Query { - noOfServers: Int! - noOfPreparedServers: Int! - servers: [Server!] - server(id: Uint!): Server! - publicSSHKey: String! - serverResourceAnalytics(id: Uint!, timeframe: ServerResourceAnalyticsTimeframe!): [ServerResourceAnalytics!]! - serverDiskUsage(id: Uint!): [ServerDisksUsage!]! # return last 1000 records - serverLatestResourceAnalytics(id: Uint!): ServerResourceAnalytics! - serverLatestDiskUsage(id: Uint!): ServerDisksUsage! - networkInterfacesOnServer(id: Uint!): [NetworkInterface!]! + noOfServers: Int! @isAuthenticated + noOfPreparedServers: Int! @isAuthenticated + servers: [Server!] @isAuthenticated + server(id: Uint!): Server! @isAuthenticated + publicSSHKey: String! @isAuthenticated + serverResourceAnalytics(id: Uint!, timeframe: ServerResourceAnalyticsTimeframe!): [ServerResourceAnalytics!]! @isAuthenticated + serverDiskUsage(id: Uint!): [ServerDisksUsage!]! @isAuthenticated # return last 1000 records + serverLatestResourceAnalytics(id: Uint!): ServerResourceAnalytics! @isAuthenticated + serverLatestDiskUsage(id: Uint!): ServerDisksUsage! @isAuthenticated + networkInterfacesOnServer(id: Uint!): [NetworkInterface!]! @isAuthenticated } extend type Mutation { - createServer(input: NewServerInput!): Server! - deleteServer(id: Uint!): Boolean! - testSSHAccessToServer(id: Uint!): Boolean! - checkDependenciesOnServer(id: Uint!): [Dependency!] - installDependenciesOnServer(id: Uint!): Boolean! - setupServer(input: ServerSetupInput!): Boolean! - promoteServerToManager(id: Uint!): Boolean! - demoteServerToWorker(id: Uint!): Boolean! - restrictDeploymentOnServer(id: Uint!): Boolean! - allowDeploymentOnServer(id: Uint!): Boolean! - putServerInMaintenanceMode(id: Uint!): Boolean! - putServerOutOfMaintenanceMode(id: Uint!): Boolean! - removeServerFromSwarmCluster(id: Uint!): Boolean! - enableProxyOnServer(id: Uint!, type: ProxyType!): Boolean! - disableProxyOnServer(id: Uint!): Boolean! - fetchAnalyticsServiceToken(id: Uint!, rotate:Boolean!): String! - changeServerIpAddress(id: Uint!, ip: String!): Boolean! - changeServerSSHPort(id: Uint!, port: Int!): Boolean! + createServer(input: NewServerInput!): Server! @isAuthenticated + deleteServer(id: Uint!): Boolean! @isAuthenticated + testSSHAccessToServer(id: Uint!): Boolean! @isAuthenticated + checkDependenciesOnServer(id: Uint!): [Dependency!] @isAuthenticated + installDependenciesOnServer(id: Uint!): Boolean! @isAuthenticated + setupServer(input: ServerSetupInput!): Boolean! @isAuthenticated + promoteServerToManager(id: Uint!): Boolean! @isAuthenticated + demoteServerToWorker(id: Uint!): Boolean! @isAuthenticated + restrictDeploymentOnServer(id: Uint!): Boolean! @isAuthenticated + allowDeploymentOnServer(id: Uint!): Boolean! @isAuthenticated + putServerInMaintenanceMode(id: Uint!): Boolean! @isAuthenticated + putServerOutOfMaintenanceMode(id: Uint!): Boolean! @isAuthenticated + removeServerFromSwarmCluster(id: Uint!): Boolean! @isAuthenticated + enableProxyOnServer(id: Uint!, type: ProxyType!): Boolean! @isAuthenticated + disableProxyOnServer(id: Uint!): Boolean! @isAuthenticated + fetchAnalyticsServiceToken(id: Uint!, rotate:Boolean!): String! @isAuthenticated + changeServerIpAddress(id: Uint!, ip: String!): Boolean! @isAuthenticated + changeServerSSHPort(id: Uint!, port: Int!): Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/server_log.graphqls b/swiftwave_service/graphql/schema/server_log.graphqls index 81fc464785..d8d4899a0f 100644 --- a/swiftwave_service/graphql/schema/server_log.graphqls +++ b/swiftwave_service/graphql/schema/server_log.graphqls @@ -6,5 +6,5 @@ type ServerLog { } extend type Query { - fetchServerLogContent(id: Uint!): String! + fetchServerLogContent(id: Uint!): String! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/stack.graphqls b/swiftwave_service/graphql/schema/stack.graphqls index 8ffccb00f6..8b7a361946 100644 --- a/swiftwave_service/graphql/schema/stack.graphqls +++ b/swiftwave_service/graphql/schema/stack.graphqls @@ -27,7 +27,7 @@ type ApplicationDeployResult { } extend type Mutation { - cleanupStack(input: StackInput!): String! - verifyStack(input: StackInput!): StackVerifyResult! - deployStack(input: StackInput!): [ApplicationDeployResult!]! + cleanupStack(input: StackInput!): String! @isAuthenticated + verifyStack(input: StackInput!): StackVerifyResult! @isAuthenticated + deployStack(input: StackInput!): [ApplicationDeployResult!]! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/system.graphqls b/swiftwave_service/graphql/schema/system.graphqls index 7e33c1e9e1..19055b49d6 100644 --- a/swiftwave_service/graphql/schema/system.graphqls +++ b/swiftwave_service/graphql/schema/system.graphqls @@ -1,3 +1,3 @@ extend type Mutation { - restartSystem: Boolean! + restartSystem: Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/system_log.graphqls b/swiftwave_service/graphql/schema/system_log.graphqls index 68faccb4fd..3022c680da 100644 --- a/swiftwave_service/graphql/schema/system_log.graphqls +++ b/swiftwave_service/graphql/schema/system_log.graphqls @@ -4,5 +4,5 @@ type FileInfo { } extend type Query { - fetchSystemLogRecords: [FileInfo]! + fetchSystemLogRecords: [FileInfo]! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/totp.graphqls b/swiftwave_service/graphql/schema/totp.graphqls index 9ff812e87b..034ca882b8 100644 --- a/swiftwave_service/graphql/schema/totp.graphqls +++ b/swiftwave_service/graphql/schema/totp.graphqls @@ -4,7 +4,7 @@ type RequestTotpEnable { } extend type Mutation { - requestTotpEnable: RequestTotpEnable! - enableTotp(totp: String!): Boolean! - disableTotp: Boolean! + requestTotpEnable: RequestTotpEnable! @isAuthenticated + enableTotp(totp: String!): Boolean! @isAuthenticated + disableTotp: Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/schema/user.graphqls.graphqls b/swiftwave_service/graphql/schema/user.graphqls.graphqls index 2218674851..f729a3bc29 100644 --- a/swiftwave_service/graphql/schema/user.graphqls.graphqls +++ b/swiftwave_service/graphql/schema/user.graphqls.graphqls @@ -15,13 +15,13 @@ input PasswordUpdateInput { } extend type Query { - users : [User]! - user(id: Uint!) : User - currentUser : User! + users : [User]! @isAuthenticated + user(id: Uint!) : User @isAuthenticated + currentUser : User! @isAuthenticated } extend type Mutation { - createUser(input: UserInput): User - deleteUser(id: Uint!) : Boolean! - changePassword(input: PasswordUpdateInput) : Boolean! + createUser(input: UserInput): User @isAuthenticated + deleteUser(id: Uint!) : Boolean! @isAuthenticated + changePassword(input: PasswordUpdateInput) : Boolean! @isAuthenticated } \ No newline at end of file diff --git a/swiftwave_service/graphql/server.go b/swiftwave_service/graphql/server.go index e797d1b129..5dd7fadda8 100644 --- a/swiftwave_service/graphql/server.go +++ b/swiftwave_service/graphql/server.go @@ -2,91 +2,99 @@ package graphql import ( "context" - "errors" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" - "github.com/golang-jwt/jwt/v5" - "github.com/gorilla/websocket" "github.com/labstack/echo/v4" - "net/http" - "strings" - "time" + "github.com/pkg/errors" ) func (server *Server) Initialize() { + c := Config{Resolvers: &Resolver{ + Config: *server.Config, + ServiceManager: *server.ServiceManager, + WorkerManager: *server.WorkerManager, + }} + c.Directives.IsAuthenticated = func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { + info := GetAuthInfo(ctx) + if info.IsAuthorized() { + return next(ctx) + } + return nil, errors.New("unauthenticated") + } graphqlHandler := handler.New( - NewExecutableSchema( - Config{Resolvers: &Resolver{ - Config: *server.Config, - ServiceManager: *server.ServiceManager, - WorkerManager: *server.WorkerManager, - }}, - ), + NewExecutableSchema(c), ) graphqlHandler.AddTransport(transport.POST{}) - graphqlHandler.AddTransport(&transport.Websocket{ - KeepAlivePingInterval: 10 * time.Second, - Upgrader: websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { - return true - }, - }, - // Authentication middleware for websocket connections - InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { - jwtToken := strings.ReplaceAll(strings.ReplaceAll(initPayload.Authorization(), "Bearer ", ""), "bearer", "") - if jwtToken == "" { - return ctx, nil, errors.New("missing jwt token") - } - //nolint:staticcheck - ctx = context.WithValue(ctx, "jwt_data", jwtToken) - // decode jwt token - token, err := jwt.Parse(jwtToken, func(token *jwt.Token) (interface{}, error) { - return []byte(server.Config.SystemConfig.JWTSecretKey), nil - }) - if err != nil { - return ctx, nil, errors.New("invalid jwt token") - } - if !token.Valid { - return ctx, nil, errors.New("invalid jwt token") - } - claims := token.Claims.(jwt.MapClaims) - // check if username is present - if _, ok := claims["username"]; !ok { - return ctx, nil, errors.New("malformed jwt token") - } - // Data in context is available in all resolvers - username := claims["username"].(string) - //nolint:staticcheck - ctx = context.WithValue(ctx, "authorized", true) - //nolint:staticcheck - ctx = context.WithValue(ctx, "username", username) - return ctx, nil, nil - }, - }) + //graphqlHandler.AddTransport(&transport.Websocket{ + // KeepAlivePingInterval: 10 * time.Second, + // Upgrader: websocket.Upgrader{ + // CheckOrigin: func(r *http.Request) bool { + // return true + // }, + // }, + // // Authentication middleware for websocket connections + // InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + // jwtToken := strings.ReplaceAll(strings.ReplaceAll(initPayload.Authorization(), "Bearer ", ""), "bearer", "") + // if jwtToken == "" { + // return ctx, nil, errors.New("missing jwt token") + // } + // //nolint:staticcheck + // ctx = context.WithValue(ctx, "jwt_data", jwtToken) + // // decode jwt token + // token, err := jwt.Parse(jwtToken, func(token *jwt.Token) (interface{}, error) { + // return []byte(server.Config.SystemConfig.JWTSecretKey), nil + // }) + // if err != nil { + // return ctx, nil, errors.New("invalid jwt token") + // } + // if !token.Valid { + // return ctx, nil, errors.New("invalid jwt token") + // } + // claims := token.Claims.(jwt.MapClaims) + // // check if username is present + // if _, ok := claims["username"]; !ok { + // return ctx, nil, errors.New("malformed jwt token") + // } + // // Data in context is available in all resolvers + // username := claims["username"].(string) + // //nolint:staticcheck + // ctx = context.WithValue(ctx, "authorized", true) + // //nolint:staticcheck + // ctx = context.WithValue(ctx, "username", username) + // return ctx, nil, nil + // }, + //}) - if server.Config.LocalConfig.IsDevelopmentMode { - graphqlHandler.Use(extension.Introspection{}) - } + graphqlHandler.Use(extension.Introspection{}) server.EchoServer.GET("/graphql", func(c echo.Context) error { - graphqlHandler.ServeHTTP(c.Response(), c.Request()) + // Inject context + req := c.Request() + ctx := context.WithValue(req.Context(), "echoContext", c) + req = req.WithContext(ctx) + // Serve + graphqlHandler.ServeHTTP(c.Response(), req) return nil }) server.EchoServer.POST("/graphql", func(c echo.Context) error { - graphqlHandler.ServeHTTP(c.Response(), c.Request()) + // Inject context + req := c.Request() + ctx := context.WithValue(req.Context(), "echoContext", c) + req = req.WithContext(ctx) + // Serve + graphqlHandler.ServeHTTP(c.Response(), req) return nil }) - if server.Config.LocalConfig.IsDevelopmentMode { - // Create GraphQL Playground - playgroundHandler := playground.Handler("GraphQL", "/graphql") - server.EchoServer.GET("/playground", func(c echo.Context) error { - playgroundHandler.ServeHTTP(c.Response(), c.Request()) - return nil - }) - } + // Create GraphQL Playground + playgroundHandler := playground.Handler("GraphQL", "/graphql") + server.EchoServer.GET("/playground", func(c echo.Context) error { + playgroundHandler.ServeHTTP(c.Response(), c.Request()) + return nil + }) } diff --git a/swiftwave_service/graphql/user.graphqls.resolvers.go b/swiftwave_service/graphql/user.graphqls.resolvers.go index 9fb5a19fe8..de19813074 100644 --- a/swiftwave_service/graphql/user.graphqls.resolvers.go +++ b/swiftwave_service/graphql/user.graphqls.resolvers.go @@ -103,8 +103,7 @@ func (r *queryResolver) User(ctx context.Context, id uint) (*model.User, error) // CurrentUser is the resolver for the currentUser field. func (r *queryResolver) CurrentUser(ctx context.Context) (*model.User, error) { - username := ctx.Value("username").(string) - user, err := core.FindUserByUsername(ctx, r.ServiceManager.DbClient, username) + user, err := GetAuthInfo(ctx).GetUser() if err != nil { return nil, err } diff --git a/swiftwave_service/main.go b/swiftwave_service/main.go index a7e85b80b0..60fc21442f 100644 --- a/swiftwave_service/main.go +++ b/swiftwave_service/main.go @@ -1,28 +1,22 @@ package swiftwave import ( - "context" "fmt" - "log" - "net/http" - "strings" - "github.com/fatih/color" - "github.com/golang-jwt/jwt/v5" - echojwt "github.com/labstack/echo-jwt/v4" "github.com/swiftwave-org/swiftwave/pkg/ssh_toolkit" "github.com/swiftwave-org/swiftwave/swiftwave_service/config" - "github.com/swiftwave-org/swiftwave/swiftwave_service/console" "github.com/swiftwave-org/swiftwave/swiftwave_service/core" "github.com/swiftwave-org/swiftwave/swiftwave_service/dashboard" "github.com/swiftwave-org/swiftwave/swiftwave_service/logger" + custom_middleware "github.com/swiftwave-org/swiftwave/swiftwave_service/middleware" "github.com/swiftwave-org/swiftwave/swiftwave_service/service_manager" + "log" + "net/http" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/swiftwave-org/swiftwave/swiftwave_service/cronjob" "github.com/swiftwave-org/swiftwave/swiftwave_service/graphql" - "github.com/swiftwave-org/swiftwave/swiftwave_service/rest" "github.com/swiftwave-org/swiftwave/swiftwave_service/worker" ) @@ -99,178 +93,19 @@ func StartServer(config *config.Config, manager *service_manager.ServiceManager, Format: "${method} ${uri} | ${remote_ip} | ${status} ${error}\n", })) echoServer.Use(middleware.CORS()) + echoServer.Use(custom_middleware.CacheMiddleware()) + echoServer.Use(custom_middleware.AuthResolverMiddleware(&manager.DbClient)) - // Cache middleware - // Cache JS, CSS and PNG files for 1 year, as if static content changes, the uri also changes - // So setting cache-control header to max-age to 1 year - // + it will also set etag header to the file name - echoServer.Use(func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if strings.HasSuffix(c.Request().RequestURI, ".js") || strings.HasSuffix(c.Request().RequestURI, ".css") || strings.HasSuffix(c.Request().RequestURI, ".png") || strings.HasSuffix(c.Request().RequestURI, ".ttf") { - s := strings.Split(c.Request().RequestURI, "/") - etag := s[len(s)-1] - c.Response().Header().Set("Etag", etag) - c.Response().Header().Set("Cache-Control", "max-age=31536000") - if match := c.Request().Header.Get("If-None-Match"); match != "" { - if strings.Contains(match, etag) { - return c.NoContent(http.StatusNotModified) - } - } - } - return next(c) - } - }) - - // Internal Service Authentication Middleware - // Authorization : analytics_token : - // Only for /service/analytics endpoints - echoServer.Use(func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if strings.Compare(c.Request().URL.Path, "/service/analytics") == 0 { - authorization := c.Request().Header.Get("Authorization") - if strings.HasPrefix(authorization, "analytics_token ") { - token := strings.TrimPrefix(authorization, "analytics_token ") - tokenParts := strings.Split(token, ":") - if len(tokenParts) == 2 { - verified, serverHostName, err := core.ValidateAnalyticsServiceToken(c.Request().Context(), manager.DbClient, tokenParts[0], tokenParts[1]) - if err != nil { - return c.JSON(http.StatusUnauthorized, map[string]interface{}{ - "message": "invalid service token", - }) - } - if verified { - c.Set("authorized", true) - c.Set("hostname", serverHostName) - } else { - return c.JSON(http.StatusUnauthorized, map[string]interface{}{ - "message": "invalid service token", - }) - } - } - } else { - c.Set("authorized", false) - c.Set("hostname", "") - } - } - return next(c) - } - }) - - // JWT Middleware - echoServer.Use(echojwt.WithConfig(echojwt.Config{ - Skipper: func(c echo.Context) bool { - // check if request is already authorized - if strings.HasPrefix(c.Request().URL.Path, "/service/analytics") && - c.Get("authorized") != nil && c.Get("hostname") != nil { - if c.Get("authorized").(bool) && strings.Compare(c.Get("hostname").(string), "") != 0 { - return true - } - } - if strings.Compare(c.Request().URL.Path, "/") == 0 || - strings.HasPrefix(c.Request().URL.Path, "/healthcheck") || - strings.HasPrefix(c.Request().URL.Path, "/.well-known") || - strings.HasPrefix(c.Request().URL.Path, "/auth") || - strings.HasPrefix(c.Request().URL.Path, "/webhook") || - strings.HasPrefix(c.Request().URL.Path, "/dashboard") || - strings.HasPrefix(c.Request().URL.Path, "/playground") { - return true - } - // check if a GET request at /graphql and a websocket upgrade request - if strings.HasPrefix(c.Request().URL.Path, "/graphql") && - strings.Compare(c.Request().Method, http.MethodGet) == 0 && - strings.Compare(c.Request().URL.RawQuery, "") == 0 && - strings.Contains(strings.ToLower(c.Request().Header.Get("Connection")), "upgrade") && - strings.Compare(strings.ToLower(c.Request().Header.Get("Upgrade")), "websocket") == 0 { - return true - } - - // on console websocket connection allow without jwt, as auth will be handled by the console server - if strings.HasPrefix(c.Request().URL.Path, "/console/ws") && - strings.Compare(c.Request().Method, http.MethodGet) == 0 && - strings.Compare(c.Request().URL.RawQuery, "") == 0 && - strings.Contains(strings.ToLower(c.Request().Header.Get("Connection")), "upgrade") && - strings.Compare(strings.ToLower(c.Request().Header.Get("Upgrade")), "websocket") == 0 { - return true - } - - // Whitelist console's HTML, JS, CSS - if (strings.Compare(c.Request().URL.Path, "/console") == 0 || - strings.Compare(c.Request().URL.Path, "/console/main.js") == 0 || - strings.Compare(c.Request().URL.Path, "/console/xterm.js") == 0 || - strings.Compare(c.Request().URL.Path, "/console/xterm-addon-fit.js") == 0 || - strings.Compare(c.Request().URL.Path, "/console/xterm.css") == 0) && - strings.Compare(c.Request().Method, http.MethodGet) == 0 { - return true - } - - return false - }, - SigningKey: []byte(config.SystemConfig.JWTSecretKey), - ContextKey: "jwt_data", - })) + // Handle dashboard + dashboard.RegisterHandlers(echoServer, false) - // Add `authorized` & `username` key to the context - echoServer.Use(func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - // ignore if already authorized - if c.Get("authorized") != nil && c.Get("hostname") != nil { - if c.Get("authorized").(bool) && strings.Compare(c.Get("hostname").(string), "") != 0 { - return next(c) - } - } - token, ok := c.Get("jwt_data").(*jwt.Token) - ctx := c.Request().Context() - if !ok { - c.Set("authorized", false) - c.Set("username", "") - c.Set("hostname", "") - //nolint:staticcheck - ctx = context.WithValue(ctx, "authorized", false) - //nolint:staticcheck - ctx = context.WithValue(ctx, "username", "") - } else { - claims := token.Claims.(jwt.MapClaims) - username := claims["username"].(string) - c.Set("authorized", true) - c.Set("username", username) - c.Set("hostname", "") - //nolint:staticcheck - ctx = context.WithValue(ctx, "authorized", true) - //nolint:staticcheck - ctx = context.WithValue(ctx, "username", username) - } - c.SetRequest(c.Request().WithContext(ctx)) - return next(c) - } - }) - // Create Rest Server - restServer := rest.Server{ - EchoServer: echoServer, - Config: config, - ServiceManager: manager, - WorkerManager: workerManager, - } - // Create Console Server (Server + Deployed Applications Remote Shell) - consoleServer := console.Server{ - EchoServer: echoServer, - Config: config, - ServiceManager: manager, - WorkerManager: workerManager, - } - // Create GraphQL Server + // GQL Server graphqlServer := graphql.Server{ EchoServer: echoServer, Config: config, ServiceManager: manager, WorkerManager: workerManager, } - // Initialize Dashboard Web App - dashboard.RegisterHandlers(echoServer, false) - // Initialize Rest Server - restServer.Initialize() - // Initialize Console Server - consoleServer.Initialize() - // Initialize GraphQL Server graphqlServer.Initialize() // Start the server diff --git a/swiftwave_service/middleware/auth.go b/swiftwave_service/middleware/auth.go new file mode 100644 index 0000000000..7e79ae2a5e --- /dev/null +++ b/swiftwave_service/middleware/auth.go @@ -0,0 +1,88 @@ +package middleware + +import ( + "context" + "errors" + "github.com/labstack/echo/v4" + "github.com/swiftwave-org/swiftwave/swiftwave_service/core" + "gorm.io/gorm" + "strings" +) + +type AuthInfo struct { + authorized bool + userID uint + context context.Context + db *gorm.DB + sessionID string +} + +func (a AuthInfo) IsAuthorized() bool { + return a.authorized +} + +func (a AuthInfo) GetUserID() uint { + return a.userID +} + +func (a AuthInfo) GetSessionID() string { + return a.sessionID +} + +func (a AuthInfo) GetUser() (core.User, error) { + if !a.authorized || a.userID == 0 || a.db == nil { + return core.User{}, errors.New("unauthorized") + } + user, err := core.FindUserByID(a.context, *a.db, a.userID) + if err != nil { + return core.User{}, errors.New("user not found") + } + return user, nil +} + +// AuthResolverMiddleware will add reference of auth info +// It will allow unauthenticated access as well +// Handler should verify requests +func AuthResolverMiddleware(dbClient *gorm.DB) func(next echo.HandlerFunc) echo.HandlerFunc { + return func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + if strings.Compare(c.Request().URL.Path, "/") == 0 || + strings.HasPrefix(c.Request().URL.Path, "/healthcheck") || + strings.HasPrefix(c.Request().URL.Path, "/.well-known") || + strings.HasPrefix(c.Request().URL.Path, "/webhook") || + strings.HasPrefix(c.Request().URL.Path, "/dashboard") || + strings.HasPrefix(c.Request().URL.Path, "/playground") { + return next(c) + } + + ctx := c.Request().Context() + + // Authenticate request + sessionId, err := c.Cookie("session_id") + isLoggedIn := false + if err == nil { + userId, err := core.FetchUserIDBySessionID(ctx, *dbClient, sessionId.Value) + if err == nil { + c.Set("auth", AuthInfo{ + authorized: true, + userID: userId, + context: ctx, + db: dbClient, + sessionID: sessionId.Value, + }) + isLoggedIn = true + } + } + if !isLoggedIn { + c.Set("auth", AuthInfo{ + authorized: false, + userID: 0, + context: ctx, + db: dbClient, + sessionID: "", + }) + } + return next(c) + } + } +} diff --git a/swiftwave_service/middleware/cache.go b/swiftwave_service/middleware/cache.go new file mode 100644 index 0000000000..279345bb85 --- /dev/null +++ b/swiftwave_service/middleware/cache.go @@ -0,0 +1,30 @@ +package middleware + +import ( + "github.com/labstack/echo/v4" + "net/http" + "strings" +) + +// CacheMiddleware > Cache middleware +// Cache JS, CSS and PNG files for 1 year, as if static content changes, the uri also changes +// So setting cache-control header to max-age to 1 year +// + it will also set etag header to the file name +func CacheMiddleware() func(next echo.HandlerFunc) echo.HandlerFunc { + return func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + if strings.HasSuffix(c.Request().RequestURI, ".js") || strings.HasSuffix(c.Request().RequestURI, ".css") || strings.HasSuffix(c.Request().RequestURI, ".png") || strings.HasSuffix(c.Request().RequestURI, ".ttf") { + s := strings.Split(c.Request().RequestURI, "/") + etag := s[len(s)-1] + c.Response().Header().Set("Etag", etag) + c.Response().Header().Set("Cache-Control", "max-age=31536000") + if match := c.Request().Header.Get("If-None-Match"); match != "" { + if strings.Contains(match, etag) { + return c.NoContent(http.StatusNotModified) + } + } + } + return next(c) + } + } +} diff --git a/swiftwave_service/rest/analytics.go b/swiftwave_service/rest/analytics.go deleted file mode 100644 index 8f8ef59db5..0000000000 --- a/swiftwave_service/rest/analytics.go +++ /dev/null @@ -1,138 +0,0 @@ -package rest - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/core" - "github.com/swiftwave-org/swiftwave/swiftwave_service/logger" - "io" - "log" - "net/http" - "time" -) - -// POST /service/analytics -func (server *Server) analytics(c echo.Context) error { - if c.Get("hostname") == nil { - return c.String(http.StatusBadRequest, "invalid request") - } - // fetch hostname from context - serverHostName := c.Get("hostname").(string) - // parse request body - var buf bytes.Buffer - // Copy the response body to the buffer - _, err := io.Copy(&buf, c.Request().Body) - if err != nil { - logger.HTTPLogger.Println("Error reading response body:", err.Error()) - return c.String(http.StatusBadRequest, "invalid request") - } - var data ResourceStatsData - requestBytes := buf.Bytes() - if err := json.Unmarshal(requestBytes, &data); err != nil { - fmt.Println(err.Error()) - return c.String(http.StatusBadRequest, "invalid request") - } - // create a transaction - tx := server.ServiceManager.DbClient.Begin() - defer func() { - tx.Rollback() - }() - - // fetch server id from database - serverId, err := core.FetchServerIDByHostName(tx, serverHostName) - if err != nil { - logger.HTTPLogger.Println(err.Error()) - return c.String(http.StatusInternalServerError, "failed to fetch server id") - } - // create new host resource stat - diskStats := make([]core.ServerDiskStat, len(data.SystemStat.DiskStats)) - for i, diskStat := range data.SystemStat.DiskStats { - diskStats[i] = core.ServerDiskStat{ - Path: diskStat.Path, - MountPoint: diskStat.MountPoint, - TotalGB: diskStat.TotalGB, - UsedGB: diskStat.UsedGB, - } - } - - recvKB := data.SystemStat.NetStat.RecvKB - sentKB := data.SystemStat.NetStat.SentKB - - /* - Little hack - - sometimes wrong data can be reported, due to overflow issues - 10000000000000000KB = 10000000000GB - - We are assuming that in 1 minute a server can't have 10000000000GB of data transfer in Tx/Rx. - So if something reported, ignore that data. - */ - - if recvKB > 10000000000000000 || sentKB > 10000000000000000 { - logger.HTTPLoggerError.Println("Ignoring data, because anomaly detected in net stats") - logger.HTTPLoggerError.Println(string(requestBytes)) - return c.String(http.StatusBadRequest, "invalid request") - } - - serverStat := core.ServerResourceStat{ - ServerID: serverId, - CpuUsagePercent: data.SystemStat.CpuUsagePercent, - MemStat: core.ServerMemoryStat{ - TotalGB: data.SystemStat.MemStat.TotalGB, - UsedGB: data.SystemStat.MemStat.UsedGB, - CachedGB: data.SystemStat.MemStat.CachedGB, - }, - DiskStats: diskStats, - NetStat: core.ServerNetStat{ - RecvKB: data.SystemStat.NetStat.RecvKB, - SentKB: data.SystemStat.NetStat.SentKB, - RecvKBPS: data.SystemStat.NetStat.RecvKB / 60, - SentKBPS: data.SystemStat.NetStat.SentKB / 60, - }, - RecordedAt: time.Unix(int64(data.TimeStamp), 0), - } - err = serverStat.Create(c.Request().Context(), *tx) - if err != nil { - log.Println(err.Error()) - return c.String(http.StatusInternalServerError, "failed to create server resource stat") - } - - // create application resource stat - appStats := make([]*core.ApplicationServiceResourceStat, 0) - for serviceName, serviceStat := range data.ServiceStats { - application := core.Application{} - err := application.FindByName(c.Request().Context(), *tx, serviceName) - if err != nil { - continue - } - cpuUsagePercent := uint64(0) - if serviceStat.SystemCpuTime > 0 { - cpuUsagePercent = uint64(float64(serviceStat.ServiceCpuTime) / float64(serviceStat.SystemCpuTime) * 100) - } - appStats = append(appStats, &core.ApplicationServiceResourceStat{ - ApplicationID: application.ID, - ServiceCpuTime: serviceStat.ServiceCpuTime, - SystemCpuTime: serviceStat.SystemCpuTime, - CpuUsagePercent: uint8(cpuUsagePercent), - ReportingServerCount: 1, - UsedMemoryMB: serviceStat.UsedMemoryMB, - NetStat: core.ApplicationServiceNetStat{ - RecvKB: serviceStat.NetStat.RecvKB, - SentKB: serviceStat.NetStat.SentKB, - RecvKBPS: serviceStat.NetStat.RecvKB / 60, - SentKBPS: serviceStat.NetStat.SentKB / 60, - }, - RecordedAt: time.Unix(int64(data.TimeStamp), 0), - }) - } - // create application resource stat - err = core.CreateApplicationServiceResourceStat(c.Request().Context(), *tx, appStats) - if err != nil { - log.Println(err.Error()) - return c.String(http.StatusInternalServerError, "failed to create application resource stat") - } - // commit transaction - tx.Commit() - return c.String(200, "ok") -} diff --git a/swiftwave_service/rest/auth.go b/swiftwave_service/rest/auth.go deleted file mode 100644 index 383db33453..0000000000 --- a/swiftwave_service/rest/auth.go +++ /dev/null @@ -1,75 +0,0 @@ -package rest - -import ( - "strings" - "time" - - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/core" - "github.com/xlzd/gotp" -) - -// POST /auth/login -func (server *Server) login(c echo.Context) error { - // Get params - username := c.FormValue("username") - password := c.FormValue("password") - totp := c.FormValue("totp") - - // Check if user exists - user, err := core.FindUserByUsername(c.Request().Context(), server.ServiceManager.DbClient, username) - if err != nil { - return c.JSON(400, &LoginResponse{ - Message: "user does not exist", - Token: "", - TotpRequired: false, - }) - } - - // check if totp is enabled - if user.TotpEnabled && strings.Compare(totp, "") == 0 { - return c.JSON(400, &LoginResponse{ - Message: "two factor authentication is enabled, but totp is not provided", - Token: "", - TotpRequired: true, - }) - } - - // Check password - if !user.CheckPassword(password) { - return c.JSON(400, &LoginResponse{ - Message: "invalid password", - Token: "", - TotpRequired: false, - }) - } - - // Check totp - if user.TotpEnabled { - totpRecord := gotp.NewDefaultTOTP(user.TotpSecret) - if !totpRecord.Verify(totp, time.Now().Unix()) { - return c.JSON(400, &LoginResponse{ - Message: "invalid totp", - Token: "", - TotpRequired: false, - }) - } - } - - // Generate jwt token - token, err := user.GenerateJWT(server.Config.SystemConfig.JWTSecretKey) - if err != nil { - return c.JSON(500, &LoginResponse{ - Message: "failed to generate jwt token", - Token: "", - TotpRequired: false, - }) - } - - // Return token - return c.JSON(200, &LoginResponse{ - Message: "success", - Token: token, - TotpRequired: false, - }) -} diff --git a/swiftwave_service/rest/auth_check.go b/swiftwave_service/rest/auth_check.go deleted file mode 100644 index 5edc253699..0000000000 --- a/swiftwave_service/rest/auth_check.go +++ /dev/null @@ -1,8 +0,0 @@ -package rest - -import "github.com/labstack/echo/v4" - -// GET /verify-auth -func (server *Server) verifyAuth(c echo.Context) error { - return c.String(200, "OK") -} diff --git a/swiftwave_service/rest/healthcheck.go b/swiftwave_service/rest/healthcheck.go deleted file mode 100644 index 37c936ee62..0000000000 --- a/swiftwave_service/rest/healthcheck.go +++ /dev/null @@ -1,8 +0,0 @@ -package rest - -import "github.com/labstack/echo/v4" - -// GET /healthcheck -func (server *Server) healthcheck(c echo.Context) error { - return c.String(200, "OK") -} diff --git a/swiftwave_service/rest/helpers.go b/swiftwave_service/rest/helpers.go deleted file mode 100644 index 83e3a7d5e2..0000000000 --- a/swiftwave_service/rest/helpers.go +++ /dev/null @@ -1,5 +0,0 @@ -package rest - -// Migrate database table -func (server *Server) MigrateDatabaseTables() { -} diff --git a/swiftwave_service/rest/log.go b/swiftwave_service/rest/log.go deleted file mode 100644 index 832a8beb65..0000000000 --- a/swiftwave_service/rest/log.go +++ /dev/null @@ -1,24 +0,0 @@ -package rest - -import ( - "github.com/labstack/echo/v4" - "os" - "path/filepath" -) - -// GET /log/ -func (server *Server) fetchLog(c echo.Context) error { - logFileName := c.Param("log_file_name") - // clean the log file name - logFileName = filepath.Clean(logFileName) - path := filepath.Join(server.Config.LocalConfig.ServiceConfig.LogDirectoryPath, logFileName) - // Check if the log file exists - _, err := os.Stat(path) - if os.IsNotExist(err) { - return c.String(404, "log file does not exist") - } - // Read and pipe the log file - c.Response().Header().Set("Content-Type", "text/plain") - c.Response().Header().Set("Content-Disposition", "attachment; filename="+logFileName) - return c.File(path) -} diff --git a/swiftwave_service/rest/persistent_volume.go b/swiftwave_service/rest/persistent_volume.go deleted file mode 100644 index 1940f8bde3..0000000000 --- a/swiftwave_service/rest/persistent_volume.go +++ /dev/null @@ -1,219 +0,0 @@ -package rest - -import ( - "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/s3" - "github.com/google/uuid" - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/core" - "github.com/swiftwave-org/swiftwave/swiftwave_service/uploader" - "io" - "log" - "mime/multipart" - "os" - "path/filepath" - "strconv" - "strings" - "time" -) - -// GET /persistent-volume/backup/:id/download -func (server *Server) downloadPersistentVolumeBackup(c echo.Context) error { - idStr := c.Param("id") - // convert id to uint - id, err := strconv.Atoi(idStr) - if err != nil { - return c.String(400, "Invalid id") - } - // fetch persistent volume backup - var persistentVolumeBackup core.PersistentVolumeBackup - err = persistentVolumeBackup.FindById(c.Request().Context(), server.ServiceManager.DbClient, uint(id)) - if err != nil { - return c.String(500, "Internal server error") - } - // check status should be success - if persistentVolumeBackup.Status != core.BackupSuccess { - return c.String(400, "Sorry, backup is not available for download") - } - if persistentVolumeBackup.Type == core.LocalBackup { - // send file - filePath := filepath.Join(server.Config.LocalConfig.ServiceConfig.PVBackupDirectoryPath, persistentVolumeBackup.File) - // file name - fileName := persistentVolumeBackup.File - c.Request().Header.Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName)) - return c.Attachment(filePath, fileName) - } else if persistentVolumeBackup.Type == core.S3Backup { - s3config := server.Config.SystemConfig.PersistentVolumeBackupConfig.S3BackupConfig - if !s3config.Enabled { - return c.String(400, "S3 backup is not enabled") - } - // download file from s3 - s3Client, err := uploader.GenerateS3Client(s3config) - if err != nil { - return c.String(500, "Internal server error") - } - // download file - resp, err := s3Client.GetObject(&s3.GetObjectInput{ - Bucket: aws.String(s3config.Bucket), - Key: aws.String(persistentVolumeBackup.File), - }) - if err != nil { - return c.String(500, "Internal server error") - } - defer func(resp *s3.GetObjectOutput) { - err := resp.Body.Close() - if err != nil { - log.Println(err) - } - }(resp) - // send file - if resp.ContentLength != nil { - contentLength, err := strconv.ParseInt(strconv.FormatInt(*resp.ContentLength, 10), 10, 64) - if err != nil { - return c.String(500, "Internal server error") - } - c.Response().Header().Set("Content-Length", fmt.Sprintf("%d", contentLength)) - } - c.Response().Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", persistentVolumeBackup.File)) - return c.Stream(200, "application/octet-stream", resp.Body) - } else { - return c.String(500, "Internal server error") - } -} - -// GET /persistent-volume/backup/:id/filename -func (server *Server) getPersistentVolumeBackupFileName(c echo.Context) error { - idStr := c.Param("id") - // convert id to uint - id, err := strconv.Atoi(idStr) - if err != nil { - return c.String(400, "Invalid id") - } - // fetch persistent volume backup - var persistentVolumeBackup core.PersistentVolumeBackup - err = persistentVolumeBackup.FindById(c.Request().Context(), server.ServiceManager.DbClient, uint(id)) - if err != nil { - return c.String(500, "Internal server error") - } - return c.String(200, persistentVolumeBackup.File) -} - -// POST /persistent-volume/:id/restore -func (server *Server) uploadPersistentVolumeRestoreFile(c echo.Context) error { - dbTx := server.ServiceManager.DbClient.Begin() - defer func() { - if r := recover(); r != nil { - dbTx.Rollback() - } - }() - file, err := c.FormFile("file") - if err != nil { - return c.JSON(400, map[string]string{ - "message": "file not found", - }) - } - persistentVolumeIdStr := c.Param("id") - // convert id to uint - persistentVolumeId, err := strconv.Atoi(persistentVolumeIdStr) - if err != nil { - return c.JSON(400, map[string]string{ - "message": "Invalid id", - }) - } - // fetch persistent volume - var persistentVolume core.PersistentVolume - err = persistentVolume.FindById(c.Request().Context(), *dbTx, uint(persistentVolumeId)) - if err != nil { - return c.JSON(500, map[string]string{ - "message": "Internal server error", - }) - } - // create a new persistent volume restore - persistentVolumeRestore := core.PersistentVolumeRestore{ - Type: core.LocalRestore, - Status: core.RestorePending, - PersistentVolumeID: persistentVolume.ID, - File: "", - CreatedAt: time.Now(), - CompletedAt: time.Now(), - } - err = persistentVolumeRestore.Create(c.Request().Context(), *dbTx) - if err != nil { - return c.JSON(500, map[string]string{ - "message": "Internal server error", - }) - } - // open file - src, err := file.Open() - if err != nil { - return c.JSON(400, map[string]string{ - "message": "file not found", - }) - } - defer func(src multipart.File) { - err := src.Close() - if err != nil { - log.Println(err) - } - }(src) - // Check if filename ends with .tar.gz - if !strings.HasSuffix(file.Filename, ".tar.gz") { - return c.JSON(400, map[string]string{ - "message": "file is not a tar.gz file", - }) - } - // Destination - fileName := fmt.Sprintf("restore-%s-%d.tar.gz", uuid.NewString(), persistentVolumeRestore.ID) - filePath := filepath.Join(server.Config.LocalConfig.ServiceConfig.PVRestoreDirectoryPath, fileName) - // Write file - dst, err := os.Create(filePath) - if err != nil { - return c.JSON(500, map[string]string{ - "message": "failed to create file", - }) - } - defer func(dst *os.File) { - err := dst.Close() - if err != nil { - log.Println(err) - } - }(dst) - // Copy - if _, err = io.Copy(dst, src); err != nil { - log.Println(err) - return c.JSON(500, map[string]string{ - "message": "failed to copy file", - }) - } - // update persistent volume restore - persistentVolumeRestore.File = fileName - err = persistentVolumeRestore.Update(c.Request().Context(), *dbTx, server.Config.LocalConfig.ServiceConfig.PVBackupDirectoryPath) - if err != nil { - return c.JSON(500, map[string]string{ - "message": "failed to update restore", - }) - } - // commit - err = dbTx.Commit().Error - if err != nil { - return c.JSON(500, map[string]string{ - "message": "failed to create restore", - }) - } - err = server.WorkerManager.EnqueuePersistentVolumeRestoreRequest(persistentVolumeRestore.ID) - if err != nil { - // mark restore as failed - persistentVolumeRestore.Status = core.RestoreFailed - err = persistentVolumeRestore.Update(c.Request().Context(), server.ServiceManager.DbClient, server.Config.LocalConfig.ServiceConfig.PVBackupDirectoryPath) - if err != nil { - log.Println(err) - } - return c.JSON(500, map[string]string{ - "message": "failed to enqueue restore job", - }) - } - return c.JSON(200, map[string]string{ - "message": "Restore job has been enqueued. You can check the status of the restore job in restore panel", - }) -} diff --git a/swiftwave_service/rest/server.go b/swiftwave_service/rest/server.go deleted file mode 100644 index 41c465b8fd..0000000000 --- a/swiftwave_service/rest/server.go +++ /dev/null @@ -1,39 +0,0 @@ -package rest - -import ( - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/config/system_config/bootstrap" -) - -// Initialize : Initialize the server and its routes -func (server *Server) Initialize() { - // Initiating Routes for ACME Challenge - server.ServiceManager.SslManager.InitHttpHandlers(server.EchoServer) - // Initiating Routes for Project - server.initiateProjectRoutes(server.EchoServer) -} - -func (server *Server) initiateProjectRoutes(e *echo.Echo) { - // Initiating Routes for Healthcheck - e.GET("/healthcheck", server.healthcheck) - // Initiating Routes for Version - e.GET("/version", server.version) - // Initiating Routes for Auth - e.POST("/auth/login", server.login) - e.GET("/verify-auth", server.verifyAuth) - // Initiating Routes for Project - e.POST("/upload/code", server.uploadTarFile) - // Initiating Routes for PersistentVolume - e.GET("/persistent-volume/backup/:id/download", server.downloadPersistentVolumeBackup) - e.GET("/persistent-volume/backup/:id/filename", server.getPersistentVolumeBackupFileName) - e.POST("/persistent-volume/:id/restore", server.uploadPersistentVolumeRestoreFile) - // Initiating Routes for Webhook - e.Any("/webhook/redeploy-app/:app-id/:webhook-token", server.redeployApp) - // Initiating Routes for fetch and update system config - e.GET("/config/system", bootstrap.FetchSystemConfigHandler) - e.PUT("/config/system", bootstrap.UpdateSystemConfigHandler) - // analytics - e.POST("/service/analytics", server.analytics) - // serve log file - e.GET("/log/:log_file_name", server.fetchLog) -} diff --git a/swiftwave_service/rest/types.go b/swiftwave_service/rest/types.go deleted file mode 100644 index 8d81d09513..0000000000 --- a/swiftwave_service/rest/types.go +++ /dev/null @@ -1,69 +0,0 @@ -package rest - -import ( - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/config" - "github.com/swiftwave-org/swiftwave/swiftwave_service/service_manager" - "github.com/swiftwave-org/swiftwave/swiftwave_service/worker" -) - -// LoginResponse : struct to hold login response -type LoginResponse struct { - Message string `json:"message"` - Token string `json:"token"` - TotpRequired bool `json:"totp_required"` -} - -// Server : hold references to other components of service -type Server struct { - EchoServer *echo.Echo - Config *config.Config - ServiceManager *service_manager.ServiceManager - WorkerManager *worker.Manager -} - -// ResourceStatsData : struct to hold analytics stats data -type ResourceStatsData struct { - SystemStat HostResourceStats `json:"system"` - ServiceStats map[string]*ServiceResourceStats `json:"services"` - TimeStamp uint64 `json:"timestamp"` -} - -// HostResourceStats : struct to hold host resource stats -type HostResourceStats struct { - CpuUsagePercent uint8 `json:"cpu_used_percent"` - MemStat MemoryStat `json:"memory"` - DiskStats []DiskStat `json:"disks"` - NetStat HostNetStat `json:"network"` -} - -type DiskStat struct { - Path string `json:"path"` - MountPoint string `json:"mount_point"` - TotalGB float32 `json:"total_gb"` - UsedGB float32 `json:"used_gb"` -} - -type MemoryStat struct { - TotalGB float32 `json:"total_gb"` - UsedGB float32 `json:"used_gb"` - CachedGB float32 `json:"cached_gb"` -} - -type HostNetStat struct { - SentKB uint64 `json:"sent_kb"` - RecvKB uint64 `json:"recv_kb"` -} - -// ServiceResourceStats : struct to hold service resource stats -type ServiceResourceStats struct { - ServiceCpuTime uint64 `json:"service_cpu_time"` - SystemCpuTime uint64 `json:"system_cpu_time"` - UsedMemoryMB uint64 `json:"used_memory_mb"` - NetStat ServiceNetStat `json:"network"` -} - -type ServiceNetStat struct { - SentKB uint64 `json:"sent_kb"` - RecvKB uint64 `json:"recv_kb"` -} diff --git a/swiftwave_service/rest/upload_code.go b/swiftwave_service/rest/upload_code.go deleted file mode 100644 index 986d9754ee..0000000000 --- a/swiftwave_service/rest/upload_code.go +++ /dev/null @@ -1,71 +0,0 @@ -package rest - -import ( - "github.com/google/uuid" - "github.com/labstack/echo/v4" - "io" - "log" - "mime/multipart" - "os" - "path/filepath" -) - -// Upload tar file and return the file name -// POST /upload/code -func (server *Server) uploadTarFile(c echo.Context) error { - file, err := c.FormFile("file") - if err != nil { - return c.JSON(400, map[string]string{ - "message": "file not found", - }) - } - src, err := file.Open() - if err != nil { - return c.JSON(400, map[string]string{ - "message": "file not found", - }) - } - defer func(src multipart.File) { - err := src.Close() - if err != nil { - log.Println(err) - } - }(src) - - // Check if file is tar - if file.Header.Get("Content-Type") != "application/x-tar" { - return c.JSON(400, map[string]string{ - "message": "file is not a tar file", - }) - } - - // Destination - destFilename := uuid.New().String() + ".tar" - destFile := filepath.Join(server.Config.LocalConfig.ServiceConfig.TarballDirectoryPath, destFilename) - dst, err := os.Create(destFile) - if err != nil { - return c.JSON(500, map[string]string{ - "message": "failed to create file", - }) - } - defer func(dst *os.File) { - err := dst.Close() - if err != nil { - log.Println(err) - } - }(dst) - - // Copy - if _, err = io.Copy(dst, src); err != nil { - log.Println(err) - return c.JSON(500, map[string]string{ - "message": "failed to copy file", - }) - } - - // Return file name - return c.JSON(200, map[string]string{ - "file": destFilename, - "message": "file uploaded successfully", - }) -} diff --git a/swiftwave_service/rest/version.go b/swiftwave_service/rest/version.go deleted file mode 100644 index 1a5484a0e7..0000000000 --- a/swiftwave_service/rest/version.go +++ /dev/null @@ -1,8 +0,0 @@ -package rest - -import "github.com/labstack/echo/v4" - -// GET /version -func (server *Server) version(c echo.Context) error { - return c.String(200, server.Config.LocalConfig.Version) -} diff --git a/swiftwave_service/rest/webhook.go b/swiftwave_service/rest/webhook.go deleted file mode 100644 index 807931dfb3..0000000000 --- a/swiftwave_service/rest/webhook.go +++ /dev/null @@ -1,123 +0,0 @@ -package rest - -import ( - "context" - "errors" - "github.com/labstack/echo/v4" - "github.com/swiftwave-org/swiftwave/swiftwave_service/core" - "github.com/swiftwave-org/swiftwave/swiftwave_service/logger" - "gorm.io/gorm" - "io" - "net/url" - "strings" -) - -// ANY /webhook/redeploy-app/:app-id/:webhook-token -func (server *Server) redeployApp(c echo.Context) error { - appId := c.Param("app-id") - webhookToken := c.Param("webhook-token") - if appId == "" || webhookToken == "" { - return c.String(400, "Invalid request") - } - ctx := context.Background() - // Fetch App - application := core.Application{ - ID: appId, - } - err := application.FindById(ctx, server.ServiceManager.DbClient, application.ID) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return c.String(404, "App not found") - } - return c.String(500, "Error fetching app") - } - // Check if webhook token matches - if application.WebhookToken != webhookToken { - return c.String(401, "Unauthorized") - } - // Fetch latest deployment - deployment, err := core.FindCurrentDeployedDeploymentByApplicationId(ctx, server.ServiceManager.DbClient, application.ID) - if err != nil { - _, err = core.FindLatestDeploymentByApplicationId(ctx, server.ServiceManager.DbClient, application.ID) - if errors.Is(err, gorm.ErrRecordNotFound) { - return c.String(404, "No deployment found") - } - return c.String(500, "Error fetching deployment") - } - - // Get body from request - body, err := io.ReadAll(c.Request().Body) - if err != nil { - return c.String(500, "Error reading request body") - } - bodyString := string(body) - // url decode body - bodyString, err = url.QueryUnescape(bodyString) - if err != nil { - logger.HTTPLoggerError.Println(err) - } - - triggeredRebuild := false - // Check if latest deployment is git - if deployment.UpstreamType == core.UpstreamTypeGit { - searchText := "refs/heads/" + deployment.RepositoryBranch - repoName := deployment.RepositoryOwner + "/" + deployment.RepositoryName - if strings.Contains(bodyString, searchText) && strings.Contains(bodyString, repoName) { - triggeredRebuild = true - } else { - return c.String(200, "OK - No rebuild") - } - } - - // Check if latest deployment is image - if deployment.UpstreamType == core.UpstreamTypeImage { - // remove the tag from the image name - splits := strings.Split(deployment.DockerImage, ":") - if len(splits) == 0 { - return c.String(500, "Error parsing docker image name") - } - imageName := splits[0] - // remove the registry from the image name - splits = strings.Split(imageName, "/") - if len(splits) == 0 { - return c.String(500, "Error parsing docker image name") - } - if len(splits) == 1 { - imageName = splits[0] - } else { - imageName = splits[len(splits)-2] + "/" + splits[len(splits)-1] - } - if strings.Contains(bodyString, imageName) { - triggeredRebuild = true - } else { - return c.String(200, "OK - No rebuild") - } - } - - if triggeredRebuild { - // fetch record - var record = &core.Application{ - ID: application.ID, - } - tx := server.ServiceManager.DbClient.Begin() - deploymentId, err := record.RebuildApplication(ctx, *tx) - if err != nil { - tx.Rollback() - return errors.New("failed to create new deployment") - } - // commit transaction - err = tx.Commit().Error - if err != nil { - tx.Rollback() - return errors.New("failed to create new deployment due to database error") - } - // enqueue build request - err = server.WorkerManager.EnqueueBuildApplicationRequest(record.ID, deploymentId) - if err != nil { - return errors.New("failed to queue build request") - } - return c.String(200, "OK - Rebuild triggered") - } - - return c.String(200, "OK - No rebuild") -}