fix(server): env setup
This commit is contained in:
parent
5ecc49f861
commit
7785f98dcd
|
@ -1,6 +1,35 @@
|
||||||
import { Box, Flex } from '@chakra-ui/react';
|
import { Box, Divider, Flex } from '@chakra-ui/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
// Don't allow changing database from here as it can cause persistence issues
|
||||||
export default function Environment() {
|
export default function Environment() {
|
||||||
return <Box>Welcome to Environment Page</Box>;
|
return (
|
||||||
|
<Box m="5" p="5" bg="white" rounded="md">
|
||||||
|
<h1>Social Media Logins</h1>
|
||||||
|
<Divider />- Add horizontal input for clientID and secret for - Google -
|
||||||
|
Github - Facebook
|
||||||
|
<h1>Roles</h1>
|
||||||
|
<Divider />- Add tagged input for roles, default roles, and protected
|
||||||
|
roles
|
||||||
|
<h1>JWT Configurations</h1>
|
||||||
|
<Divider />- Add input for JWT Type (keep this disabled for now with
|
||||||
|
notice saying, "More JWT types will be enabled in upcoming releases"),JWT
|
||||||
|
secret, JWT role claim
|
||||||
|
<h1>Session Storage</h1>
|
||||||
|
<Divider />- Add input for redis url
|
||||||
|
<h1>Email Configurations</h1>
|
||||||
|
<Divider />- Add input for SMTP Host, PORT, Username, Password, From
|
||||||
|
Email,
|
||||||
|
<h1>White Listing</h1>
|
||||||
|
<Divider />- Add input for allowed origins
|
||||||
|
<h1>Organization Information</h1>
|
||||||
|
<Divider />- Add input for organization name, and logo
|
||||||
|
<h1>Custom Scripts</h1>
|
||||||
|
<Divider />- For now add text area input for CUSTOM_ACCESS_TOKEN_SCRIPT
|
||||||
|
<h1>Disable Features</h1>
|
||||||
|
<Divider />
|
||||||
|
<h1>Danger</h1>
|
||||||
|
<Divider />- Include changing admin secret
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
2
server/env/persist_env.go
vendored
2
server/env/persist_env.go
vendored
|
@ -28,6 +28,7 @@ func PersistEnv() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptedConfig, err := utils.EncryptAES(configData)
|
encryptedConfig, err := utils.EncryptAES(configData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -121,6 +122,7 @@ func PersistEnv() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
envstore.EnvInMemoryStoreObj.UpdateEnvStore(jsonData)
|
||||||
if hasChanged {
|
if hasChanged {
|
||||||
encryptedConfig, err := utils.EncryptEnvData(jsonData)
|
encryptedConfig, err := utils.EncryptEnvData(jsonData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/authorizerdev/authorizer/server/constants"
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
|
@ -58,6 +59,7 @@ func AdminSignupResolver(ctx context.Context, params model.AdminSignupInput) (*m
|
||||||
}
|
}
|
||||||
|
|
||||||
configData, err := utils.EncryptEnvData(jsonData)
|
configData, err := utils.EncryptEnvData(jsonData)
|
||||||
|
log.Println("=> config data from signup:", configData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ func IsValidEmail(email string) bool {
|
||||||
|
|
||||||
// IsValidOrigin validates origin based on ALLOWED_ORIGINS
|
// IsValidOrigin validates origin based on ALLOWED_ORIGINS
|
||||||
func IsValidOrigin(url string) bool {
|
func IsValidOrigin(url string) bool {
|
||||||
allowedOrigins := envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAllowedOrigins).([]string)
|
allowedOrigins := envstore.EnvInMemoryStoreObj.GetEnvVariable(constants.EnvKeyAllowedOrigins).([]interface{})
|
||||||
if len(allowedOrigins) == 1 && allowedOrigins[0] == "*" {
|
if len(allowedOrigins) == 1 && allowedOrigins[0].(string) == "*" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ func IsValidOrigin(url string) bool {
|
||||||
currentOrigin := hostName + ":" + port
|
currentOrigin := hostName + ":" + port
|
||||||
|
|
||||||
for _, origin := range allowedOrigins {
|
for _, origin := range allowedOrigins {
|
||||||
replacedString := origin
|
replacedString := origin.(string)
|
||||||
// if has regex whitelisted domains
|
// if has regex whitelisted domains
|
||||||
if strings.Contains(origin, "*") {
|
if strings.Contains(origin.(string), "*") {
|
||||||
replacedString = strings.Replace(origin, ".", "\\.", -1)
|
replacedString = strings.Replace(origin.(string), ".", "\\.", -1)
|
||||||
replacedString = strings.Replace(replacedString, "*", ".*", -1)
|
replacedString = strings.Replace(replacedString, "*", ".*", -1)
|
||||||
|
|
||||||
if strings.HasPrefix(replacedString, ".*") {
|
if strings.HasPrefix(replacedString, ".*") {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user