Add support for public private key from admin apis
This commit is contained in:
parent
1f058f954d
commit
66d42fc2bc
2
Makefile
2
Makefile
|
@ -11,3 +11,5 @@ clean:
|
|||
rm -rf build
|
||||
test:
|
||||
cd server && go clean --testcache && go test -v ./test
|
||||
generate:
|
||||
cd server && go get github.com/99designs/gqlgen/cmd@v0.14.0 && go run github.com/99designs/gqlgen generate
|
|
@ -70,6 +70,8 @@ type ComplexityRoot struct {
|
|||
GithubClientSecret func(childComplexity int) int
|
||||
GoogleClientID func(childComplexity int) int
|
||||
GoogleClientSecret func(childComplexity int) int
|
||||
JwtPrivateKey func(childComplexity int) int
|
||||
JwtPublicKey func(childComplexity int) int
|
||||
JwtRoleClaim func(childComplexity int) int
|
||||
JwtSecret func(childComplexity int) int
|
||||
JwtType func(childComplexity int) int
|
||||
|
@ -391,6 +393,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||
|
||||
return e.complexity.Env.GoogleClientSecret(childComplexity), true
|
||||
|
||||
case "Env.JWT_PRIVATE_KEY":
|
||||
if e.complexity.Env.JwtPrivateKey == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Env.JwtPrivateKey(childComplexity), true
|
||||
|
||||
case "Env.JWT_PUBLIC_KEY":
|
||||
if e.complexity.Env.JwtPublicKey == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Env.JwtPublicKey(childComplexity), true
|
||||
|
||||
case "Env.JWT_ROLE_CLAIM":
|
||||
if e.complexity.Env.JwtRoleClaim == nil {
|
||||
break
|
||||
|
@ -1206,6 +1222,8 @@ type Env {
|
|||
SENDER_EMAIL: String
|
||||
JWT_TYPE: String
|
||||
JWT_SECRET: String
|
||||
JWT_PRIVATE_KEY: String
|
||||
JWT_PUBLIC_KEY: String
|
||||
ALLOWED_ORIGINS: [String!]
|
||||
APP_URL: String
|
||||
REDIS_URL: String
|
||||
|
@ -1240,6 +1258,8 @@ input UpdateEnvInput {
|
|||
SENDER_EMAIL: String
|
||||
JWT_TYPE: String
|
||||
JWT_SECRET: String
|
||||
JWT_PRIVATE_KEY: String
|
||||
JWT_PUBLIC_KEY: String
|
||||
ALLOWED_ORIGINS: [String!]
|
||||
APP_URL: String
|
||||
REDIS_URL: String
|
||||
|
@ -2229,6 +2249,70 @@ func (ec *executionContext) _Env_JWT_SECRET(ctx context.Context, field graphql.C
|
|||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Env_JWT_PRIVATE_KEY(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "Env",
|
||||
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.JwtPrivateKey, 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) _Env_JWT_PUBLIC_KEY(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "Env",
|
||||
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.JwtPublicKey, 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) _Env_ALLOWED_ORIGINS(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
@ -7044,6 +7128,22 @@ func (ec *executionContext) unmarshalInputUpdateEnvInput(ctx context.Context, ob
|
|||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "JWT_PRIVATE_KEY":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("JWT_PRIVATE_KEY"))
|
||||
it.JwtPrivateKey, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "JWT_PUBLIC_KEY":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("JWT_PUBLIC_KEY"))
|
||||
it.JwtPublicKey, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "ALLOWED_ORIGINS":
|
||||
var err error
|
||||
|
||||
|
@ -7539,6 +7639,10 @@ func (ec *executionContext) _Env(ctx context.Context, sel ast.SelectionSet, obj
|
|||
out.Values[i] = ec._Env_JWT_TYPE(ctx, field, obj)
|
||||
case "JWT_SECRET":
|
||||
out.Values[i] = ec._Env_JWT_SECRET(ctx, field, obj)
|
||||
case "JWT_PRIVATE_KEY":
|
||||
out.Values[i] = ec._Env_JWT_PRIVATE_KEY(ctx, field, obj)
|
||||
case "JWT_PUBLIC_KEY":
|
||||
out.Values[i] = ec._Env_JWT_PUBLIC_KEY(ctx, field, obj)
|
||||
case "ALLOWED_ORIGINS":
|
||||
out.Values[i] = ec._Env_ALLOWED_ORIGINS(ctx, field, obj)
|
||||
case "APP_URL":
|
||||
|
|
|
@ -34,6 +34,8 @@ type Env struct {
|
|||
SenderEmail *string `json:"SENDER_EMAIL"`
|
||||
JwtType *string `json:"JWT_TYPE"`
|
||||
JwtSecret *string `json:"JWT_SECRET"`
|
||||
JwtPrivateKey *string `json:"JWT_PRIVATE_KEY"`
|
||||
JwtPublicKey *string `json:"JWT_PUBLIC_KEY"`
|
||||
AllowedOrigins []string `json:"ALLOWED_ORIGINS"`
|
||||
AppURL *string `json:"APP_URL"`
|
||||
RedisURL *string `json:"REDIS_URL"`
|
||||
|
@ -153,6 +155,8 @@ type UpdateEnvInput struct {
|
|||
SenderEmail *string `json:"SENDER_EMAIL"`
|
||||
JwtType *string `json:"JWT_TYPE"`
|
||||
JwtSecret *string `json:"JWT_SECRET"`
|
||||
JwtPrivateKey *string `json:"JWT_PRIVATE_KEY"`
|
||||
JwtPublicKey *string `json:"JWT_PUBLIC_KEY"`
|
||||
AllowedOrigins []string `json:"ALLOWED_ORIGINS"`
|
||||
AppURL *string `json:"APP_URL"`
|
||||
RedisURL *string `json:"REDIS_URL"`
|
||||
|
|
|
@ -97,6 +97,8 @@ type Env {
|
|||
SENDER_EMAIL: String
|
||||
JWT_TYPE: String
|
||||
JWT_SECRET: String
|
||||
JWT_PRIVATE_KEY: String
|
||||
JWT_PUBLIC_KEY: String
|
||||
ALLOWED_ORIGINS: [String!]
|
||||
APP_URL: String
|
||||
REDIS_URL: String
|
||||
|
@ -131,6 +133,8 @@ input UpdateEnvInput {
|
|||
SENDER_EMAIL: String
|
||||
JWT_TYPE: String
|
||||
JWT_SECRET: String
|
||||
JWT_PRIVATE_KEY: String
|
||||
JWT_PUBLIC_KEY: String
|
||||
ALLOWED_ORIGINS: [String!]
|
||||
APP_URL: String
|
||||
REDIS_URL: String
|
||||
|
|
|
@ -40,6 +40,8 @@ func EnvResolver(ctx context.Context) (*model.Env, error) {
|
|||
jwtType := store.StringEnv[constants.EnvKeyJwtType]
|
||||
jwtSecret := store.StringEnv[constants.EnvKeyJwtSecret]
|
||||
jwtRoleClaim := store.StringEnv[constants.EnvKeyJwtRoleClaim]
|
||||
jwtPublicKey := store.StringEnv[constants.EnvKeyJwtPublicKey]
|
||||
jwtPrivateKey := store.StringEnv[constants.EnvKeyJwtPrivateKey]
|
||||
allowedOrigins := store.SliceEnv[constants.EnvKeyAllowedOrigins]
|
||||
appURL := store.StringEnv[constants.EnvKeyAppURL]
|
||||
redisURL := store.StringEnv[constants.EnvKeyRedisURL]
|
||||
|
@ -74,6 +76,8 @@ func EnvResolver(ctx context.Context) (*model.Env, error) {
|
|||
SenderEmail: &senderEmail,
|
||||
JwtType: &jwtType,
|
||||
JwtSecret: &jwtSecret,
|
||||
JwtPrivateKey: &jwtPrivateKey,
|
||||
JwtPublicKey: &jwtPublicKey,
|
||||
JwtRoleClaim: &jwtRoleClaim,
|
||||
AllowedOrigins: allowedOrigins,
|
||||
AppURL: &appURL,
|
||||
|
|
Loading…
Reference in New Issue
Block a user