From 9c8e9baa39871d32cf4268c6b193aad76d012452 Mon Sep 17 00:00:00 2001 From: Lakhan Samani Date: Fri, 31 Dec 2021 17:03:37 +0530 Subject: [PATCH] feat: add _update_config mutation --- server/__test__/admin_login_test.go | 2 +- server/__test__/admin_session_test.go | 2 +- server/__test__/meta_test.go | 2 + server/__test__/resolvers_test.go | 7 +- server/__test__/test.go | 1 + server/__test__/update_config_test.go | 42 + server/env/persist_env.go | 33 +- server/graph/generated/generated.go | 1975 ++++++++++++++++++++++++- server/graph/model/models_gen.go | 72 + server/graph/schema.graphqls | 80 +- server/graph/schema.resolvers.go | 15 +- server/middlewares/cors.go | 2 - server/resolvers/update_config.go | 119 ++ server/utils/auth_token.go | 19 +- 14 files changed, 2316 insertions(+), 55 deletions(-) create mode 100644 server/__test__/update_config_test.go create mode 100644 server/resolvers/update_config.go diff --git a/server/__test__/admin_login_test.go b/server/__test__/admin_login_test.go index fbf18ec..827d8cf 100644 --- a/server/__test__/admin_login_test.go +++ b/server/__test__/admin_login_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" ) -func aminLoginTests(s TestSetup, t *testing.T) { +func adminLoginTests(s TestSetup, t *testing.T) { t.Run(`should complete admin login`, func(t *testing.T) { _, ctx := createContext(s) _, err := resolvers.AdminLoginResolver(ctx, model.AdminLoginInput{ diff --git a/server/__test__/admin_session_test.go b/server/__test__/admin_session_test.go index 06d0a45..bcf248b 100644 --- a/server/__test__/admin_session_test.go +++ b/server/__test__/admin_session_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" ) -func aminSessionTests(s TestSetup, t *testing.T) { +func adminSessionTests(s TestSetup, t *testing.T) { t.Run(`should get admin session`, func(t *testing.T) { req, ctx := createContext(s) _, err := resolvers.AdminSession(ctx) diff --git a/server/__test__/meta_test.go b/server/__test__/meta_test.go index f4167c1..9989141 100644 --- a/server/__test__/meta_test.go +++ b/server/__test__/meta_test.go @@ -2,6 +2,7 @@ package test import ( "context" + "log" "testing" "github.com/authorizerdev/authorizer/server/resolvers" @@ -12,6 +13,7 @@ func metaTests(s TestSetup, t *testing.T) { t.Run(`should get meta information`, func(t *testing.T) { ctx := context.Background() meta, err := resolvers.Meta(ctx) + log.Println("=> meta:", meta) assert.Nil(t, err) assert.False(t, meta.IsFacebookLoginEnabled) assert.False(t, meta.IsGoogleLoginEnabled) diff --git a/server/__test__/resolvers_test.go b/server/__test__/resolvers_test.go index 0d4fea6..83559bc 100644 --- a/server/__test__/resolvers_test.go +++ b/server/__test__/resolvers_test.go @@ -6,6 +6,7 @@ import ( "github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/enum" + "github.com/authorizerdev/authorizer/server/env" ) func TestResolvers(t *testing.T) { @@ -19,6 +20,7 @@ func TestResolvers(t *testing.T) { constants.EnvData.DATABASE_URL = dbURL constants.EnvData.DATABASE_TYPE = dbType db.InitDB() + env.PersistEnv() s := testSetup() defer s.Server.Close() @@ -42,8 +44,9 @@ func TestResolvers(t *testing.T) { usersTest(s, t) deleteUserTest(s, t) updateUserTest(s, t) - aminLoginTests(s, t) - aminSessionTests(s, t) + adminLoginTests(s, t) + adminSessionTests(s, t) + updateConfigTests(s, t) }) } } diff --git a/server/__test__/test.go b/server/__test__/test.go index 5cddfe3..82ae77b 100644 --- a/server/__test__/test.go +++ b/server/__test__/test.go @@ -71,6 +71,7 @@ func testSetup() TestSetup { } constants.EnvData.ENV_PATH = "../../.env.sample" + env.InitEnv() session.InitSession() diff --git a/server/__test__/update_config_test.go b/server/__test__/update_config_test.go new file mode 100644 index 0000000..a104f38 --- /dev/null +++ b/server/__test__/update_config_test.go @@ -0,0 +1,42 @@ +package test + +import ( + "log" + "testing" + + "github.com/authorizerdev/authorizer/server/constants" + "github.com/authorizerdev/authorizer/server/graph/model" + "github.com/authorizerdev/authorizer/server/resolvers" + "github.com/authorizerdev/authorizer/server/utils" + "github.com/stretchr/testify/assert" +) + +func updateConfigTests(s TestSetup, t *testing.T) { + t.Run(`should update configs`, func(t *testing.T) { + req, ctx := createContext(s) + originalAppURL := constants.EnvData.APP_URL + log.Println("=> originalAppURL:", constants.EnvData.APP_URL) + + data := model.UpdateConfigInput{} + _, err := resolvers.UpdateConfigResolver(ctx, data) + log.Println("error:", err) + assert.NotNil(t, err) + + h, _ := utils.HashPassword(constants.EnvData.ADMIN_SECRET) + req.Header.Add("Authorization", "Bearer "+h) + newURL := "https://test.com" + data = model.UpdateConfigInput{ + AppURL: &newURL, + } + _, err = resolvers.UpdateConfigResolver(ctx, data) + log.Println("error:", err) + assert.Nil(t, err) + assert.Equal(t, constants.EnvData.APP_URL, newURL) + assert.NotEqual(t, constants.EnvData.APP_URL, originalAppURL) + data = model.UpdateConfigInput{ + AppURL: &originalAppURL, + } + _, err = resolvers.UpdateConfigResolver(ctx, data) + assert.Nil(t, err) + }) +} diff --git a/server/env/persist_env.go b/server/env/persist_env.go index 9f1fdd5..7ce535c 100644 --- a/server/env/persist_env.go +++ b/server/env/persist_env.go @@ -59,8 +59,6 @@ func PersistEnv() error { return err } - log.Println("=> persisted data:", jsonData) - // if env is changed via env file or OS env // give that higher preference and update db, but we don't recommend it @@ -120,7 +118,6 @@ func PersistEnv() error { } } - log.Println("has changed:", hasChanged) if hasChanged { jsonBytes, err := json.Marshal(jsonData) if err != nil { @@ -132,23 +129,23 @@ func PersistEnv() error { return err } + configData, err := json.Marshal(constants.EnvData) + if err != nil { + return err + } + encryptedConfig, err := utils.EncryptAES(configData) + if err != nil { + return err + } + + config.Config = encryptedConfig + _, err = db.Mgr.UpdateConfig(config) + if err != nil { + log.Println("error updating config:", err) + return err + } } - configData, err := json.Marshal(constants.EnvData) - if err != nil { - return err - } - encryptedConfig, err := utils.EncryptAES(configData) - if err != nil { - return err - } - - config.Config = encryptedConfig - _, err = db.Mgr.UpdateConfig(config) - if err != nil { - log.Println("error updating config:", err) - return err - } } return nil diff --git a/server/graph/generated/generated.go b/server/graph/generated/generated.go index 59bea79..5230e13 100644 --- a/server/graph/generated/generated.go +++ b/server/graph/generated/generated.go @@ -55,6 +55,42 @@ type ComplexityRoot struct { User func(childComplexity int) int } + Config struct { + AdminSecret func(childComplexity int) int + AllowedOrigins func(childComplexity int) int + AppURL func(childComplexity int) int + AuthorizerURL func(childComplexity int) int + CookieName func(childComplexity int) int + DatabaseName func(childComplexity int) int + DatabaseType func(childComplexity int) int + DatabaseURL func(childComplexity int) int + DefaultRoles func(childComplexity int) int + DisableBasicAuthentication func(childComplexity int) int + DisableEmailVerification func(childComplexity int) int + DisableLoginPage func(childComplexity int) int + DisableMagicLinkLogin func(childComplexity int) int + FacebookClientID func(childComplexity int) int + FacebookClientSecret func(childComplexity int) int + GithubClientID func(childComplexity int) int + GithubClientSecret func(childComplexity int) int + GoogleClientID func(childComplexity int) int + GoogleClientSecret func(childComplexity int) int + JwtRoleClaim func(childComplexity int) int + JwtSecret func(childComplexity int) int + JwtType func(childComplexity int) int + OrganizationLogo func(childComplexity int) int + OrganizationName func(childComplexity int) int + ProtectedRoles func(childComplexity int) int + RedisURL func(childComplexity int) int + ResetPasswordURL func(childComplexity int) int + Roles func(childComplexity int) int + SMTPHost func(childComplexity int) int + SMTPPort func(childComplexity int) int + SenderEmail func(childComplexity int) int + SenderPassword func(childComplexity int) int + Version func(childComplexity int) int + } + Error struct { Message func(childComplexity int) int Reason func(childComplexity int) int @@ -80,6 +116,7 @@ type ComplexityRoot struct { ResendVerifyEmail func(childComplexity int, params model.ResendVerifyEmailInput) int ResetPassword func(childComplexity int, params model.ResetPasswordInput) int Signup func(childComplexity int, params model.SignUpInput) int + UpdateConfig func(childComplexity int, params model.UpdateConfigInput) int UpdateProfile func(childComplexity int, params model.UpdateProfileInput) int UpdateUser func(childComplexity int, params model.UpdateUserInput) int VerifyEmail func(childComplexity int, params model.VerifyEmailInput) int @@ -87,6 +124,7 @@ type ComplexityRoot struct { Query struct { AdminSession func(childComplexity int) int + Config func(childComplexity int) int Meta func(childComplexity int) int Profile func(childComplexity int) int Session func(childComplexity int, roles []string) int @@ -142,6 +180,7 @@ type MutationResolver interface { DeleteUser(ctx context.Context, params model.DeleteUserInput) (*model.Response, error) UpdateUser(ctx context.Context, params model.UpdateUserInput) (*model.User, error) AdminLogin(ctx context.Context, params model.AdminLoginInput) (*model.AdminLoginResponse, error) + UpdateConfig(ctx context.Context, params model.UpdateConfigInput) (*model.Response, error) } type QueryResolver interface { Meta(ctx context.Context) (*model.Meta, error) @@ -150,6 +189,7 @@ type QueryResolver interface { Users(ctx context.Context) ([]*model.User, error) VerificationRequests(ctx context.Context) ([]*model.VerificationRequest, error) AdminSession(ctx context.Context) (*model.AdminLoginResponse, error) + Config(ctx context.Context) (*model.Config, error) } type executableSchema struct { @@ -209,6 +249,237 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.AuthResponse.User(childComplexity), true + case "Config.ADMIN_SECRET": + if e.complexity.Config.AdminSecret == nil { + break + } + + return e.complexity.Config.AdminSecret(childComplexity), true + + case "Config.ALLOWED_ORIGINS": + if e.complexity.Config.AllowedOrigins == nil { + break + } + + return e.complexity.Config.AllowedOrigins(childComplexity), true + + case "Config.APP_URL": + if e.complexity.Config.AppURL == nil { + break + } + + return e.complexity.Config.AppURL(childComplexity), true + + case "Config.AUTHORIZER_URL": + if e.complexity.Config.AuthorizerURL == nil { + break + } + + return e.complexity.Config.AuthorizerURL(childComplexity), true + + case "Config.COOKIE_NAME": + if e.complexity.Config.CookieName == nil { + break + } + + return e.complexity.Config.CookieName(childComplexity), true + + case "Config.DATABASE_NAME": + if e.complexity.Config.DatabaseName == nil { + break + } + + return e.complexity.Config.DatabaseName(childComplexity), true + + case "Config.DATABASE_TYPE": + if e.complexity.Config.DatabaseType == nil { + break + } + + return e.complexity.Config.DatabaseType(childComplexity), true + + case "Config.DATABASE_URL": + if e.complexity.Config.DatabaseURL == nil { + break + } + + return e.complexity.Config.DatabaseURL(childComplexity), true + + case "Config.DEFAULT_ROLES": + if e.complexity.Config.DefaultRoles == nil { + break + } + + return e.complexity.Config.DefaultRoles(childComplexity), true + + case "Config.DISABLE_BASIC_AUTHENTICATION": + if e.complexity.Config.DisableBasicAuthentication == nil { + break + } + + return e.complexity.Config.DisableBasicAuthentication(childComplexity), true + + case "Config.DISABLE_EMAIL_VERIFICATION": + if e.complexity.Config.DisableEmailVerification == nil { + break + } + + return e.complexity.Config.DisableEmailVerification(childComplexity), true + + case "Config.DISABLE_LOGIN_PAGE": + if e.complexity.Config.DisableLoginPage == nil { + break + } + + return e.complexity.Config.DisableLoginPage(childComplexity), true + + case "Config.DISABLE_MAGIC_LINK_LOGIN": + if e.complexity.Config.DisableMagicLinkLogin == nil { + break + } + + return e.complexity.Config.DisableMagicLinkLogin(childComplexity), true + + case "Config.FACEBOOK_CLIENT_ID": + if e.complexity.Config.FacebookClientID == nil { + break + } + + return e.complexity.Config.FacebookClientID(childComplexity), true + + case "Config.FACEBOOK_CLIENT_SECRET": + if e.complexity.Config.FacebookClientSecret == nil { + break + } + + return e.complexity.Config.FacebookClientSecret(childComplexity), true + + case "Config.GITHUB_CLIENT_ID": + if e.complexity.Config.GithubClientID == nil { + break + } + + return e.complexity.Config.GithubClientID(childComplexity), true + + case "Config.GITHUB_CLIENT_SECRET": + if e.complexity.Config.GithubClientSecret == nil { + break + } + + return e.complexity.Config.GithubClientSecret(childComplexity), true + + case "Config.GOOGLE_CLIENT_ID": + if e.complexity.Config.GoogleClientID == nil { + break + } + + return e.complexity.Config.GoogleClientID(childComplexity), true + + case "Config.GOOGLE_CLIENT_SECRET": + if e.complexity.Config.GoogleClientSecret == nil { + break + } + + return e.complexity.Config.GoogleClientSecret(childComplexity), true + + case "Config.JWT_ROLE_CLAIM": + if e.complexity.Config.JwtRoleClaim == nil { + break + } + + return e.complexity.Config.JwtRoleClaim(childComplexity), true + + case "Config.JWT_SECRET": + if e.complexity.Config.JwtSecret == nil { + break + } + + return e.complexity.Config.JwtSecret(childComplexity), true + + case "Config.JWT_TYPE": + if e.complexity.Config.JwtType == nil { + break + } + + return e.complexity.Config.JwtType(childComplexity), true + + case "Config.ORGANIZATION_LOGO": + if e.complexity.Config.OrganizationLogo == nil { + break + } + + return e.complexity.Config.OrganizationLogo(childComplexity), true + + case "Config.ORGANIZATION_NAME": + if e.complexity.Config.OrganizationName == nil { + break + } + + return e.complexity.Config.OrganizationName(childComplexity), true + + case "Config.PROTECTED_ROLES": + if e.complexity.Config.ProtectedRoles == nil { + break + } + + return e.complexity.Config.ProtectedRoles(childComplexity), true + + case "Config.REDIS_URL": + if e.complexity.Config.RedisURL == nil { + break + } + + return e.complexity.Config.RedisURL(childComplexity), true + + case "Config.RESET_PASSWORD_URL": + if e.complexity.Config.ResetPasswordURL == nil { + break + } + + return e.complexity.Config.ResetPasswordURL(childComplexity), true + + case "Config.ROLES": + if e.complexity.Config.Roles == nil { + break + } + + return e.complexity.Config.Roles(childComplexity), true + + case "Config.SMTP_HOST": + if e.complexity.Config.SMTPHost == nil { + break + } + + return e.complexity.Config.SMTPHost(childComplexity), true + + case "Config.SMTP_PORT": + if e.complexity.Config.SMTPPort == nil { + break + } + + return e.complexity.Config.SMTPPort(childComplexity), true + + case "Config.SENDER_EMAIL": + if e.complexity.Config.SenderEmail == nil { + break + } + + return e.complexity.Config.SenderEmail(childComplexity), true + + case "Config.SENDER_PASSWORD": + if e.complexity.Config.SenderPassword == nil { + break + } + + return e.complexity.Config.SenderPassword(childComplexity), true + + case "Config.VERSION": + if e.complexity.Config.Version == nil { + break + } + + return e.complexity.Config.Version(childComplexity), true + case "Error.message": if e.complexity.Error.Message == nil { break @@ -375,6 +646,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.Signup(childComplexity, args["params"].(model.SignUpInput)), true + case "Mutation._update_config": + if e.complexity.Mutation.UpdateConfig == nil { + break + } + + args, err := ec.field_Mutation__update_config_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateConfig(childComplexity, args["params"].(model.UpdateConfigInput)), true + case "Mutation.update_profile": if e.complexity.Mutation.UpdateProfile == nil { break @@ -418,6 +701,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.AdminSession(childComplexity), true + case "Query._config": + if e.complexity.Query.Config == nil { + break + } + + return e.complexity.Query.Config(childComplexity), true + case "Query.meta": if e.complexity.Query.Meta == nil { break @@ -766,6 +1056,78 @@ type AdminLoginResponse { access_token: String! } +type Config { + ADMIN_SECRET: String + VERSION: String + DATABASE_TYPE: String + DATABASE_URL: String + DATABASE_NAME: String + SMTP_HOST: String + SMTP_PORT: String + SENDER_EMAIL: String + SENDER_PASSWORD: String + JWT_TYPE: String + JWT_SECRET: String + ALLOWED_ORIGINS: [String!] + AUTHORIZER_URL: String + APP_URL: String + REDIS_URL: String + COOKIE_NAME: String + RESET_PASSWORD_URL: String + DISABLE_EMAIL_VERIFICATION: Boolean + DISABLE_BASIC_AUTHENTICATION: Boolean + DISABLE_MAGIC_LINK_LOGIN: Boolean + DISABLE_LOGIN_PAGE: Boolean + ROLES: [String!] + PROTECTED_ROLES: [String!] + DEFAULT_ROLES: [String!] + JWT_ROLE_CLAIM: String + GOOGLE_CLIENT_ID: String + GOOGLE_CLIENT_SECRET: String + GITHUB_CLIENT_ID: String + GITHUB_CLIENT_SECRET: String + FACEBOOK_CLIENT_ID: String + FACEBOOK_CLIENT_SECRET: String + ORGANIZATION_NAME: String + ORGANIZATION_LOGO: String +} + +input UpdateConfigInput { + ADMIN_SECRET: String + VERSION: String + DATABASE_TYPE: String + DATABASE_URL: String + DATABASE_NAME: String + SMTP_HOST: String + SMTP_PORT: String + SENDER_EMAIL: String + SENDER_PASSWORD: String + JWT_TYPE: String + JWT_SECRET: String + ALLOWED_ORIGINS: [String!] + AUTHORIZER_URL: String + APP_URL: String + REDIS_URL: String + COOKIE_NAME: String + RESET_PASSWORD_URL: String + DISABLE_EMAIL_VERIFICATION: Boolean + DISABLE_BASIC_AUTHENTICATION: Boolean + DISABLE_MAGIC_LINK_LOGIN: Boolean + DISABLE_LOGIN_PAGE: Boolean + ROLES: [String!] + PROTECTED_ROLES: [String!] + DEFAULT_ROLES: [String!] + JWT_ROLE_CLAIM: String + GOOGLE_CLIENT_ID: String + GOOGLE_CLIENT_SECRET: String + GITHUB_CLIENT_ID: String + GITHUB_CLIENT_SECRET: String + FACEBOOK_CLIENT_ID: String + FACEBOOK_CLIENT_SECRET: String + ORGANIZATION_NAME: String + ORGANIZATION_LOGO: String +} + input AdminLoginInput { admin_secret: String! } @@ -861,17 +1223,19 @@ type Mutation { # admin only apis _delete_user(params: DeleteUserInput!): Response! _update_user(params: UpdateUserInput!): User! - _admin_login(params: AdminLoginInput!): AdminLoginResponse + _admin_login(params: AdminLoginInput!): AdminLoginResponse! + _update_config(params: UpdateConfigInput!): Response! } type Query { meta: Meta! - session(roles: [String!]): AuthResponse + session(roles: [String!]): AuthResponse! profile: User! # admin only apis _users: [User!]! _verification_requests: [VerificationRequest!]! - _admin_session: AdminLoginResponse + _admin_session: AdminLoginResponse! + _config: Config! } `, BuiltIn: false}, } @@ -911,6 +1275,21 @@ func (ec *executionContext) field_Mutation__delete_user_args(ctx context.Context return args, nil } +func (ec *executionContext) field_Mutation__update_config_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.UpdateConfigInput + if tmp, ok := rawArgs["params"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) + arg0, err = ec.unmarshalNUpdateConfigInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateConfigInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["params"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation__update_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1315,6 +1694,1062 @@ func (ec *executionContext) _AuthResponse_user(ctx context.Context, field graphq return ec.marshalOUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } +func (ec *executionContext) _Config_ADMIN_SECRET(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AdminSecret, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_VERSION(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Version, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DATABASE_TYPE(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DatabaseType, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DATABASE_URL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DatabaseURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DATABASE_NAME(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DatabaseName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_SMTP_HOST(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SMTPHost, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_SMTP_PORT(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SMTPPort, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_SENDER_EMAIL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SenderEmail, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_SENDER_PASSWORD(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SenderPassword, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_JWT_TYPE(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.JwtType, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_JWT_SECRET(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.JwtSecret, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_ALLOWED_ORIGINS(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AllowedOrigins, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_AUTHORIZER_URL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AuthorizerURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_APP_URL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AppURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_REDIS_URL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RedisURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_COOKIE_NAME(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CookieName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_RESET_PASSWORD_URL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ResetPasswordURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DISABLE_EMAIL_VERIFICATION(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisableEmailVerification, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DISABLE_BASIC_AUTHENTICATION(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisableBasicAuthentication, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DISABLE_MAGIC_LINK_LOGIN(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisableMagicLinkLogin, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DISABLE_LOGIN_PAGE(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisableLoginPage, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_ROLES(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Roles, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_PROTECTED_ROLES(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ProtectedRoles, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_DEFAULT_ROLES(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultRoles, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_JWT_ROLE_CLAIM(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.JwtRoleClaim, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_GOOGLE_CLIENT_ID(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GoogleClientID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_GOOGLE_CLIENT_SECRET(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GoogleClientSecret, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_GITHUB_CLIENT_ID(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GithubClientID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_GITHUB_CLIENT_SECRET(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GithubClientSecret, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_FACEBOOK_CLIENT_ID(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FacebookClientID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_FACEBOOK_CLIENT_SECRET(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FacebookClientSecret, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_ORGANIZATION_NAME(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OrganizationName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Config_ORGANIZATION_LOGO(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Config", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OrganizationLogo, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + func (ec *executionContext) _Error_message(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -2117,11 +3552,56 @@ func (ec *executionContext) _Mutation__admin_login(ctx context.Context, field gr return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*model.AdminLoginResponse) fc.Result = res - return ec.marshalOAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx, field.Selections, res) + return ec.marshalNAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx, field.Selections, res) +} + +func (ec *executionContext) _Mutation__update_config(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation__update_config_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateConfig(rctx, args["params"].(model.UpdateConfigInput)) + }) + 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.(*model.Response) + fc.Result = res + return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } func (ec *executionContext) _Query_meta(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -2191,11 +3671,14 @@ func (ec *executionContext) _Query_session(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*model.AuthResponse) fc.Result = res - return ec.marshalOAuthResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx, field.Selections, res) + return ec.marshalNAuthResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx, field.Selections, res) } func (ec *executionContext) _Query_profile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -2328,11 +3811,49 @@ func (ec *executionContext) _Query__admin_session(ctx context.Context, field gra return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*model.AdminLoginResponse) fc.Result = res - return ec.marshalOAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx, field.Selections, res) + return ec.marshalNAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx, field.Selections, res) +} + +func (ec *executionContext) _Query__config(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Config(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.(*model.Config) + fc.Result = res + return ec.marshalNConfig2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐConfig(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -4669,6 +6190,285 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj i return it, nil } +func (ec *executionContext) unmarshalInputUpdateConfigInput(ctx context.Context, obj interface{}) (model.UpdateConfigInput, error) { + var it model.UpdateConfigInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + for k, v := range asMap { + switch k { + case "ADMIN_SECRET": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ADMIN_SECRET")) + it.AdminSecret, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "VERSION": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("VERSION")) + it.Version, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "DATABASE_TYPE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DATABASE_TYPE")) + it.DatabaseType, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "DATABASE_URL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DATABASE_URL")) + it.DatabaseURL, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "DATABASE_NAME": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DATABASE_NAME")) + it.DatabaseName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "SMTP_HOST": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SMTP_HOST")) + it.SMTPHost, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "SMTP_PORT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SMTP_PORT")) + it.SMTPPort, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "SENDER_EMAIL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SENDER_EMAIL")) + it.SenderEmail, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "SENDER_PASSWORD": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SENDER_PASSWORD")) + it.SenderPassword, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "JWT_TYPE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("JWT_TYPE")) + it.JwtType, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "JWT_SECRET": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("JWT_SECRET")) + it.JwtSecret, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "ALLOWED_ORIGINS": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ALLOWED_ORIGINS")) + it.AllowedOrigins, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + case "AUTHORIZER_URL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("AUTHORIZER_URL")) + it.AuthorizerURL, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "APP_URL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("APP_URL")) + it.AppURL, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "REDIS_URL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("REDIS_URL")) + it.RedisURL, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "COOKIE_NAME": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("COOKIE_NAME")) + it.CookieName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "RESET_PASSWORD_URL": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("RESET_PASSWORD_URL")) + it.ResetPasswordURL, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "DISABLE_EMAIL_VERIFICATION": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DISABLE_EMAIL_VERIFICATION")) + it.DisableEmailVerification, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "DISABLE_BASIC_AUTHENTICATION": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DISABLE_BASIC_AUTHENTICATION")) + it.DisableBasicAuthentication, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "DISABLE_MAGIC_LINK_LOGIN": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DISABLE_MAGIC_LINK_LOGIN")) + it.DisableMagicLinkLogin, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "DISABLE_LOGIN_PAGE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DISABLE_LOGIN_PAGE")) + it.DisableLoginPage, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "ROLES": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ROLES")) + it.Roles, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + case "PROTECTED_ROLES": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("PROTECTED_ROLES")) + it.ProtectedRoles, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + case "DEFAULT_ROLES": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("DEFAULT_ROLES")) + it.DefaultRoles, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + case "JWT_ROLE_CLAIM": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("JWT_ROLE_CLAIM")) + it.JwtRoleClaim, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "GOOGLE_CLIENT_ID": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("GOOGLE_CLIENT_ID")) + it.GoogleClientID, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "GOOGLE_CLIENT_SECRET": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("GOOGLE_CLIENT_SECRET")) + it.GoogleClientSecret, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "GITHUB_CLIENT_ID": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("GITHUB_CLIENT_ID")) + it.GithubClientID, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "GITHUB_CLIENT_SECRET": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("GITHUB_CLIENT_SECRET")) + it.GithubClientSecret, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "FACEBOOK_CLIENT_ID": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("FACEBOOK_CLIENT_ID")) + it.FacebookClientID, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "FACEBOOK_CLIENT_SECRET": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("FACEBOOK_CLIENT_SECRET")) + it.FacebookClientSecret, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "ORGANIZATION_NAME": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ORGANIZATION_NAME")) + it.OrganizationName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "ORGANIZATION_LOGO": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ORGANIZATION_LOGO")) + it.OrganizationLogo, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context, obj interface{}) (model.UpdateProfileInput, error) { var it model.UpdateProfileInput asMap := map[string]interface{}{} @@ -4979,6 +6779,94 @@ func (ec *executionContext) _AuthResponse(ctx context.Context, sel ast.Selection return out } +var configImplementors = []string{"Config"} + +func (ec *executionContext) _Config(ctx context.Context, sel ast.SelectionSet, obj *model.Config) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, configImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Config") + case "ADMIN_SECRET": + out.Values[i] = ec._Config_ADMIN_SECRET(ctx, field, obj) + case "VERSION": + out.Values[i] = ec._Config_VERSION(ctx, field, obj) + case "DATABASE_TYPE": + out.Values[i] = ec._Config_DATABASE_TYPE(ctx, field, obj) + case "DATABASE_URL": + out.Values[i] = ec._Config_DATABASE_URL(ctx, field, obj) + case "DATABASE_NAME": + out.Values[i] = ec._Config_DATABASE_NAME(ctx, field, obj) + case "SMTP_HOST": + out.Values[i] = ec._Config_SMTP_HOST(ctx, field, obj) + case "SMTP_PORT": + out.Values[i] = ec._Config_SMTP_PORT(ctx, field, obj) + case "SENDER_EMAIL": + out.Values[i] = ec._Config_SENDER_EMAIL(ctx, field, obj) + case "SENDER_PASSWORD": + out.Values[i] = ec._Config_SENDER_PASSWORD(ctx, field, obj) + case "JWT_TYPE": + out.Values[i] = ec._Config_JWT_TYPE(ctx, field, obj) + case "JWT_SECRET": + out.Values[i] = ec._Config_JWT_SECRET(ctx, field, obj) + case "ALLOWED_ORIGINS": + out.Values[i] = ec._Config_ALLOWED_ORIGINS(ctx, field, obj) + case "AUTHORIZER_URL": + out.Values[i] = ec._Config_AUTHORIZER_URL(ctx, field, obj) + case "APP_URL": + out.Values[i] = ec._Config_APP_URL(ctx, field, obj) + case "REDIS_URL": + out.Values[i] = ec._Config_REDIS_URL(ctx, field, obj) + case "COOKIE_NAME": + out.Values[i] = ec._Config_COOKIE_NAME(ctx, field, obj) + case "RESET_PASSWORD_URL": + out.Values[i] = ec._Config_RESET_PASSWORD_URL(ctx, field, obj) + case "DISABLE_EMAIL_VERIFICATION": + out.Values[i] = ec._Config_DISABLE_EMAIL_VERIFICATION(ctx, field, obj) + case "DISABLE_BASIC_AUTHENTICATION": + out.Values[i] = ec._Config_DISABLE_BASIC_AUTHENTICATION(ctx, field, obj) + case "DISABLE_MAGIC_LINK_LOGIN": + out.Values[i] = ec._Config_DISABLE_MAGIC_LINK_LOGIN(ctx, field, obj) + case "DISABLE_LOGIN_PAGE": + out.Values[i] = ec._Config_DISABLE_LOGIN_PAGE(ctx, field, obj) + case "ROLES": + out.Values[i] = ec._Config_ROLES(ctx, field, obj) + case "PROTECTED_ROLES": + out.Values[i] = ec._Config_PROTECTED_ROLES(ctx, field, obj) + case "DEFAULT_ROLES": + out.Values[i] = ec._Config_DEFAULT_ROLES(ctx, field, obj) + case "JWT_ROLE_CLAIM": + out.Values[i] = ec._Config_JWT_ROLE_CLAIM(ctx, field, obj) + case "GOOGLE_CLIENT_ID": + out.Values[i] = ec._Config_GOOGLE_CLIENT_ID(ctx, field, obj) + case "GOOGLE_CLIENT_SECRET": + out.Values[i] = ec._Config_GOOGLE_CLIENT_SECRET(ctx, field, obj) + case "GITHUB_CLIENT_ID": + out.Values[i] = ec._Config_GITHUB_CLIENT_ID(ctx, field, obj) + case "GITHUB_CLIENT_SECRET": + out.Values[i] = ec._Config_GITHUB_CLIENT_SECRET(ctx, field, obj) + case "FACEBOOK_CLIENT_ID": + out.Values[i] = ec._Config_FACEBOOK_CLIENT_ID(ctx, field, obj) + case "FACEBOOK_CLIENT_SECRET": + out.Values[i] = ec._Config_FACEBOOK_CLIENT_SECRET(ctx, field, obj) + case "ORGANIZATION_NAME": + out.Values[i] = ec._Config_ORGANIZATION_NAME(ctx, field, obj) + case "ORGANIZATION_LOGO": + out.Values[i] = ec._Config_ORGANIZATION_LOGO(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *model.Error) graphql.Marshaler { @@ -5140,6 +7028,14 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) } case "_admin_login": out.Values[i] = ec._Mutation__admin_login(ctx, field) + if out.Values[i] == graphql.Null { + invalids++ + } + case "_update_config": + out.Values[i] = ec._Mutation__update_config(ctx, field) + if out.Values[i] == graphql.Null { + invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -5189,6 +7085,9 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } }() res = ec._Query_session(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res }) case "profile": @@ -5242,6 +7141,23 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } }() res = ec._Query__admin_session(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "_config": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__config(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res }) case "__type": @@ -5651,6 +7567,20 @@ func (ec *executionContext) unmarshalNAdminLoginInput2githubᚗcomᚋauthorizerd return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNAdminLoginResponse2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx context.Context, sel ast.SelectionSet, v model.AdminLoginResponse) graphql.Marshaler { + return ec._AdminLoginResponse(ctx, sel, &v) +} + +func (ec *executionContext) marshalNAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.AdminLoginResponse) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._AdminLoginResponse(ctx, sel, v) +} + func (ec *executionContext) marshalNAuthResponse2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx context.Context, sel ast.SelectionSet, v model.AuthResponse) graphql.Marshaler { return ec._AuthResponse(ctx, sel, &v) } @@ -5680,6 +7610,20 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } +func (ec *executionContext) marshalNConfig2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐConfig(ctx context.Context, sel ast.SelectionSet, v model.Config) graphql.Marshaler { + return ec._Config(ctx, sel, &v) +} + +func (ec *executionContext) marshalNConfig2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐConfig(ctx context.Context, sel ast.SelectionSet, v *model.Config) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Config(ctx, sel, v) +} + func (ec *executionContext) unmarshalNDeleteUserInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐDeleteUserInput(ctx context.Context, v interface{}) (model.DeleteUserInput, error) { res, err := ec.unmarshalInputDeleteUserInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -5809,6 +7753,11 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel return ret } +func (ec *executionContext) unmarshalNUpdateConfigInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateConfigInput(ctx context.Context, v interface{}) (model.UpdateConfigInput, error) { + res, err := ec.unmarshalInputUpdateConfigInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNUpdateProfileInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateProfileInput(ctx context.Context, v interface{}) (model.UpdateProfileInput, error) { res, err := ec.unmarshalInputUpdateProfileInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -6193,20 +8142,6 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } -func (ec *executionContext) marshalOAdminLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.AdminLoginResponse) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AdminLoginResponse(ctx, sel, v) -} - -func (ec *executionContext) marshalOAuthResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx context.Context, sel ast.SelectionSet, v *model.AuthResponse) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AuthResponse(ctx, sel, v) -} - func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/server/graph/model/models_gen.go b/server/graph/model/models_gen.go index 6152385..a06cb59 100644 --- a/server/graph/model/models_gen.go +++ b/server/graph/model/models_gen.go @@ -18,6 +18,42 @@ type AuthResponse struct { User *User `json:"user"` } +type Config struct { + AdminSecret *string `json:"ADMIN_SECRET"` + Version *string `json:"VERSION"` + DatabaseType *string `json:"DATABASE_TYPE"` + DatabaseURL *string `json:"DATABASE_URL"` + DatabaseName *string `json:"DATABASE_NAME"` + SMTPHost *string `json:"SMTP_HOST"` + SMTPPort *string `json:"SMTP_PORT"` + SenderEmail *string `json:"SENDER_EMAIL"` + SenderPassword *string `json:"SENDER_PASSWORD"` + JwtType *string `json:"JWT_TYPE"` + JwtSecret *string `json:"JWT_SECRET"` + AllowedOrigins []string `json:"ALLOWED_ORIGINS"` + AuthorizerURL *string `json:"AUTHORIZER_URL"` + AppURL *string `json:"APP_URL"` + RedisURL *string `json:"REDIS_URL"` + CookieName *string `json:"COOKIE_NAME"` + ResetPasswordURL *string `json:"RESET_PASSWORD_URL"` + DisableEmailVerification *bool `json:"DISABLE_EMAIL_VERIFICATION"` + DisableBasicAuthentication *bool `json:"DISABLE_BASIC_AUTHENTICATION"` + DisableMagicLinkLogin *bool `json:"DISABLE_MAGIC_LINK_LOGIN"` + DisableLoginPage *bool `json:"DISABLE_LOGIN_PAGE"` + Roles []string `json:"ROLES"` + ProtectedRoles []string `json:"PROTECTED_ROLES"` + DefaultRoles []string `json:"DEFAULT_ROLES"` + JwtRoleClaim *string `json:"JWT_ROLE_CLAIM"` + GoogleClientID *string `json:"GOOGLE_CLIENT_ID"` + GoogleClientSecret *string `json:"GOOGLE_CLIENT_SECRET"` + GithubClientID *string `json:"GITHUB_CLIENT_ID"` + GithubClientSecret *string `json:"GITHUB_CLIENT_SECRET"` + FacebookClientID *string `json:"FACEBOOK_CLIENT_ID"` + FacebookClientSecret *string `json:"FACEBOOK_CLIENT_SECRET"` + OrganizationName *string `json:"ORGANIZATION_NAME"` + OrganizationLogo *string `json:"ORGANIZATION_LOGO"` +} + type DeleteUserInput struct { Email string `json:"email"` } @@ -82,6 +118,42 @@ type SignUpInput struct { Roles []string `json:"roles"` } +type UpdateConfigInput struct { + AdminSecret *string `json:"ADMIN_SECRET"` + Version *string `json:"VERSION"` + DatabaseType *string `json:"DATABASE_TYPE"` + DatabaseURL *string `json:"DATABASE_URL"` + DatabaseName *string `json:"DATABASE_NAME"` + SMTPHost *string `json:"SMTP_HOST"` + SMTPPort *string `json:"SMTP_PORT"` + SenderEmail *string `json:"SENDER_EMAIL"` + SenderPassword *string `json:"SENDER_PASSWORD"` + JwtType *string `json:"JWT_TYPE"` + JwtSecret *string `json:"JWT_SECRET"` + AllowedOrigins []string `json:"ALLOWED_ORIGINS"` + AuthorizerURL *string `json:"AUTHORIZER_URL"` + AppURL *string `json:"APP_URL"` + RedisURL *string `json:"REDIS_URL"` + CookieName *string `json:"COOKIE_NAME"` + ResetPasswordURL *string `json:"RESET_PASSWORD_URL"` + DisableEmailVerification *bool `json:"DISABLE_EMAIL_VERIFICATION"` + DisableBasicAuthentication *bool `json:"DISABLE_BASIC_AUTHENTICATION"` + DisableMagicLinkLogin *bool `json:"DISABLE_MAGIC_LINK_LOGIN"` + DisableLoginPage *bool `json:"DISABLE_LOGIN_PAGE"` + Roles []string `json:"ROLES"` + ProtectedRoles []string `json:"PROTECTED_ROLES"` + DefaultRoles []string `json:"DEFAULT_ROLES"` + JwtRoleClaim *string `json:"JWT_ROLE_CLAIM"` + GoogleClientID *string `json:"GOOGLE_CLIENT_ID"` + GoogleClientSecret *string `json:"GOOGLE_CLIENT_SECRET"` + GithubClientID *string `json:"GITHUB_CLIENT_ID"` + GithubClientSecret *string `json:"GITHUB_CLIENT_SECRET"` + FacebookClientID *string `json:"FACEBOOK_CLIENT_ID"` + FacebookClientSecret *string `json:"FACEBOOK_CLIENT_SECRET"` + OrganizationName *string `json:"ORGANIZATION_NAME"` + OrganizationLogo *string `json:"ORGANIZATION_LOGO"` +} + type UpdateProfileInput struct { OldPassword *string `json:"old_password"` NewPassword *string `json:"new_password"` diff --git a/server/graph/schema.graphqls b/server/graph/schema.graphqls index 1957219..b03a78c 100644 --- a/server/graph/schema.graphqls +++ b/server/graph/schema.graphqls @@ -67,6 +67,78 @@ type AdminLoginResponse { access_token: String! } +type Config { + ADMIN_SECRET: String + VERSION: String + DATABASE_TYPE: String + DATABASE_URL: String + DATABASE_NAME: String + SMTP_HOST: String + SMTP_PORT: String + SENDER_EMAIL: String + SENDER_PASSWORD: String + JWT_TYPE: String + JWT_SECRET: String + ALLOWED_ORIGINS: [String!] + AUTHORIZER_URL: String + APP_URL: String + REDIS_URL: String + COOKIE_NAME: String + RESET_PASSWORD_URL: String + DISABLE_EMAIL_VERIFICATION: Boolean + DISABLE_BASIC_AUTHENTICATION: Boolean + DISABLE_MAGIC_LINK_LOGIN: Boolean + DISABLE_LOGIN_PAGE: Boolean + ROLES: [String!] + PROTECTED_ROLES: [String!] + DEFAULT_ROLES: [String!] + JWT_ROLE_CLAIM: String + GOOGLE_CLIENT_ID: String + GOOGLE_CLIENT_SECRET: String + GITHUB_CLIENT_ID: String + GITHUB_CLIENT_SECRET: String + FACEBOOK_CLIENT_ID: String + FACEBOOK_CLIENT_SECRET: String + ORGANIZATION_NAME: String + ORGANIZATION_LOGO: String +} + +input UpdateConfigInput { + ADMIN_SECRET: String + VERSION: String + DATABASE_TYPE: String + DATABASE_URL: String + DATABASE_NAME: String + SMTP_HOST: String + SMTP_PORT: String + SENDER_EMAIL: String + SENDER_PASSWORD: String + JWT_TYPE: String + JWT_SECRET: String + ALLOWED_ORIGINS: [String!] + AUTHORIZER_URL: String + APP_URL: String + REDIS_URL: String + COOKIE_NAME: String + RESET_PASSWORD_URL: String + DISABLE_EMAIL_VERIFICATION: Boolean + DISABLE_BASIC_AUTHENTICATION: Boolean + DISABLE_MAGIC_LINK_LOGIN: Boolean + DISABLE_LOGIN_PAGE: Boolean + ROLES: [String!] + PROTECTED_ROLES: [String!] + DEFAULT_ROLES: [String!] + JWT_ROLE_CLAIM: String + GOOGLE_CLIENT_ID: String + GOOGLE_CLIENT_SECRET: String + GITHUB_CLIENT_ID: String + GITHUB_CLIENT_SECRET: String + FACEBOOK_CLIENT_ID: String + FACEBOOK_CLIENT_SECRET: String + ORGANIZATION_NAME: String + ORGANIZATION_LOGO: String +} + input AdminLoginInput { admin_secret: String! } @@ -162,15 +234,17 @@ type Mutation { # admin only apis _delete_user(params: DeleteUserInput!): Response! _update_user(params: UpdateUserInput!): User! - _admin_login(params: AdminLoginInput!): AdminLoginResponse + _admin_login(params: AdminLoginInput!): AdminLoginResponse! + _update_config(params: UpdateConfigInput!): Response! } type Query { meta: Meta! - session(roles: [String!]): AuthResponse + session(roles: [String!]): AuthResponse! profile: User! # admin only apis _users: [User!]! _verification_requests: [VerificationRequest!]! - _admin_session: AdminLoginResponse + _admin_session: AdminLoginResponse! + _config: Config! } diff --git a/server/graph/schema.resolvers.go b/server/graph/schema.resolvers.go index bcf9726..8edc26e 100644 --- a/server/graph/schema.resolvers.go +++ b/server/graph/schema.resolvers.go @@ -5,6 +5,7 @@ package graph import ( "context" + "fmt" "github.com/authorizerdev/authorizer/server/graph/generated" "github.com/authorizerdev/authorizer/server/graph/model" @@ -59,6 +60,10 @@ func (r *mutationResolver) AdminLogin(ctx context.Context, params model.AdminLog return resolvers.AdminLoginResolver(ctx, params) } +func (r *mutationResolver) UpdateConfig(ctx context.Context, params model.UpdateConfigInput) (*model.Response, error) { + return resolvers.UpdateConfigResolver(ctx, params) +} + func (r *queryResolver) Meta(ctx context.Context) (*model.Meta, error) { return resolvers.Meta(ctx) } @@ -83,13 +88,15 @@ func (r *queryResolver) AdminSession(ctx context.Context) (*model.AdminLoginResp return resolvers.AdminSession(ctx) } +func (r *queryResolver) Config(ctx context.Context) (*model.Config, error) { + panic(fmt.Errorf("not implemented")) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -type ( - mutationResolver struct{ *Resolver } - queryResolver struct{ *Resolver } -) +type mutationResolver struct{ *Resolver } +type queryResolver struct{ *Resolver } diff --git a/server/middlewares/cors.go b/server/middlewares/cors.go index a5065e6..f093e8a 100644 --- a/server/middlewares/cors.go +++ b/server/middlewares/cors.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/utils" "github.com/gin-gonic/gin" ) @@ -9,7 +8,6 @@ import ( func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { origin := c.Request.Header.Get("Origin") - constants.EnvData.APP_URL = origin if utils.IsValidOrigin(origin) { c.Writer.Header().Set("Access-Control-Allow-Origin", origin) diff --git a/server/resolvers/update_config.go b/server/resolvers/update_config.go new file mode 100644 index 0000000..089b0cc --- /dev/null +++ b/server/resolvers/update_config.go @@ -0,0 +1,119 @@ +package resolvers + +import ( + "context" + "encoding/json" + "fmt" + "log" + "reflect" + + "github.com/authorizerdev/authorizer/server/constants" + "github.com/authorizerdev/authorizer/server/db" + "github.com/authorizerdev/authorizer/server/graph/model" + "github.com/authorizerdev/authorizer/server/utils" +) + +func UpdateConfigResolver(ctx context.Context, params model.UpdateConfigInput) (*model.Response, error) { + gc, err := utils.GinContextFromContext(ctx) + var res *model.Response + + if err != nil { + return res, err + } + + if !utils.IsSuperAdmin(gc) { + return res, fmt.Errorf("unauthorized") + } + + var data map[string]interface{} + byteData, err := json.Marshal(params) + if err != nil { + return res, fmt.Errorf("error marshalling params: %t", err) + } + + err = json.Unmarshal(byteData, &data) + if err != nil { + return res, fmt.Errorf("error un-marshalling params: %t", err) + } + + updatedData := make(map[string]interface{}) + for key, value := range data { + if value != nil { + fieldType := reflect.TypeOf(value).String() + + if fieldType == "string" || fieldType == "bool" { + updatedData[key] = value + } + + if fieldType == "[]interface {}" { + stringArr := []string{} + for _, v := range value.([]interface{}) { + stringArr = append(stringArr, v.(string)) + } + updatedData[key] = stringArr + } + } + } + + // handle derivative cases like disabling email verification & magic login + // in case SMTP is off but env is set to true + if updatedData["SMTP_HOST"] == "" || updatedData["SENDER_EMAIL"] == "" || updatedData["SENDER_PASSWORD"] == "" { + if !updatedData["DISABLE_EMAIL_VERIFICATION"].(bool) { + updatedData["DISABLE_EMAIL_VERIFICATION"] = true + } + + if !updatedData["DISABLE_MAGIC_LINK_LOGIN"].(bool) { + updatedData["DISABLE_MAGIC_LINK_LOGIN"] = true + } + } + + config, err := db.Mgr.GetConfig() + if err != nil { + return res, err + } + + jsonBytes, err := json.Marshal(updatedData) + if err != nil { + return res, err + } + + err = json.Unmarshal(jsonBytes, &constants.EnvData) + if err != nil { + return res, err + } + + configData, err := json.Marshal(constants.EnvData) + if err != nil { + return res, err + } + encryptedConfig, err := utils.EncryptAES(configData) + if err != nil { + return res, err + } + + // in case of db change re-initialize db + if params.DatabaseType != nil || params.DatabaseURL != nil || params.DatabaseName != nil { + db.InitDB() + } + + // in case of admin secret change update the cookie with new hash + if params.AdminSecret != nil { + hashedKey, err := utils.HashPassword(constants.EnvData.ADMIN_SECRET) + if err != nil { + return res, err + } + utils.SetAdminCookie(gc, hashedKey) + } + + config.Config = encryptedConfig + _, err = db.Mgr.UpdateConfig(config) + if err != nil { + log.Println("error updating config:", err) + return res, err + } + + res = &model.Response{ + Message: "configurations updated successfully", + } + return res, nil +} diff --git a/server/utils/auth_token.go b/server/utils/auth_token.go index f159cd0..18ed7ea 100644 --- a/server/utils/auth_token.go +++ b/server/utils/auth_token.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "net/url" "os" "strings" "time" @@ -140,10 +141,20 @@ func GetAdminAuthToken(gc *gin.Context) (string, error) { token = strings.TrimPrefix(auth, "Bearer ") - err = bcrypt.CompareHashAndPassword([]byte(token), []byte(constants.EnvData.ADMIN_SECRET)) - if err != nil { - return "", fmt.Errorf(`unauthorized`) - } } + + // cookie escapes special characters like $ + // hence we need to unescape before comparing + decodedValue, err := url.QueryUnescape(token) + if err != nil { + return "", err + } + + err = bcrypt.CompareHashAndPassword([]byte(decodedValue), []byte(constants.EnvData.ADMIN_SECRET)) + log.Println("error comparing hash:", err) + if err != nil { + return "", fmt.Errorf(`unauthorized`) + } + return token, nil }