Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bbc6394cf3 | ||
![]() |
63c8e2e55f | ||
![]() |
b224892a39 | ||
![]() |
13edf1965c | ||
![]() |
1f220a5205 | ||
![]() |
32fb954a1c | ||
![]() |
65eadb66fa | ||
![]() |
9ce53eb8e8 | ||
![]() |
3b196f074b | ||
![]() |
f2fe584793 | ||
![]() |
287b952dad | ||
![]() |
e690066652 | ||
![]() |
0f67d74657 | ||
![]() |
6e09307c22 | ||
![]() |
7fc69dcc55 | ||
![]() |
8449821d1b | ||
![]() |
476bdf00fc | ||
![]() |
e41f123866 | ||
![]() |
094782aeca | ||
![]() |
9630cbbc3e | ||
![]() |
1ac060136a | ||
![]() |
844e867d96 | ||
![]() |
820d294130 | ||
![]() |
e37472d498 | ||
![]() |
589af96888 | ||
![]() |
dccc70e5c0 | ||
![]() |
d8eceadd7f | ||
![]() |
e6c4fdff26 | ||
![]() |
896d8e046d | ||
![]() |
a6d5d4af24 | ||
![]() |
cc4eaa2847 | ||
![]() |
dba8944565 | ||
![]() |
e760a5598e | ||
![]() |
f62a22619b | ||
![]() |
c32a7fa1e4 | ||
![]() |
399b97079d |
@@ -7,3 +7,4 @@ SMTP_PORT=2525
|
|||||||
SMTP_USERNAME=test
|
SMTP_USERNAME=test
|
||||||
SMTP_PASSWORD=test
|
SMTP_PASSWORD=test
|
||||||
SENDER_EMAIL="info@authorizer.dev"
|
SENDER_EMAIL="info@authorizer.dev"
|
||||||
|
AWS_REGION=ap-south-1
|
8
Makefile
8
Makefile
@@ -23,14 +23,20 @@ test-arangodb:
|
|||||||
docker run -d --name authorizer_arangodb -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4
|
docker run -d --name authorizer_arangodb -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4
|
||||||
cd server && go clean --testcache && TEST_DBS="arangodb" go test -p 1 -v ./test
|
cd server && go clean --testcache && TEST_DBS="arangodb" go test -p 1 -v ./test
|
||||||
docker rm -vf authorizer_arangodb
|
docker rm -vf authorizer_arangodb
|
||||||
|
test-dynamodb:
|
||||||
|
docker run -d --name dynamodb-local-test -p 8000:8000 amazon/dynamodb-local:latest
|
||||||
|
cd server && go clean --testcache && TEST_DBS="dynamodb" go test -p 1 -v ./test
|
||||||
|
docker rm -vf dynamodb-local-test
|
||||||
test-all-db:
|
test-all-db:
|
||||||
rm -rf server/test/test.db && rm -rf test.db
|
rm -rf server/test/test.db && rm -rf test.db
|
||||||
docker run -d --name authorizer_scylla_db -p 9042:9042 scylladb/scylla
|
docker run -d --name authorizer_scylla_db -p 9042:9042 scylladb/scylla
|
||||||
docker run -d --name authorizer_mongodb_db -p 27017:27017 mongo:4.4.15
|
docker run -d --name authorizer_mongodb_db -p 27017:27017 mongo:4.4.15
|
||||||
docker run -d --name authorizer_arangodb -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4
|
docker run -d --name authorizer_arangodb -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4
|
||||||
cd server && go clean --testcache && TEST_DBS="sqlite,mongodb,arangodb,scylladb" go test -p 1 -v ./test
|
docker run -d --name dynamodb-local-test -p 8000:8000 amazon/dynamodb-local:latest
|
||||||
|
cd server && go clean --testcache && TEST_DBS="sqlite,mongodb,arangodb,scylladb,dynamodb" go test -p 1 -v ./test
|
||||||
docker rm -vf authorizer_scylla_db
|
docker rm -vf authorizer_scylla_db
|
||||||
docker rm -vf authorizer_mongodb_db
|
docker rm -vf authorizer_mongodb_db
|
||||||
docker rm -vf authorizer_arangodb
|
docker rm -vf authorizer_arangodb
|
||||||
|
docker rm -vf dynamodb-local-test
|
||||||
generate:
|
generate:
|
||||||
cd server && go run github.com/99designs/gqlgen generate && go mod tidy
|
cd server && go run github.com/99designs/gqlgen generate && go mod tidy
|
||||||
|
6
app/.prettierrc.json
Normal file
6
app/.prettierrc.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"tabWidth": 2,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"useTabs": false
|
||||||
|
}
|
24
app/package-lock.json
generated
24
app/package-lock.json
generated
@@ -22,7 +22,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react-router-dom": "^5.1.8",
|
"@types/react-router-dom": "^5.1.8",
|
||||||
"@types/styled-components": "^5.1.11"
|
"@types/styled-components": "^5.1.11",
|
||||||
|
"prettier": "2.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@authorizerdev/authorizer-js": {
|
"node_modules/@authorizerdev/authorizer-js": {
|
||||||
@@ -617,6 +618,21 @@
|
|||||||
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin-prettier.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/prop-types": {
|
"node_modules/prop-types": {
|
||||||
"version": "15.7.2",
|
"version": "15.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
||||||
@@ -1329,6 +1345,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"prop-types": {
|
"prop-types": {
|
||||||
"version": "15.7.2",
|
"version": "15.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
||||||
|
@@ -5,7 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf build && NODE_ENV=production node ./esbuild.config.js",
|
"build": "rm -rf build && NODE_ENV=production node ./esbuild.config.js",
|
||||||
"start": "NODE_ENV=development node ./esbuild.config.js"
|
"start": "NODE_ENV=development node ./esbuild.config.js",
|
||||||
|
"format": "prettier --write --use-tabs 'src/**/*.(ts|tsx|js|jsx)'"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Lakhan Samani",
|
"author": "Lakhan Samani",
|
||||||
@@ -19,11 +20,12 @@
|
|||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-is": "^17.0.2",
|
"react-is": "^17.0.2",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"typescript": "^4.3.5",
|
"styled-components": "^5.3.0",
|
||||||
"styled-components": "^5.3.0"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react-router-dom": "^5.1.8",
|
"@types/react-router-dom": "^5.1.8",
|
||||||
"@types/styled-components": "^5.1.11"
|
"@types/styled-components": "^5.1.11",
|
||||||
|
"prettier": "2.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ export default function Root({
|
|||||||
const { token, loading, config } = useAuthorizer();
|
const { token, loading, config } = useAuthorizer();
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(
|
const searchParams = new URLSearchParams(
|
||||||
hasWindow() ? window.location.search : ``
|
hasWindow() ? window.location.search : ``,
|
||||||
);
|
);
|
||||||
const state = searchParams.get('state') || createRandomString();
|
const state = searchParams.get('state') || createRandomString();
|
||||||
const scope = searchParams.get('scope')
|
const scope = searchParams.get('scope')
|
||||||
|
@@ -60,7 +60,12 @@ export default function Login({ urlProps }: { urlProps: Record<string, any> }) {
|
|||||||
{view === VIEW_TYPES.FORGOT_PASSWORD && (
|
{view === VIEW_TYPES.FORGOT_PASSWORD && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<h1 style={{ textAlign: 'center' }}>Forgot Password</h1>
|
<h1 style={{ textAlign: 'center' }}>Forgot Password</h1>
|
||||||
<AuthorizerForgotPassword urlProps={urlProps} />
|
<AuthorizerForgotPassword
|
||||||
|
urlProps={{
|
||||||
|
...urlProps,
|
||||||
|
redirect_uri: `${window.location.origin}/app/reset-password`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Footer>
|
<Footer>
|
||||||
<Link
|
<Link
|
||||||
to="#"
|
to="#"
|
||||||
|
@@ -8,7 +8,7 @@ export const createRandomString = () => {
|
|||||||
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.';
|
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.';
|
||||||
let random = '';
|
let random = '';
|
||||||
const randomValues = Array.from(
|
const randomValues = Array.from(
|
||||||
getCrypto().getRandomValues(new Uint8Array(43))
|
getCrypto().getRandomValues(new Uint8Array(43)),
|
||||||
);
|
);
|
||||||
randomValues.forEach((v) => (random += charset[v % charset.length]));
|
randomValues.forEach((v) => (random += charset[v % charset.length]));
|
||||||
return random;
|
return random;
|
||||||
|
6
dashboard/.prettierrc.json
Normal file
6
dashboard/.prettierrc.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"tabWidth": 2,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"useTabs": false
|
||||||
|
}
|
1191
dashboard/package-lock.json
generated
1191
dashboard/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf build && NODE_ENV=production node ./esbuild.config.js",
|
"build": "rm -rf build && NODE_ENV=production node ./esbuild.config.js",
|
||||||
"start": "NODE_ENV=development node ./esbuild.config.js"
|
"start": "NODE_ENV=development node ./esbuild.config.js",
|
||||||
|
"format": "prettier --write --use-tabs 'src/**/*.(ts|tsx|js|jsx)'"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Lakhan Samani",
|
"author": "Lakhan Samani",
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
"urql": "^2.0.6"
|
"urql": "^2.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react-email-editor": "^1.1.7"
|
"@types/react-email-editor": "^1.1.7",
|
||||||
|
"prettier": "2.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
@@ -20,13 +20,14 @@ import { useClient } from 'urql';
|
|||||||
import { FaSave } from 'react-icons/fa';
|
import { FaSave } from 'react-icons/fa';
|
||||||
import InputField from './InputField';
|
import InputField from './InputField';
|
||||||
import {
|
import {
|
||||||
ArrayInputType,
|
|
||||||
DateInputType,
|
DateInputType,
|
||||||
|
MultiSelectInputType,
|
||||||
SelectInputType,
|
SelectInputType,
|
||||||
TextInputType,
|
TextInputType,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { getObjectDiff } from '../utils';
|
import { getObjectDiff } from '../utils';
|
||||||
import { UpdateUser } from '../graphql/mutation';
|
import { UpdateUser } from '../graphql/mutation';
|
||||||
|
import { GetAvailableRolesQuery } from '../graphql/queries';
|
||||||
|
|
||||||
const GenderTypes = {
|
const GenderTypes = {
|
||||||
Undisclosed: null,
|
Undisclosed: null,
|
||||||
@@ -57,8 +58,9 @@ const EditUserModal = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
const [availableRoles, setAvailableRoles] = useState<string[]>([]);
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const [userData, setUserData] = React.useState<userDataTypes>({
|
const [userData, setUserData] = useState<userDataTypes>({
|
||||||
id: '',
|
id: '',
|
||||||
email: '',
|
email: '',
|
||||||
given_name: '',
|
given_name: '',
|
||||||
@@ -73,7 +75,17 @@ const EditUserModal = ({
|
|||||||
});
|
});
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setUserData(user);
|
setUserData(user);
|
||||||
|
fetchAvailableRoles();
|
||||||
}, []);
|
}, []);
|
||||||
|
const fetchAvailableRoles = async () => {
|
||||||
|
const res = await client.query(GetAvailableRolesQuery).toPromise();
|
||||||
|
if (res.data?._env?.ROLES && res.data?._env?.PROTECTED_ROLES) {
|
||||||
|
setAvailableRoles([
|
||||||
|
...res.data._env.ROLES,
|
||||||
|
...res.data._env.PROTECTED_ROLES,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
const saveHandler = async () => {
|
const saveHandler = async () => {
|
||||||
const diff = getObjectDiff(user, userData);
|
const diff = getObjectDiff(user, userData);
|
||||||
const updatedUserData = diff.reduce(
|
const updatedUserData = diff.reduce(
|
||||||
@@ -82,7 +94,7 @@ const EditUserModal = ({
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
[property]: userData[property],
|
[property]: userData[property],
|
||||||
}),
|
}),
|
||||||
{}
|
{},
|
||||||
);
|
);
|
||||||
const res = await client
|
const res = await client
|
||||||
.mutation(UpdateUser, { params: { ...updatedUserData, id: userData.id } })
|
.mutation(UpdateUser, { params: { ...updatedUserData, id: userData.id } })
|
||||||
@@ -221,7 +233,8 @@ const EditUserModal = ({
|
|||||||
<InputField
|
<InputField
|
||||||
variables={userData}
|
variables={userData}
|
||||||
setVariables={setUserData}
|
setVariables={setUserData}
|
||||||
inputType={ArrayInputType.USER_ROLES}
|
availableRoles={availableRoles}
|
||||||
|
inputType={MultiSelectInputType.USER_ROLES}
|
||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Flex, Stack, Text, useMediaQuery } from "@chakra-ui/react";
|
import { Flex, Stack, Text, useMediaQuery } from '@chakra-ui/react';
|
||||||
import InputField from "../../components/InputField";
|
import InputField from '../../components/InputField';
|
||||||
import { TextInputType, TextAreaInputType } from "../../constants";
|
import { TextInputType, TextAreaInputType } from '../../constants';
|
||||||
|
|
||||||
const AccessToken = ({ variables, setVariables }: any) => {
|
const AccessToken = ({ variables, setVariables }: any) => {
|
||||||
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)");
|
const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
||||||
Access Token
|
Access Token
|
||||||
</Text>
|
</Text>
|
||||||
<Stack spacing={6} padding="2% 0%">
|
<Stack spacing={6} padding="2% 0%">
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "50%"}
|
w={isNotSmallerScreen ? '30%' : '50%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">Access Token Expiry Time:</Text>
|
<Text fontSize="sm">Access Token Expiry Time:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -33,9 +33,9 @@ const AccessToken = ({ variables, setVariables }: any) => {
|
|||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "60%"}
|
w={isNotSmallerScreen ? '30%' : '60%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
direction="column"
|
direction="column"
|
||||||
>
|
>
|
||||||
@@ -45,8 +45,8 @@ const AccessToken = ({ variables, setVariables }: any) => {
|
|||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
variables={variables}
|
variables={variables}
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Flex, Stack, Center, Text, useMediaQuery } from "@chakra-ui/react";
|
import { Flex, Stack, Center, Text, useMediaQuery } from '@chakra-ui/react';
|
||||||
import InputField from "../../components/InputField";
|
import InputField from '../../components/InputField';
|
||||||
import { ArrayInputType} from "../../constants";
|
import { ArrayInputType } from '../../constants';
|
||||||
|
|
||||||
const DomainWhiteListing = ({ variables, setVariables }: any) => {
|
const DomainWhiteListing = ({ variables, setVariables }: any) => {
|
||||||
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)");
|
const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
||||||
Domain White Listing
|
Domain White Listing
|
||||||
</Text>
|
</Text>
|
||||||
<Stack spacing={6} padding="2% 0%">
|
<Stack spacing={6} padding="2% 0%">
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex w="30%" justifyContent="start" alignItems="center">
|
<Flex w="30%" justifyContent="start" alignItems="center">
|
||||||
<Text fontSize="sm">Allowed Origins:</Text>
|
<Text fontSize="sm">Allowed Origins:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
variables={variables}
|
variables={variables}
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Flex, Stack, Center, Text, useMediaQuery } from "@chakra-ui/react";
|
import { Flex, Stack, Center, Text, useMediaQuery } from '@chakra-ui/react';
|
||||||
import InputField from "../../components/InputField";
|
import InputField from '../../components/InputField';
|
||||||
import { TextInputType, HiddenInputType} from "../../constants";
|
import { TextInputType, HiddenInputType } from '../../constants';
|
||||||
const EmailConfigurations = ({
|
const EmailConfigurations = ({
|
||||||
variables,
|
variables,
|
||||||
setVariables,
|
setVariables,
|
||||||
fieldVisibility,
|
fieldVisibility,
|
||||||
setFieldVisibility,
|
setFieldVisibility,
|
||||||
}: any) => {
|
}: any) => {
|
||||||
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)");
|
const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
||||||
Email Configurations
|
Email Configurations
|
||||||
</Text>
|
</Text>
|
||||||
<Stack spacing={6} padding="2% 0%">
|
<Stack spacing={6} padding="2% 0%">
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex w="30%" justifyContent="start" alignItems="center">
|
<Flex w="30%" justifyContent="start" alignItems="center">
|
||||||
<Text fontSize="sm">SMTP Host:</Text>
|
<Text fontSize="sm">SMTP Host:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -32,13 +32,13 @@ const EmailConfigurations = ({
|
|||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex w="30%" justifyContent="start" alignItems="center">
|
<Flex w="30%" justifyContent="start" alignItems="center">
|
||||||
<Text fontSize="sm">SMTP Port:</Text>
|
<Text fontSize="sm">SMTP Port:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -48,17 +48,37 @@ const EmailConfigurations = ({
|
|||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "40%"}
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
|
justifyContent="start"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Text fontSize="sm">SMTP Local Name:</Text>
|
||||||
|
</Flex>
|
||||||
|
<Center
|
||||||
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
|
>
|
||||||
|
<InputField
|
||||||
|
borderRadius={5}
|
||||||
|
variables={variables}
|
||||||
|
setVariables={setVariables}
|
||||||
|
inputType={TextInputType.SMTP_LOCAL_NAME}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Flex>
|
||||||
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
|
<Flex
|
||||||
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">SMTP Username:</Text>
|
<Text fontSize="sm">SMTP Username:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -68,17 +88,17 @@ const EmailConfigurations = ({
|
|||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "40%"}
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">SMTP Password:</Text>
|
<Text fontSize="sm">SMTP Password:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -90,13 +110,13 @@ const EmailConfigurations = ({
|
|||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex w="30%" justifyContent="start" alignItems="center">
|
<Flex w="30%" justifyContent="start" alignItems="center">
|
||||||
<Text fontSize="sm">From Email:</Text>
|
<Text fontSize="sm">From Email:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Divider, Flex, Stack, Text } from "@chakra-ui/react";
|
import { Divider, Flex, Stack, Text } from '@chakra-ui/react';
|
||||||
import InputField from "../InputField";
|
import InputField from '../InputField';
|
||||||
import { SwitchInputType } from "../../constants";
|
import { SwitchInputType } from '../../constants';
|
||||||
|
|
||||||
const Features = ({ variables, setVariables }: any) => {
|
const Features = ({ variables, setVariables }: any) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
||||||
Disable Features
|
Disable Features
|
||||||
</Text>
|
</Text>
|
||||||
@@ -126,7 +126,7 @@ const Features = ({ variables, setVariables }: any) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Divider paddingY={5}/>
|
<Divider paddingY={5} />
|
||||||
<Text fontSize="md" paddingTop={5} fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop={5} fontWeight="bold" mb={5}>
|
||||||
Cookie Security Features
|
Cookie Security Features
|
||||||
</Text>
|
</Text>
|
||||||
@@ -135,7 +135,8 @@ const Features = ({ variables, setVariables }: any) => {
|
|||||||
<Flex w="100%" alignItems="baseline" flexDir="column">
|
<Flex w="100%" alignItems="baseline" flexDir="column">
|
||||||
<Text fontSize="sm">Use Secure App Cookie:</Text>
|
<Text fontSize="sm">Use Secure App Cookie:</Text>
|
||||||
<Text fontSize="x-small">
|
<Text fontSize="x-small">
|
||||||
Note: If you set this to insecure, it will set <code>sameSite</code> property of cookie to <code>lax</code> mode
|
Note: If you set this to insecure, it will set{' '}
|
||||||
|
<code>sameSite</code> property of cookie to <code>lax</code> mode
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex justifyContent="start">
|
<Flex justifyContent="start">
|
||||||
|
@@ -37,7 +37,7 @@ const JSTConfigurations = ({
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: variables.JWT_TYPE,
|
type: variables.JWT_TYPE,
|
||||||
key: variables.JWT_PUBLIC_KEY || variables.JWT_SECRET,
|
key: variables.JWT_PUBLIC_KEY || variables.JWT_SECRET,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
toast({
|
toast({
|
||||||
title: `JWT config copied successfully`,
|
title: `JWT config copied successfully`,
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Flex, Stack, Center, Text, useMediaQuery } from "@chakra-ui/react";
|
import { Flex, Stack, Center, Text, useMediaQuery } from '@chakra-ui/react';
|
||||||
import InputField from "../InputField";
|
import InputField from '../InputField';
|
||||||
import { TextInputType } from "../../constants";
|
import { TextInputType } from '../../constants';
|
||||||
|
|
||||||
const OrganizationInfo = ({ variables, setVariables }: any) => {
|
const OrganizationInfo = ({ variables, setVariables }: any) => {
|
||||||
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)");
|
const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold" mb={5}>
|
||||||
Organization Information
|
Organization Information
|
||||||
</Text>
|
</Text>
|
||||||
<Stack spacing={6} padding="2% 0%">
|
<Stack spacing={6} padding="2% 0%">
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "40%"}
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">Organization Name:</Text>
|
<Text fontSize="sm">Organization Name:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
@@ -32,17 +32,17 @@ const OrganizationInfo = ({ variables, setVariables }: any) => {
|
|||||||
/>
|
/>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={isNotSmallerScreen ? "row" : "column"}>
|
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "40%"}
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">Organization Logo:</Text>
|
<Text fontSize="sm">Organization Logo:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
Flex,
|
Flex,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -8,10 +8,10 @@ import {
|
|||||||
InputGroup,
|
InputGroup,
|
||||||
InputRightElement,
|
InputRightElement,
|
||||||
useMediaQuery,
|
useMediaQuery,
|
||||||
} from "@chakra-ui/react";
|
} from '@chakra-ui/react';
|
||||||
import { FaRegEyeSlash, FaRegEye } from "react-icons/fa";
|
import { FaRegEyeSlash, FaRegEye } from 'react-icons/fa';
|
||||||
import InputField from "../InputField";
|
import InputField from '../InputField';
|
||||||
import { HiddenInputType } from "../../constants";
|
import { HiddenInputType } from '../../constants';
|
||||||
const SecurityAdminSecret = ({
|
const SecurityAdminSecret = ({
|
||||||
variables,
|
variables,
|
||||||
setVariables,
|
setVariables,
|
||||||
@@ -20,10 +20,10 @@ const SecurityAdminSecret = ({
|
|||||||
validateAdminSecretHandler,
|
validateAdminSecretHandler,
|
||||||
adminSecret,
|
adminSecret,
|
||||||
}: any) => {
|
}: any) => {
|
||||||
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)");
|
const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{" "}
|
{' '}
|
||||||
<Text fontSize="md" paddingTop="2%" fontWeight="bold">
|
<Text fontSize="md" paddingTop="2%" fontWeight="bold">
|
||||||
Security (Admin Secret)
|
Security (Admin Secret)
|
||||||
</Text>
|
</Text>
|
||||||
@@ -35,20 +35,20 @@ const SecurityAdminSecret = ({
|
|||||||
borderRadius="5px"
|
borderRadius="5px"
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
marginTop={isNotSmallerScreen ? "3%" : "5%"}
|
marginTop={isNotSmallerScreen ? '3%' : '5%'}
|
||||||
direction={isNotSmallerScreen ? "row" : "column"}
|
direction={isNotSmallerScreen ? 'row' : 'column'}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
mt={3}
|
mt={3}
|
||||||
w={isNotSmallerScreen ? "30%" : "40%"}
|
w={isNotSmallerScreen ? '30%' : '40%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">Old Admin Secret:</Text>
|
<Text fontSize="sm">Old Admin Secret:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputGroup size="sm">
|
<InputGroup size="sm">
|
||||||
<Input
|
<Input
|
||||||
@@ -59,8 +59,8 @@ const SecurityAdminSecret = ({
|
|||||||
onChange={(event: any) => validateAdminSecretHandler(event)}
|
onChange={(event: any) => validateAdminSecretHandler(event)}
|
||||||
type={
|
type={
|
||||||
!fieldVisibility[HiddenInputType.OLD_ADMIN_SECRET]
|
!fieldVisibility[HiddenInputType.OLD_ADMIN_SECRET]
|
||||||
? "password"
|
? 'password'
|
||||||
: "text"
|
: 'text'
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<InputRightElement
|
<InputRightElement
|
||||||
@@ -104,18 +104,18 @@ const SecurityAdminSecret = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
<Flex
|
<Flex
|
||||||
paddingBottom="3%"
|
paddingBottom="3%"
|
||||||
direction={isNotSmallerScreen ? "row" : "column"}
|
direction={isNotSmallerScreen ? 'row' : 'column'}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
w={isNotSmallerScreen ? "30%" : "50%"}
|
w={isNotSmallerScreen ? '30%' : '50%'}
|
||||||
justifyContent="start"
|
justifyContent="start"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Text fontSize="sm">New Admin Secret:</Text>
|
<Text fontSize="sm">New Admin Secret:</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
w={isNotSmallerScreen ? "70%" : "100%"}
|
w={isNotSmallerScreen ? '70%' : '100%'}
|
||||||
mt={isNotSmallerScreen ? "0" : "3"}
|
mt={isNotSmallerScreen ? '0' : '3'}
|
||||||
>
|
>
|
||||||
<InputField
|
<InputField
|
||||||
borderRadius={5}
|
borderRadius={5}
|
||||||
|
@@ -167,7 +167,7 @@ const GenerateKeysModal = ({ jwtType, getData }: propTypes) => {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{Object.values(HMACEncryptionType).includes(
|
{Object.values(HMACEncryptionType).includes(
|
||||||
stateVariables.JWT_TYPE
|
stateVariables.JWT_TYPE,
|
||||||
) ? (
|
) ? (
|
||||||
<Flex marginTop="8">
|
<Flex marginTop="8">
|
||||||
<Flex w="23%" justifyContent="start" alignItems="center">
|
<Flex w="23%" justifyContent="start" alignItems="center">
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Flex,
|
Flex,
|
||||||
@@ -13,6 +13,12 @@ import {
|
|||||||
Textarea,
|
Textarea,
|
||||||
Switch,
|
Switch,
|
||||||
Text,
|
Text,
|
||||||
|
MenuButton,
|
||||||
|
MenuList,
|
||||||
|
MenuItemOption,
|
||||||
|
MenuOptionGroup,
|
||||||
|
Button,
|
||||||
|
Menu,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import {
|
import {
|
||||||
FaRegClone,
|
FaRegClone,
|
||||||
@@ -20,6 +26,7 @@ import {
|
|||||||
FaRegEyeSlash,
|
FaRegEyeSlash,
|
||||||
FaPlus,
|
FaPlus,
|
||||||
FaTimes,
|
FaTimes,
|
||||||
|
FaAngleDown,
|
||||||
} from 'react-icons/fa';
|
} from 'react-icons/fa';
|
||||||
import {
|
import {
|
||||||
ArrayInputOperations,
|
ArrayInputOperations,
|
||||||
@@ -30,6 +37,7 @@ import {
|
|||||||
TextAreaInputType,
|
TextAreaInputType,
|
||||||
SwitchInputType,
|
SwitchInputType,
|
||||||
DateInputType,
|
DateInputType,
|
||||||
|
MultiSelectInputType,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { copyTextToClipboard } from '../utils';
|
import { copyTextToClipboard } from '../utils';
|
||||||
|
|
||||||
@@ -39,13 +47,16 @@ const InputField = ({
|
|||||||
setVariables,
|
setVariables,
|
||||||
fieldVisibility,
|
fieldVisibility,
|
||||||
setFieldVisibility,
|
setFieldVisibility,
|
||||||
|
availableRoles,
|
||||||
...downshiftProps
|
...downshiftProps
|
||||||
}: any) => {
|
}: any) => {
|
||||||
const props = {
|
const props = {
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
...downshiftProps,
|
...downshiftProps,
|
||||||
};
|
};
|
||||||
const [inputFieldVisibility, setInputFieldVisibility] = React.useState<
|
const [availableUserRoles, setAvailableUserRoles] =
|
||||||
|
useState<string[]>(availableRoles);
|
||||||
|
const [inputFieldVisibility, setInputFieldVisibility] = useState<
|
||||||
Record<string, boolean>
|
Record<string, boolean>
|
||||||
>({
|
>({
|
||||||
ROLES: false,
|
ROLES: false,
|
||||||
@@ -54,7 +65,7 @@ const InputField = ({
|
|||||||
ALLOWED_ORIGINS: false,
|
ALLOWED_ORIGINS: false,
|
||||||
roles: false,
|
roles: false,
|
||||||
});
|
});
|
||||||
const [inputData, setInputData] = React.useState<Record<string, string>>({
|
const [inputData, setInputData] = useState<Record<string, string>>({
|
||||||
ROLES: '',
|
ROLES: '',
|
||||||
DEFAULT_ROLES: '',
|
DEFAULT_ROLES: '',
|
||||||
PROTECTED_ROLES: '',
|
PROTECTED_ROLES: '',
|
||||||
@@ -64,7 +75,7 @@ const InputField = ({
|
|||||||
const updateInputHandler = (
|
const updateInputHandler = (
|
||||||
type: string,
|
type: string,
|
||||||
operation: any,
|
operation: any,
|
||||||
role: string = ''
|
role: string = '',
|
||||||
) => {
|
) => {
|
||||||
if (operation === ArrayInputOperations.APPEND) {
|
if (operation === ArrayInputOperations.APPEND) {
|
||||||
if (inputData[type] !== '') {
|
if (inputData[type] !== '') {
|
||||||
@@ -78,7 +89,7 @@ const InputField = ({
|
|||||||
}
|
}
|
||||||
if (operation === ArrayInputOperations.REMOVE) {
|
if (operation === ArrayInputOperations.REMOVE) {
|
||||||
let updatedEnvVars = variables[type].filter(
|
let updatedEnvVars = variables[type].filter(
|
||||||
(item: string) => item !== role
|
(item: string) => item !== role,
|
||||||
);
|
);
|
||||||
setVariables({
|
setVariables({
|
||||||
...variables,
|
...variables,
|
||||||
@@ -95,7 +106,7 @@ const InputField = ({
|
|||||||
onChange={(
|
onChange={(
|
||||||
event: Event & {
|
event: Event & {
|
||||||
target: HTMLInputElement;
|
target: HTMLInputElement;
|
||||||
}
|
},
|
||||||
) =>
|
) =>
|
||||||
setVariables({
|
setVariables({
|
||||||
...variables,
|
...variables,
|
||||||
@@ -116,11 +127,11 @@ const InputField = ({
|
|||||||
<InputGroup size="sm">
|
<InputGroup size="sm">
|
||||||
<Input
|
<Input
|
||||||
{...props}
|
{...props}
|
||||||
value={variables[inputType] ?? ''}
|
value={variables[inputType] || ''}
|
||||||
onChange={(
|
onChange={(
|
||||||
event: Event & {
|
event: Event & {
|
||||||
target: HTMLInputElement;
|
target: HTMLInputElement;
|
||||||
}
|
},
|
||||||
) =>
|
) =>
|
||||||
setVariables({
|
setVariables({
|
||||||
...variables,
|
...variables,
|
||||||
@@ -207,7 +218,7 @@ const InputField = ({
|
|||||||
updateInputHandler(
|
updateInputHandler(
|
||||||
inputType,
|
inputType,
|
||||||
ArrayInputOperations.REMOVE,
|
ArrayInputOperations.REMOVE,
|
||||||
role
|
role,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -221,7 +232,7 @@ const InputField = ({
|
|||||||
size="xs"
|
size="xs"
|
||||||
minW="150px"
|
minW="150px"
|
||||||
placeholder="add a new value"
|
placeholder="add a new value"
|
||||||
value={inputData[inputType] ?? ''}
|
value={inputData[inputType] || ''}
|
||||||
onChange={(e: any) => {
|
onChange={(e: any) => {
|
||||||
setInputData({ ...inputData, [inputType]: e.target.value });
|
setInputData({ ...inputData, [inputType]: e.target.value });
|
||||||
}}
|
}}
|
||||||
@@ -278,6 +289,87 @@ const InputField = ({
|
|||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (Object.values(MultiSelectInputType).includes(inputType)) {
|
||||||
|
return (
|
||||||
|
<Flex w="100%" style={{ position: 'relative' }}>
|
||||||
|
<Flex
|
||||||
|
border="1px solid #e2e8f0"
|
||||||
|
w="100%"
|
||||||
|
borderRadius="var(--chakra-radii-sm)"
|
||||||
|
p="1% 0 0 2.5%"
|
||||||
|
overflowX={variables[inputType].length > 3 ? 'scroll' : 'hidden'}
|
||||||
|
overflowY="hidden"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Flex justifyContent="start" alignItems="center" w="100%" wrap="wrap">
|
||||||
|
{variables[inputType].map((role: string, index: number) => (
|
||||||
|
<Box key={index} margin="0.5%" role="group">
|
||||||
|
<Tag
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
colorScheme="gray"
|
||||||
|
minW="fit-content"
|
||||||
|
>
|
||||||
|
<TagLabel cursor="default">{role}</TagLabel>
|
||||||
|
<TagRightIcon
|
||||||
|
boxSize="12px"
|
||||||
|
as={FaTimes}
|
||||||
|
display="none"
|
||||||
|
cursor="pointer"
|
||||||
|
_groupHover={{ display: 'block' }}
|
||||||
|
onClick={() =>
|
||||||
|
updateInputHandler(
|
||||||
|
inputType,
|
||||||
|
ArrayInputOperations.REMOVE,
|
||||||
|
role,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Tag>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Flex>
|
||||||
|
<Menu matchWidth={true}>
|
||||||
|
<MenuButton px="10px" py="7.5px">
|
||||||
|
<FaAngleDown />
|
||||||
|
</MenuButton>
|
||||||
|
<MenuList
|
||||||
|
position="absolute"
|
||||||
|
top="0"
|
||||||
|
right="0"
|
||||||
|
zIndex="10"
|
||||||
|
maxH="150"
|
||||||
|
overflowX="scroll"
|
||||||
|
>
|
||||||
|
<MenuOptionGroup
|
||||||
|
title={undefined}
|
||||||
|
value={variables[inputType]}
|
||||||
|
type="checkbox"
|
||||||
|
onChange={(values: string[] | string) => {
|
||||||
|
setVariables({
|
||||||
|
...variables,
|
||||||
|
[inputType]: values,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{availableUserRoles.map((role) => {
|
||||||
|
return (
|
||||||
|
<MenuItemOption
|
||||||
|
key={`multiselect-menu-${role}`}
|
||||||
|
value={role}
|
||||||
|
>
|
||||||
|
{role}
|
||||||
|
</MenuItemOption>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</MenuOptionGroup>
|
||||||
|
</MenuList>
|
||||||
|
</Menu>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (Object.values(TextAreaInputType).includes(inputType)) {
|
if (Object.values(TextAreaInputType).includes(inputType)) {
|
||||||
return (
|
return (
|
||||||
<Textarea
|
<Textarea
|
||||||
@@ -288,7 +380,7 @@ const InputField = ({
|
|||||||
onChange={(
|
onChange={(
|
||||||
event: Event & {
|
event: Event & {
|
||||||
target: HTMLInputElement;
|
target: HTMLInputElement;
|
||||||
}
|
},
|
||||||
) =>
|
) =>
|
||||||
setVariables({
|
setVariables({
|
||||||
...variables,
|
...variables,
|
||||||
|
@@ -304,7 +304,7 @@ const InviteMembersModal = ({
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateEmailListHandler(
|
updateEmailListHandler(
|
||||||
ArrayInputOperations.REMOVE,
|
ArrayInputOperations.REMOVE,
|
||||||
index
|
index,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@@ -218,7 +218,7 @@ export const Sidebar = ({ onClose, ...rest }: SidebarProps) => {
|
|||||||
</NavItem>{' '}
|
</NavItem>{' '}
|
||||||
</Text>
|
</Text>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
<Link
|
<Link
|
||||||
href="/playground"
|
href="/playground"
|
||||||
|
@@ -185,7 +185,7 @@ const UpdateEmailTemplate = ({
|
|||||||
toast({
|
toast({
|
||||||
title: capitalizeFirstLetter(
|
title: capitalizeFirstLetter(
|
||||||
res.data?._add_email_template?.message ||
|
res.data?._add_email_template?.message ||
|
||||||
res.data?._update_email_template?.message
|
res.data?._update_email_template?.message,
|
||||||
),
|
),
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -220,7 +220,7 @@ const UpdateEmailTemplate = ({
|
|||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const updatedTemplateVariables = Object.entries(
|
const updatedTemplateVariables = Object.entries(
|
||||||
emailTemplateVariables
|
emailTemplateVariables,
|
||||||
).reduce((acc, [key, val]): any => {
|
).reduce((acc, [key, val]): any => {
|
||||||
if (
|
if (
|
||||||
(templateData[EmailTemplateInputDataFields.EVENT_NAME] !==
|
(templateData[EmailTemplateInputDataFields.EVENT_NAME] !==
|
||||||
@@ -367,7 +367,7 @@ const UpdateEmailTemplate = ({
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
inputChangehandler(
|
inputChangehandler(
|
||||||
EmailTemplateInputDataFields.EVENT_NAME,
|
EmailTemplateInputDataFields.EVENT_NAME,
|
||||||
e.currentTarget.value
|
e.currentTarget.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -376,7 +376,7 @@ const UpdateEmailTemplate = ({
|
|||||||
<option value={value} key={key}>
|
<option value={value} key={key}>
|
||||||
{key}
|
{key}
|
||||||
</option>
|
</option>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</Select>
|
</Select>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -401,7 +401,7 @@ const UpdateEmailTemplate = ({
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
inputChangehandler(
|
inputChangehandler(
|
||||||
EmailTemplateInputDataFields.SUBJECT,
|
EmailTemplateInputDataFields.SUBJECT,
|
||||||
e.currentTarget.value
|
e.currentTarget.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@@ -126,13 +126,13 @@ const UpdateWebhookModal = ({
|
|||||||
...initWebhookValidatorData,
|
...initWebhookValidatorData,
|
||||||
});
|
});
|
||||||
const [verifiedStatus, setVerifiedStatus] = useState<webhookVerifiedStatus>(
|
const [verifiedStatus, setVerifiedStatus] = useState<webhookVerifiedStatus>(
|
||||||
webhookVerifiedStatus.PENDING
|
webhookVerifiedStatus.PENDING,
|
||||||
);
|
);
|
||||||
const inputChangehandler = (
|
const inputChangehandler = (
|
||||||
inputType: string,
|
inputType: string,
|
||||||
value: any,
|
value: any,
|
||||||
headerInputType: string = WebhookInputHeaderFields.KEY,
|
headerInputType: string = WebhookInputHeaderFields.KEY,
|
||||||
headerIndex: number = 0
|
headerIndex: number = 0,
|
||||||
) => {
|
) => {
|
||||||
if (
|
if (
|
||||||
verifiedStatus !== webhookVerifiedStatus.PENDING &&
|
verifiedStatus !== webhookVerifiedStatus.PENDING &&
|
||||||
@@ -238,7 +238,7 @@ const UpdateWebhookModal = ({
|
|||||||
validator[WebhookInputDataFields.ENDPOINT] &&
|
validator[WebhookInputDataFields.ENDPOINT] &&
|
||||||
!validator[WebhookInputDataFields.HEADERS].some(
|
!validator[WebhookInputDataFields.HEADERS].some(
|
||||||
(headerData: headersValidatorDataType) =>
|
(headerData: headersValidatorDataType) =>
|
||||||
!headerData.key || !headerData.value
|
!headerData.key || !headerData.value,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -256,7 +256,7 @@ const UpdateWebhookModal = ({
|
|||||||
(acc, data) => {
|
(acc, data) => {
|
||||||
return data.key ? { ...acc, [data.key]: data.value } : acc;
|
return data.key ? { ...acc, [data.key]: data.value } : acc;
|
||||||
},
|
},
|
||||||
{}
|
{},
|
||||||
);
|
);
|
||||||
if (Object.keys(headers).length) {
|
if (Object.keys(headers).length) {
|
||||||
params[WebhookInputDataFields.HEADERS] = headers;
|
params[WebhookInputDataFields.HEADERS] = headers;
|
||||||
@@ -295,7 +295,7 @@ const UpdateWebhookModal = ({
|
|||||||
} else if (res.data?._add_webhook || res.data?._update_webhook) {
|
} else if (res.data?._add_webhook || res.data?._update_webhook) {
|
||||||
toast({
|
toast({
|
||||||
title: capitalizeFirstLetter(
|
title: capitalizeFirstLetter(
|
||||||
res.data?._add_webhook?.message || res.data?._update_webhook?.message
|
res.data?._add_webhook?.message || res.data?._update_webhook?.message,
|
||||||
),
|
),
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -333,7 +333,7 @@ const UpdateWebhookModal = ({
|
|||||||
setValidator({
|
setValidator({
|
||||||
...validator,
|
...validator,
|
||||||
[WebhookInputDataFields.HEADERS]: new Array(
|
[WebhookInputDataFields.HEADERS]: new Array(
|
||||||
formattedHeadersData.length
|
formattedHeadersData.length,
|
||||||
)
|
)
|
||||||
.fill({})
|
.fill({})
|
||||||
.map(() => ({ ...initHeadersValidatorData })),
|
.map(() => ({ ...initHeadersValidatorData })),
|
||||||
@@ -406,7 +406,7 @@ const UpdateWebhookModal = ({
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
inputChangehandler(
|
inputChangehandler(
|
||||||
WebhookInputDataFields.EVENT_NAME,
|
WebhookInputDataFields.EVENT_NAME,
|
||||||
e.currentTarget.value
|
e.currentTarget.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -415,7 +415,7 @@ const UpdateWebhookModal = ({
|
|||||||
<option value={value} key={key}>
|
<option value={value} key={key}>
|
||||||
{key}
|
{key}
|
||||||
</option>
|
</option>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</Select>
|
</Select>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -438,7 +438,7 @@ const UpdateWebhookModal = ({
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
inputChangehandler(
|
inputChangehandler(
|
||||||
WebhookInputDataFields.ENDPOINT,
|
WebhookInputDataFields.ENDPOINT,
|
||||||
e.currentTarget.value
|
e.currentTarget.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -462,7 +462,7 @@ const UpdateWebhookModal = ({
|
|||||||
onChange={() =>
|
onChange={() =>
|
||||||
inputChangehandler(
|
inputChangehandler(
|
||||||
WebhookInputDataFields.ENABLED,
|
WebhookInputDataFields.ENABLED,
|
||||||
!webhook[WebhookInputDataFields.ENABLED]
|
!webhook[WebhookInputDataFields.ENABLED],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -517,7 +517,7 @@ const UpdateWebhookModal = ({
|
|||||||
WebhookInputDataFields.HEADERS,
|
WebhookInputDataFields.HEADERS,
|
||||||
e.target.value,
|
e.target.value,
|
||||||
WebhookInputHeaderFields.KEY,
|
WebhookInputHeaderFields.KEY,
|
||||||
index
|
index,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
width="30%"
|
width="30%"
|
||||||
@@ -540,7 +540,7 @@ const UpdateWebhookModal = ({
|
|||||||
WebhookInputDataFields.HEADERS,
|
WebhookInputDataFields.HEADERS,
|
||||||
e.target.value,
|
e.target.value,
|
||||||
WebhookInputHeaderFields.VALUE,
|
WebhookInputHeaderFields.VALUE,
|
||||||
index
|
index,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
width="65%"
|
width="65%"
|
||||||
@@ -560,7 +560,7 @@ const UpdateWebhookModal = ({
|
|||||||
</InputRightElement>
|
</InputRightElement>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
<Divider marginY={5} />
|
<Divider marginY={5} />
|
||||||
|
@@ -161,15 +161,15 @@ const ViewWebhookLogsModal = ({
|
|||||||
<Td>
|
<Td>
|
||||||
<Text fontSize="sm">{`${logData.id.substring(
|
<Text fontSize="sm">{`${logData.id.substring(
|
||||||
0,
|
0,
|
||||||
5
|
5,
|
||||||
)}***${logData.id.substring(
|
)}***${logData.id.substring(
|
||||||
logData.id.length - 5,
|
logData.id.length - 5,
|
||||||
logData.id.length
|
logData.id.length,
|
||||||
)}`}</Text>
|
)}`}</Text>
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
{dayjs(logData.created_at * 1000).format(
|
{dayjs(logData.created_at * 1000).format(
|
||||||
'MMM DD, YYYY'
|
'MMM DD, YYYY',
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
|
@@ -15,6 +15,7 @@ export const TextInputType = {
|
|||||||
SMTP_HOST: 'SMTP_HOST',
|
SMTP_HOST: 'SMTP_HOST',
|
||||||
SMTP_PORT: 'SMTP_PORT',
|
SMTP_PORT: 'SMTP_PORT',
|
||||||
SMTP_USERNAME: 'SMTP_USERNAME',
|
SMTP_USERNAME: 'SMTP_USERNAME',
|
||||||
|
SMTP_LOCAL_NAME: 'SMTP_LOCAL_NAME',
|
||||||
SENDER_EMAIL: 'SENDER_EMAIL',
|
SENDER_EMAIL: 'SENDER_EMAIL',
|
||||||
ORGANIZATION_NAME: 'ORGANIZATION_NAME',
|
ORGANIZATION_NAME: 'ORGANIZATION_NAME',
|
||||||
ORGANIZATION_LOGO: 'ORGANIZATION_LOGO',
|
ORGANIZATION_LOGO: 'ORGANIZATION_LOGO',
|
||||||
@@ -48,7 +49,6 @@ export const ArrayInputType = {
|
|||||||
DEFAULT_ROLES: 'DEFAULT_ROLES',
|
DEFAULT_ROLES: 'DEFAULT_ROLES',
|
||||||
PROTECTED_ROLES: 'PROTECTED_ROLES',
|
PROTECTED_ROLES: 'PROTECTED_ROLES',
|
||||||
ALLOWED_ORIGINS: 'ALLOWED_ORIGINS',
|
ALLOWED_ORIGINS: 'ALLOWED_ORIGINS',
|
||||||
USER_ROLES: 'roles',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SelectInputType = {
|
export const SelectInputType = {
|
||||||
@@ -56,6 +56,10 @@ export const SelectInputType = {
|
|||||||
GENDER: 'gender',
|
GENDER: 'gender',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MultiSelectInputType = {
|
||||||
|
USER_ROLES: 'roles',
|
||||||
|
};
|
||||||
|
|
||||||
export const TextAreaInputType = {
|
export const TextAreaInputType = {
|
||||||
CUSTOM_ACCESS_TOKEN_SCRIPT: 'CUSTOM_ACCESS_TOKEN_SCRIPT',
|
CUSTOM_ACCESS_TOKEN_SCRIPT: 'CUSTOM_ACCESS_TOKEN_SCRIPT',
|
||||||
JWT_PRIVATE_KEY: 'JWT_PRIVATE_KEY',
|
JWT_PRIVATE_KEY: 'JWT_PRIVATE_KEY',
|
||||||
@@ -129,6 +133,7 @@ export interface envVarTypes {
|
|||||||
SMTP_PORT: string;
|
SMTP_PORT: string;
|
||||||
SMTP_USERNAME: string;
|
SMTP_USERNAME: string;
|
||||||
SMTP_PASSWORD: string;
|
SMTP_PASSWORD: string;
|
||||||
|
SMTP_LOCAL_NAME: string;
|
||||||
SENDER_EMAIL: string;
|
SENDER_EMAIL: string;
|
||||||
ALLOWED_ORIGINS: [string] | [];
|
ALLOWED_ORIGINS: [string] | [];
|
||||||
ORGANIZATION_NAME: string;
|
ORGANIZATION_NAME: string;
|
||||||
|
@@ -45,6 +45,7 @@ export const EnvVariablesQuery = `
|
|||||||
SMTP_PORT
|
SMTP_PORT
|
||||||
SMTP_USERNAME
|
SMTP_USERNAME
|
||||||
SMTP_PASSWORD
|
SMTP_PASSWORD
|
||||||
|
SMTP_LOCAL_NAME
|
||||||
SENDER_EMAIL
|
SENDER_EMAIL
|
||||||
ALLOWED_ORIGINS
|
ALLOWED_ORIGINS
|
||||||
ORGANIZATION_NAME
|
ORGANIZATION_NAME
|
||||||
@@ -169,3 +170,12 @@ export const WebhookLogsQuery = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const GetAvailableRolesQuery = `
|
||||||
|
query {
|
||||||
|
_env {
|
||||||
|
ROLES
|
||||||
|
PROTECTED_ROLES
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
@@ -6,5 +6,5 @@ ReactDOM.render(
|
|||||||
<div>
|
<div>
|
||||||
<App />
|
<App />
|
||||||
</div>,
|
</div>,
|
||||||
document.getElementById('root')
|
document.getElementById('root'),
|
||||||
);
|
);
|
||||||
|
@@ -154,7 +154,7 @@ const EmailTemplates = () => {
|
|||||||
<Td>{templateData[EmailTemplateInputDataFields.SUBJECT]}</Td>
|
<Td>{templateData[EmailTemplateInputDataFields.SUBJECT]}</Td>
|
||||||
<Td>
|
<Td>
|
||||||
{dayjs(templateData.created_at * 1000).format(
|
{dayjs(templateData.created_at * 1000).format(
|
||||||
'MMM DD, YYYY'
|
'MMM DD, YYYY',
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
|
@@ -65,6 +65,7 @@ const Environment = () => {
|
|||||||
SMTP_PORT: '',
|
SMTP_PORT: '',
|
||||||
SMTP_USERNAME: '',
|
SMTP_USERNAME: '',
|
||||||
SMTP_PASSWORD: '',
|
SMTP_PASSWORD: '',
|
||||||
|
SMTP_LOCAL_NAME: '',
|
||||||
SENDER_EMAIL: '',
|
SENDER_EMAIL: '',
|
||||||
ALLOWED_ORIGINS: [],
|
ALLOWED_ORIGINS: [],
|
||||||
ORGANIZATION_NAME: '',
|
ORGANIZATION_NAME: '',
|
||||||
@@ -157,7 +158,7 @@ const Environment = () => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
[property]: envVariables[property],
|
[property]: envVariables[property],
|
||||||
}),
|
}),
|
||||||
{}
|
{},
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
updatedEnvVariables[HiddenInputType.ADMIN_SECRET] === '' ||
|
updatedEnvVariables[HiddenInputType.ADMIN_SECRET] === '' ||
|
||||||
|
@@ -29,7 +29,7 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
useToast,
|
useToast,
|
||||||
Spinner,
|
Spinner,
|
||||||
TableContainer
|
TableContainer,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import {
|
import {
|
||||||
FaAngleLeft,
|
FaAngleLeft,
|
||||||
@@ -195,7 +195,7 @@ export default function Users() {
|
|||||||
|
|
||||||
const updateAccessHandler = async (
|
const updateAccessHandler = async (
|
||||||
id: string,
|
id: string,
|
||||||
action: updateAccessActions
|
action: updateAccessActions,
|
||||||
) => {
|
) => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case updateAccessActions.ENABLE:
|
case updateAccessActions.ENABLE:
|
||||||
@@ -263,7 +263,8 @@ export default function Users() {
|
|||||||
.toPromise();
|
.toPromise();
|
||||||
if (res.data?._update_user?.id) {
|
if (res.data?._update_user?.id) {
|
||||||
toast({
|
toast({
|
||||||
title: `Multi factor authentication ${user.is_multi_factor_auth_enabled ? 'disabled' : 'enabled'
|
title: `Multi factor authentication ${
|
||||||
|
user.is_multi_factor_auth_enabled ? 'disabled' : 'enabled'
|
||||||
} for user`,
|
} for user`,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -387,7 +388,7 @@ export default function Users() {
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateAccessHandler(
|
updateAccessHandler(
|
||||||
user.id,
|
user.id,
|
||||||
updateAccessActions.ENABLE
|
updateAccessActions.ENABLE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -398,7 +399,7 @@ export default function Users() {
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateAccessHandler(
|
updateAccessHandler(
|
||||||
user.id,
|
user.id,
|
||||||
updateAccessActions.REVOKE
|
updateAccessActions.REVOKE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -407,13 +408,17 @@ export default function Users() {
|
|||||||
)}
|
)}
|
||||||
{user.is_multi_factor_auth_enabled ? (
|
{user.is_multi_factor_auth_enabled ? (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => multiFactorAuthUpdateHandler(user)}
|
onClick={() =>
|
||||||
|
multiFactorAuthUpdateHandler(user)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Disable MultiFactor Authentication
|
Disable MultiFactor Authentication
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
) : (
|
) : (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => multiFactorAuthUpdateHandler(user)}
|
onClick={() =>
|
||||||
|
multiFactorAuthUpdateHandler(user)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Enable MultiFactor Authentication
|
Enable MultiFactor Authentication
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@@ -170,12 +170,12 @@ const Webhooks = () => {
|
|||||||
label={JSON.stringify(
|
label={JSON.stringify(
|
||||||
webhook[WebhookInputDataFields.HEADERS],
|
webhook[WebhookInputDataFields.HEADERS],
|
||||||
null,
|
null,
|
||||||
' '
|
' ',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Tag size="sm" variant="outline" colorScheme="gray">
|
<Tag size="sm" variant="outline" colorScheme="gray">
|
||||||
{Object.keys(
|
{Object.keys(
|
||||||
webhook[WebhookInputDataFields.HEADERS] || {}
|
webhook[WebhookInputDataFields.HEADERS] || {},
|
||||||
)?.length.toString()}
|
)?.length.toString()}
|
||||||
</Tag>
|
</Tag>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
@@ -67,7 +67,7 @@ export const validateEmail = (email: string) => {
|
|||||||
return email
|
return email
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.match(
|
.match(
|
||||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
||||||
)
|
)
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
@@ -78,7 +78,7 @@ export const validateURI = (uri: string) => {
|
|||||||
return uri
|
return uri
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.match(
|
.match(
|
||||||
/(?:^|\s)((https?:\/\/)?(?:localhost|[\w-]+(?:\.[\w-]+)+)(:\d+)?(\/\S*)?)/
|
/(?:^|\s)((https?:\/\/)?(?:localhost|[\w-]+(?:\.[\w-]+)+)(:\d+)?(\/\S*)?)/,
|
||||||
)
|
)
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
|
@@ -27,7 +27,7 @@ const parseCSV = (file: File, delimiter: string): Promise<dataTypes[]> => {
|
|||||||
value: email.trim(),
|
value: email.trim(),
|
||||||
isInvalid: !validateEmail(email.trim()),
|
isInvalid: !validateEmail(email.trim()),
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -25,4 +25,6 @@ const (
|
|||||||
DbTypeCockroachDB = "cockroachdb"
|
DbTypeCockroachDB = "cockroachdb"
|
||||||
// DbTypePlanetScaleDB is the planetscale database type
|
// DbTypePlanetScaleDB is the planetscale database type
|
||||||
DbTypePlanetScaleDB = "planetscale"
|
DbTypePlanetScaleDB = "planetscale"
|
||||||
|
// DbTypeDynamoDB is the Dynamo database type
|
||||||
|
DbTypeDynamoDB = "dynamodb"
|
||||||
)
|
)
|
||||||
|
@@ -21,6 +21,12 @@ const (
|
|||||||
EnvKeyDatabaseType = "DATABASE_TYPE"
|
EnvKeyDatabaseType = "DATABASE_TYPE"
|
||||||
// EnvKeyDatabaseURL key for env variable DATABASE_URL
|
// EnvKeyDatabaseURL key for env variable DATABASE_URL
|
||||||
EnvKeyDatabaseURL = "DATABASE_URL"
|
EnvKeyDatabaseURL = "DATABASE_URL"
|
||||||
|
// EnvAwsRegion key for env variable AWS REGION
|
||||||
|
EnvAwsRegion = "AWS_REGION"
|
||||||
|
// EnvAwsAccessKeyID key for env variable AWS_ACCESS_KEY_ID
|
||||||
|
EnvAwsAccessKeyID = "AWS_ACCESS_KEY_ID"
|
||||||
|
// EnvAwsAccessKey key for env variable AWS_SECRET_ACCESS_KEY
|
||||||
|
EnvAwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
|
||||||
// EnvKeyDatabaseName key for env variable DATABASE_NAME
|
// EnvKeyDatabaseName key for env variable DATABASE_NAME
|
||||||
EnvKeyDatabaseName = "DATABASE_NAME"
|
EnvKeyDatabaseName = "DATABASE_NAME"
|
||||||
// EnvKeyDatabaseUsername key for env variable DATABASE_USERNAME
|
// EnvKeyDatabaseUsername key for env variable DATABASE_USERNAME
|
||||||
@@ -45,6 +51,8 @@ const (
|
|||||||
EnvKeySmtpUsername = "SMTP_USERNAME"
|
EnvKeySmtpUsername = "SMTP_USERNAME"
|
||||||
// EnvKeySmtpPassword key for env variable SMTP_PASSWORD
|
// EnvKeySmtpPassword key for env variable SMTP_PASSWORD
|
||||||
EnvKeySmtpPassword = "SMTP_PASSWORD"
|
EnvKeySmtpPassword = "SMTP_PASSWORD"
|
||||||
|
// EnvKeySmtpLocalName key for env variable SMTP_LOCAL_NAME
|
||||||
|
EnvKeySmtpLocalName = "SMTP_LOCAL_NAME"
|
||||||
// EnvKeySenderEmail key for env variable SENDER_EMAIL
|
// EnvKeySenderEmail key for env variable SENDER_EMAIL
|
||||||
EnvKeySenderEmail = "SENDER_EMAIL"
|
EnvKeySenderEmail = "SENDER_EMAIL"
|
||||||
// EnvKeyIsEmailServiceEnabled key for env variable IS_EMAIL_SERVICE_ENABLED
|
// EnvKeyIsEmailServiceEnabled key for env variable IS_EMAIL_SERVICE_ENABLED
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/authorizerdev/authorizer/server/db/providers"
|
"github.com/authorizerdev/authorizer/server/db/providers"
|
||||||
"github.com/authorizerdev/authorizer/server/db/providers/arangodb"
|
"github.com/authorizerdev/authorizer/server/db/providers/arangodb"
|
||||||
"github.com/authorizerdev/authorizer/server/db/providers/cassandradb"
|
"github.com/authorizerdev/authorizer/server/db/providers/cassandradb"
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/providers/dynamodb"
|
||||||
"github.com/authorizerdev/authorizer/server/db/providers/mongodb"
|
"github.com/authorizerdev/authorizer/server/db/providers/mongodb"
|
||||||
"github.com/authorizerdev/authorizer/server/db/providers/sql"
|
"github.com/authorizerdev/authorizer/server/db/providers/sql"
|
||||||
"github.com/authorizerdev/authorizer/server/memorystore"
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
||||||
@@ -20,10 +21,11 @@ func InitDB() error {
|
|||||||
|
|
||||||
envs := memorystore.RequiredEnvStoreObj.GetRequiredEnv()
|
envs := memorystore.RequiredEnvStoreObj.GetRequiredEnv()
|
||||||
|
|
||||||
isSQL := envs.DatabaseType != constants.DbTypeArangodb && envs.DatabaseType != constants.DbTypeMongodb && envs.DatabaseType != constants.DbTypeCassandraDB && envs.DatabaseType != constants.DbTypeScyllaDB
|
isSQL := envs.DatabaseType != constants.DbTypeArangodb && envs.DatabaseType != constants.DbTypeMongodb && envs.DatabaseType != constants.DbTypeCassandraDB && envs.DatabaseType != constants.DbTypeScyllaDB && envs.DatabaseType != constants.DbTypeDynamoDB
|
||||||
isArangoDB := envs.DatabaseType == constants.DbTypeArangodb
|
isArangoDB := envs.DatabaseType == constants.DbTypeArangodb
|
||||||
isMongoDB := envs.DatabaseType == constants.DbTypeMongodb
|
isMongoDB := envs.DatabaseType == constants.DbTypeMongodb
|
||||||
isCassandra := envs.DatabaseType == constants.DbTypeCassandraDB || envs.DatabaseType == constants.DbTypeScyllaDB
|
isCassandra := envs.DatabaseType == constants.DbTypeCassandraDB || envs.DatabaseType == constants.DbTypeScyllaDB
|
||||||
|
isDynamoDB := envs.DatabaseType == constants.DbTypeDynamoDB
|
||||||
|
|
||||||
if isSQL {
|
if isSQL {
|
||||||
log.Info("Initializing SQL Driver for: ", envs.DatabaseType)
|
log.Info("Initializing SQL Driver for: ", envs.DatabaseType)
|
||||||
@@ -61,5 +63,14 @@ func InitDB() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isDynamoDB {
|
||||||
|
log.Info("Initializing DynamoDB Driver for: ", envs.DatabaseType)
|
||||||
|
Provider, err = dynamodb.NewProvider()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to initialize DynamoDB driver: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -9,14 +9,14 @@ import (
|
|||||||
|
|
||||||
// EmailTemplate model for database
|
// EmailTemplate model for database
|
||||||
type EmailTemplate struct {
|
type EmailTemplate struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name"`
|
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name" dynamo:"event_name" index:"event_name,hash"`
|
||||||
Subject string `gorm:"type:text" json:"subject" bson:"subject" cql:"subject"`
|
Subject string `json:"subject" bson:"subject" cql:"subject" dynamo:"subject"`
|
||||||
Template string `gorm:"type:text" json:"template" bson:"template" cql:"template"`
|
Template string `json:"template" bson:"template" cql:"template" dynamo:"template"`
|
||||||
Design string `gorm:"type:text" json:"design" bson:"design" cql:"design"`
|
Design string `json:"design" bson:"design" cql:"design" dynamo:"design"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsAPIEmailTemplate to return email template as graphql response object
|
// AsAPIEmailTemplate to return email template as graphql response object
|
||||||
|
@@ -4,10 +4,10 @@ package models
|
|||||||
|
|
||||||
// Env model for db
|
// Env model for db
|
||||||
type Env struct {
|
type Env struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
EnvData string `gorm:"type:text" json:"env" bson:"env" cql:"env"`
|
EnvData string `json:"env" bson:"env" cql:"env" dynamo:"env"`
|
||||||
Hash string `gorm:"type:text" json:"hash" bson:"hash" cql:"hash"`
|
Hash string `json:"hash" bson:"hash" cql:"hash" dynamo:"hash"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
}
|
}
|
||||||
|
@@ -2,11 +2,15 @@ package models
|
|||||||
|
|
||||||
// OTP model for database
|
// OTP model for database
|
||||||
type OTP struct {
|
type OTP struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
Email string `gorm:"unique" json:"email" bson:"email" cql:"email"`
|
Email string `gorm:"unique" json:"email" bson:"email" cql:"email" dynamo:"email" index:"email,hash"`
|
||||||
Otp string `json:"otp" bson:"otp" cql:"otp"`
|
Otp string `json:"otp" bson:"otp" cql:"otp" dynamo:"otp"`
|
||||||
ExpiresAt int64 `json:"expires_at" bson:"expires_at" cql:"expires_at"`
|
ExpiresAt int64 `json:"expires_at" bson:"expires_at" cql:"expires_at" dynamo:"expires_at"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Paging struct {
|
||||||
|
ID string `json:"id,omitempty" dynamo:"id,hash"`
|
||||||
}
|
}
|
||||||
|
@@ -4,11 +4,11 @@ package models
|
|||||||
|
|
||||||
// Session model for db
|
// Session model for db
|
||||||
type Session struct {
|
type Session struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
UserID string `gorm:"type:char(36)" json:"user_id" bson:"user_id" cql:"user_id"`
|
UserID string `gorm:"type:char(36)" json:"user_id" bson:"user_id" cql:"user_id" dynamo:"user_id" index:"user_id,hash"`
|
||||||
UserAgent string `json:"user_agent" bson:"user_agent" cql:"user_agent"`
|
UserAgent string `json:"user_agent" bson:"user_agent" cql:"user_agent" dynamo:"user_agent"`
|
||||||
IP string `json:"ip" bson:"ip" cql:"ip"`
|
IP string `json:"ip" bson:"ip" cql:"ip" dynamo:"ip"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
}
|
}
|
||||||
|
@@ -12,27 +12,27 @@ import (
|
|||||||
|
|
||||||
// User model for db
|
// User model for db
|
||||||
type User struct {
|
type User struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
|
|
||||||
Email string `gorm:"unique" json:"email" bson:"email" cql:"email"`
|
Email string `gorm:"unique" json:"email" bson:"email" cql:"email" dynamo:"email" index:"email,hash"`
|
||||||
EmailVerifiedAt *int64 `json:"email_verified_at" bson:"email_verified_at" cql:"email_verified_at"`
|
EmailVerifiedAt *int64 `json:"email_verified_at" bson:"email_verified_at" cql:"email_verified_at" dynamo:"email_verified_at"`
|
||||||
Password *string `gorm:"type:text" json:"password" bson:"password" cql:"password"`
|
Password *string `json:"password" bson:"password" cql:"password" dynamo:"password"`
|
||||||
SignupMethods string `json:"signup_methods" bson:"signup_methods" cql:"signup_methods"`
|
SignupMethods string `json:"signup_methods" bson:"signup_methods" cql:"signup_methods" dynamo:"signup_methods"`
|
||||||
GivenName *string `json:"given_name" bson:"given_name" cql:"given_name"`
|
GivenName *string `json:"given_name" bson:"given_name" cql:"given_name" dynamo:"given_name"`
|
||||||
FamilyName *string `json:"family_name" bson:"family_name" cql:"family_name"`
|
FamilyName *string `json:"family_name" bson:"family_name" cql:"family_name" dynamo:"family_name"`
|
||||||
MiddleName *string `json:"middle_name" bson:"middle_name" cql:"middle_name"`
|
MiddleName *string `json:"middle_name" bson:"middle_name" cql:"middle_name" dynamo:"middle_name"`
|
||||||
Nickname *string `json:"nickname" bson:"nickname" cql:"nickname"`
|
Nickname *string `json:"nickname" bson:"nickname" cql:"nickname" dynamo:"nickname"`
|
||||||
Gender *string `json:"gender" bson:"gender" cql:"gender"`
|
Gender *string `json:"gender" bson:"gender" cql:"gender" dynamo:"gender"`
|
||||||
Birthdate *string `json:"birthdate" bson:"birthdate" cql:"birthdate"`
|
Birthdate *string `json:"birthdate" bson:"birthdate" cql:"birthdate" dynamo:"birthdate"`
|
||||||
PhoneNumber *string `gorm:"unique" json:"phone_number" bson:"phone_number" cql:"phone_number"`
|
PhoneNumber *string `gorm:"unique" json:"phone_number" bson:"phone_number" cql:"phone_number" dynamo:"phone_number"`
|
||||||
PhoneNumberVerifiedAt *int64 `json:"phone_number_verified_at" bson:"phone_number_verified_at" cql:"phone_number_verified_at"`
|
PhoneNumberVerifiedAt *int64 `json:"phone_number_verified_at" bson:"phone_number_verified_at" cql:"phone_number_verified_at" dynamo:"phone_number_verified_at"`
|
||||||
Picture *string `gorm:"type:text" json:"picture" bson:"picture" cql:"picture"`
|
Picture *string `json:"picture" bson:"picture" cql:"picture" dynamo:"picture"`
|
||||||
Roles string `json:"roles" bson:"roles" cql:"roles"`
|
Roles string `json:"roles" bson:"roles" cql:"roles" dynamo:"roles"`
|
||||||
RevokedTimestamp *int64 `json:"revoked_timestamp" bson:"revoked_timestamp" cql:"revoked_timestamp"`
|
RevokedTimestamp *int64 `json:"revoked_timestamp" bson:"revoked_timestamp" cql:"revoked_timestamp" dynamo:"revoked_timestamp"`
|
||||||
IsMultiFactorAuthEnabled *bool `json:"is_multi_factor_auth_enabled" bson:"is_multi_factor_auth_enabled" cql:"is_multi_factor_auth_enabled"`
|
IsMultiFactorAuthEnabled *bool `json:"is_multi_factor_auth_enabled" bson:"is_multi_factor_auth_enabled" cql:"is_multi_factor_auth_enabled" dynamo:"is_multi_factor_auth_enabled"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) AsAPIUser() *model.User {
|
func (user *User) AsAPIUser() *model.User {
|
||||||
|
@@ -11,16 +11,16 @@ import (
|
|||||||
|
|
||||||
// VerificationRequest model for db
|
// VerificationRequest model for db
|
||||||
type VerificationRequest struct {
|
type VerificationRequest struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
Token string `gorm:"type:text" json:"token" bson:"token" cql:"jwt_token"` // token is reserved keyword in cassandra
|
Token string `json:"token" bson:"token" cql:"jwt_token" dynamo:"token" index:"token,hash"`
|
||||||
Identifier string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(64)" json:"identifier" bson:"identifier" cql:"identifier"`
|
Identifier string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(64)" json:"identifier" bson:"identifier" cql:"identifier" dynamo:"identifier"`
|
||||||
ExpiresAt int64 `json:"expires_at" bson:"expires_at" cql:"expires_at"`
|
ExpiresAt int64 `json:"expires_at" bson:"expires_at" cql:"expires_at" dynamo:"expires_at"`
|
||||||
Email string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(256)" json:"email" bson:"email" cql:"email"`
|
Email string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(256)" json:"email" bson:"email" cql:"email" dynamo:"email"`
|
||||||
Nonce string `gorm:"type:text" json:"nonce" bson:"nonce" cql:"nonce"`
|
Nonce string `json:"nonce" bson:"nonce" cql:"nonce" dynamo:"nonce"`
|
||||||
RedirectURI string `gorm:"type:text" json:"redirect_uri" bson:"redirect_uri" cql:"redirect_uri"`
|
RedirectURI string `json:"redirect_uri" bson:"redirect_uri" cql:"redirect_uri" dynamo:"redirect_uri"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VerificationRequest) AsAPIVerificationRequest() *model.VerificationRequest {
|
func (v *VerificationRequest) AsAPIVerificationRequest() *model.VerificationRequest {
|
||||||
|
@@ -12,14 +12,14 @@ import (
|
|||||||
|
|
||||||
// Webhook model for db
|
// Webhook model for db
|
||||||
type Webhook struct {
|
type Webhook struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name"`
|
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name" dynamo:"event_name" index:"event_name,hash"`
|
||||||
EndPoint string `gorm:"type:text" json:"endpoint" bson:"endpoint" cql:"endpoint"`
|
EndPoint string `json:"endpoint" bson:"endpoint" cql:"endpoint" dynamo:"endpoint"`
|
||||||
Headers string `gorm:"type:text" json:"headers" bson:"headers" cql:"headers"`
|
Headers string `json:"headers" bson:"headers" cql:"headers" dynamo:"headers"`
|
||||||
Enabled bool `json:"enabled" bson:"enabled" cql:"enabled"`
|
Enabled bool `json:"enabled" bson:"enabled" cql:"enabled" dynamo:"enabled"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsAPIWebhook to return webhook as graphql response object
|
// AsAPIWebhook to return webhook as graphql response object
|
||||||
|
@@ -11,14 +11,14 @@ import (
|
|||||||
|
|
||||||
// WebhookLog model for db
|
// WebhookLog model for db
|
||||||
type WebhookLog struct {
|
type WebhookLog struct {
|
||||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty"` // for arangodb
|
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||||
HttpStatus int64 `json:"http_status" bson:"http_status" cql:"http_status"`
|
HttpStatus int64 `json:"http_status" bson:"http_status" cql:"http_status" dynamo:"http_status"`
|
||||||
Response string `gorm:"type:text" json:"response" bson:"response" cql:"response"`
|
Response string `json:"response" bson:"response" cql:"response" dynamo:"response"`
|
||||||
Request string `gorm:"type:text" json:"request" bson:"request" cql:"request"`
|
Request string `json:"request" bson:"request" cql:"request" dynamo:"request"`
|
||||||
WebhookID string `gorm:"type:char(36)" json:"webhook_id" bson:"webhook_id" cql:"webhook_id"`
|
WebhookID string `gorm:"type:char(36)" json:"webhook_id" bson:"webhook_id" cql:"webhook_id" dynamo:"webhook_id" index:"webhook_id,hash"`
|
||||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsAPIWebhookLog to return webhook log as graphql response object
|
// AsAPIWebhookLog to return webhook log as graphql response object
|
||||||
|
121
server/db/providers/dynamodb/email_template.go
Normal file
121
server/db/providers/dynamodb/email_template.go
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddEmailTemplate to add EmailTemplate
|
||||||
|
func (p *provider) AddEmailTemplate(ctx context.Context, emailTemplate models.EmailTemplate) (*model.EmailTemplate, error) {
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
if emailTemplate.ID == "" {
|
||||||
|
emailTemplate.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
emailTemplate.Key = emailTemplate.ID
|
||||||
|
emailTemplate.CreatedAt = time.Now().Unix()
|
||||||
|
emailTemplate.UpdatedAt = time.Now().Unix()
|
||||||
|
err := collection.Put(emailTemplate).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEmailTemplate to update EmailTemplate
|
||||||
|
func (p *provider) UpdateEmailTemplate(ctx context.Context, emailTemplate models.EmailTemplate) (*model.EmailTemplate, error) {
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
emailTemplate.UpdatedAt = time.Now().Unix()
|
||||||
|
err := UpdateByHashKey(collection, "id", emailTemplate.ID, emailTemplate)
|
||||||
|
if err != nil {
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), err
|
||||||
|
}
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEmailTemplates to list EmailTemplate
|
||||||
|
func (p *provider) ListEmailTemplate(ctx context.Context, pagination model.Pagination) (*model.EmailTemplates, error) {
|
||||||
|
|
||||||
|
var emailTemplate models.EmailTemplate
|
||||||
|
var iter dynamo.PagingIter
|
||||||
|
var lastEval dynamo.PagingKey
|
||||||
|
var iteration int64 = 0
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
emailTemplates := []*model.EmailTemplate{}
|
||||||
|
paginationClone := pagination
|
||||||
|
scanner := collection.Scan()
|
||||||
|
count, err := scanner.Count()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for (paginationClone.Offset + paginationClone.Limit) > iteration {
|
||||||
|
iter = scanner.StartFrom(lastEval).Limit(paginationClone.Limit).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &emailTemplate) {
|
||||||
|
if paginationClone.Offset == iteration {
|
||||||
|
emailTemplates = append(emailTemplates, emailTemplate.AsAPIEmailTemplate())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastEval = iter.LastEvaluatedKey()
|
||||||
|
iteration += paginationClone.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationClone.Total = count
|
||||||
|
|
||||||
|
return &model.EmailTemplates{
|
||||||
|
Pagination: &paginationClone,
|
||||||
|
EmailTemplates: emailTemplates,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEmailTemplateByID to get EmailTemplate by id
|
||||||
|
func (p *provider) GetEmailTemplateByID(ctx context.Context, emailTemplateID string) (*model.EmailTemplate, error) {
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
var emailTemplate models.EmailTemplate
|
||||||
|
err := collection.Get("id", emailTemplateID).OneWithContext(ctx, &emailTemplate)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEmailTemplateByEventName to get EmailTemplate by event_name
|
||||||
|
func (p *provider) GetEmailTemplateByEventName(ctx context.Context, eventName string) (*model.EmailTemplate, error) {
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
var emailTemplates []models.EmailTemplate
|
||||||
|
var emailTemplate models.EmailTemplate
|
||||||
|
|
||||||
|
err := collection.Scan().Index("event_name").Filter("'event_name' = ?", eventName).Limit(1).AllWithContext(ctx, &emailTemplates)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(emailTemplates) > 0 {
|
||||||
|
emailTemplate = emailTemplates[0]
|
||||||
|
return emailTemplate.AsAPIEmailTemplate(), nil
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("no record found")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteEmailTemplate to delete EmailTemplate
|
||||||
|
func (p *provider) DeleteEmailTemplate(ctx context.Context, emailTemplate *model.EmailTemplate) error {
|
||||||
|
collection := p.db.Table(models.Collections.EmailTemplate)
|
||||||
|
err := collection.Delete("id", emailTemplate.ID).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
72
server/db/providers/dynamodb/env.go
Normal file
72
server/db/providers/dynamodb/env.go
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddEnv to save environment information in database
|
||||||
|
func (p *provider) AddEnv(ctx context.Context, env models.Env) (models.Env, error) {
|
||||||
|
collection := p.db.Table(models.Collections.Env)
|
||||||
|
|
||||||
|
if env.ID == "" {
|
||||||
|
env.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
env.Key = env.ID
|
||||||
|
|
||||||
|
env.CreatedAt = time.Now().Unix()
|
||||||
|
env.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
err := collection.Put(env).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return env, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return env, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEnv to update environment information in database
|
||||||
|
func (p *provider) UpdateEnv(ctx context.Context, env models.Env) (models.Env, error) {
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.Env)
|
||||||
|
env.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
err := UpdateByHashKey(collection, "id", env.ID, env)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return env, err
|
||||||
|
}
|
||||||
|
return env, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnv to get environment information from database
|
||||||
|
func (p *provider) GetEnv(ctx context.Context) (models.Env, error) {
|
||||||
|
var env models.Env
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.Env)
|
||||||
|
// As there is no Findone supported.
|
||||||
|
iter := collection.Scan().Limit(1).Iter()
|
||||||
|
|
||||||
|
for iter.NextWithContext(ctx, &env) {
|
||||||
|
if env.ID == "" {
|
||||||
|
return env, errors.New("no documets found")
|
||||||
|
} else {
|
||||||
|
return env, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := iter.Err()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return env, fmt.Errorf("config not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return env, nil
|
||||||
|
}
|
80
server/db/providers/dynamodb/otp.go
Normal file
80
server/db/providers/dynamodb/otp.go
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UpsertOTP to add or update otp
|
||||||
|
func (p *provider) UpsertOTP(ctx context.Context, otpParam *models.OTP) (*models.OTP, error) {
|
||||||
|
otp, _ := p.GetOTPByEmail(ctx, otpParam.Email)
|
||||||
|
shouldCreate := false
|
||||||
|
if otp == nil {
|
||||||
|
id := uuid.NewString()
|
||||||
|
otp = &models.OTP{
|
||||||
|
ID: id,
|
||||||
|
Key: id,
|
||||||
|
Otp: otpParam.Otp,
|
||||||
|
Email: otpParam.Email,
|
||||||
|
ExpiresAt: otpParam.ExpiresAt,
|
||||||
|
CreatedAt: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
shouldCreate = true
|
||||||
|
} else {
|
||||||
|
otp.Otp = otpParam.Otp
|
||||||
|
otp.ExpiresAt = otpParam.ExpiresAt
|
||||||
|
}
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.OTP)
|
||||||
|
otp.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if shouldCreate {
|
||||||
|
err = collection.Put(otp).RunWithContext(ctx)
|
||||||
|
} else {
|
||||||
|
err = UpdateByHashKey(collection, "id", otp.ID, otp)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return otp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOTPByEmail to get otp for a given email address
|
||||||
|
func (p *provider) GetOTPByEmail(ctx context.Context, emailAddress string) (*models.OTP, error) {
|
||||||
|
var otps []models.OTP
|
||||||
|
var otp models.OTP
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.OTP)
|
||||||
|
|
||||||
|
err := collection.Scan().Index("email").Filter("'email' = ?", emailAddress).Limit(1).AllWithContext(ctx, &otps)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(otps) > 0 {
|
||||||
|
otp = otps[0]
|
||||||
|
return &otp, nil
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("no docuemnt found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOTP to delete otp
|
||||||
|
func (p *provider) DeleteOTP(ctx context.Context, otp *models.OTP) error {
|
||||||
|
collection := p.db.Table(models.Collections.OTP)
|
||||||
|
|
||||||
|
if otp.ID != "" {
|
||||||
|
err := collection.Delete("id", otp.ID).RunWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
61
server/db/providers/dynamodb/provider.go
Normal file
61
server/db/providers/dynamodb/provider.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
||||||
|
)
|
||||||
|
|
||||||
|
type provider struct {
|
||||||
|
db *dynamo.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProvider returns a new Dynamo provider
|
||||||
|
func NewProvider() (*provider, error) {
|
||||||
|
dbURL := memorystore.RequiredEnvStoreObj.GetRequiredEnv().DatabaseURL
|
||||||
|
awsRegion := memorystore.RequiredEnvStoreObj.GetRequiredEnv().AwsRegion
|
||||||
|
awsAccessKeyID := memorystore.RequiredEnvStoreObj.GetRequiredEnv().AwsAccessKeyID
|
||||||
|
awsSecretAccessKey := memorystore.RequiredEnvStoreObj.GetRequiredEnv().AwsSecretAccessKey
|
||||||
|
|
||||||
|
config := aws.Config{
|
||||||
|
MaxRetries: aws.Int(3),
|
||||||
|
CredentialsChainVerboseErrors: aws.Bool(true), // for full error logs
|
||||||
|
}
|
||||||
|
|
||||||
|
if awsRegion != "" {
|
||||||
|
config.Region = aws.String(awsRegion)
|
||||||
|
}
|
||||||
|
|
||||||
|
// custom awsAccessKeyID, awsSecretAccessKey took first priority, if not then fetch config from aws credentials
|
||||||
|
if awsAccessKeyID != "" && awsSecretAccessKey != "" {
|
||||||
|
config.Credentials = credentials.NewStaticCredentials(awsAccessKeyID, awsSecretAccessKey, "")
|
||||||
|
} else if dbURL != "" {
|
||||||
|
// static config in case of testing or local-setup
|
||||||
|
config.Credentials = credentials.NewStaticCredentials("key", "key", "")
|
||||||
|
config.Endpoint = aws.String(dbURL)
|
||||||
|
} else {
|
||||||
|
log.Debugf("%s or %s or %s not found. Trying to load default credentials from aws config", constants.EnvAwsRegion, constants.EnvAwsAccessKeyID, constants.EnvAwsSecretAccessKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
session := session.Must(session.NewSession(&config))
|
||||||
|
db := dynamo.New(session)
|
||||||
|
|
||||||
|
db.CreateTable(models.Collections.User, models.User{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.Session, models.Session{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.EmailTemplate, models.EmailTemplate{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.Env, models.Env{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.OTP, models.OTP{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.VerificationRequest, models.VerificationRequest{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.Webhook, models.Webhook{}).Wait()
|
||||||
|
db.CreateTable(models.Collections.WebhookLog, models.WebhookLog{}).Wait()
|
||||||
|
|
||||||
|
return &provider{
|
||||||
|
db: db,
|
||||||
|
}, nil
|
||||||
|
}
|
28
server/db/providers/dynamodb/session.go
Normal file
28
server/db/providers/dynamodb/session.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddSession to save session information in database
|
||||||
|
func (p *provider) AddSession(ctx context.Context, session models.Session) error {
|
||||||
|
collection := p.db.Table(models.Collections.Session)
|
||||||
|
|
||||||
|
if session.ID == "" {
|
||||||
|
session.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
session.CreatedAt = time.Now().Unix()
|
||||||
|
session.UpdatedAt = time.Now().Unix()
|
||||||
|
err := collection.Put(session).RunWithContext(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSession to delete session information from database
|
||||||
|
func (p *provider) DeleteSession(ctx context.Context, userId string) error {
|
||||||
|
return nil
|
||||||
|
}
|
46
server/db/providers/dynamodb/shared.go
Normal file
46
server/db/providers/dynamodb/shared.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// As updpate all item not supported so set manually via Set and SetNullable for empty field
|
||||||
|
func UpdateByHashKey(table dynamo.Table, hashKey string, hashValue string, item interface{}) error {
|
||||||
|
existingValue, err := dynamo.MarshalItem(item)
|
||||||
|
var i interface{}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nullableValue, err := dynamodbattribute.MarshalMap(item)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
u := table.Update(hashKey, hashValue)
|
||||||
|
for k, v := range existingValue {
|
||||||
|
if k == hashKey {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
u = u.Set(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range nullableValue {
|
||||||
|
if k == hashKey {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dynamodbattribute.Unmarshal(v, &i)
|
||||||
|
if i == nil {
|
||||||
|
u = u.SetNullable(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = u.Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
195
server/db/providers/dynamodb/user.go
Normal file
195
server/db/providers/dynamodb/user.go
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
"github.com/authorizerdev/authorizer/server/memorystore"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddUser to save user information in database
|
||||||
|
func (p *provider) AddUser(ctx context.Context, user models.User) (models.User, error) {
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
|
||||||
|
if user.ID == "" {
|
||||||
|
user.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Roles == "" {
|
||||||
|
defaultRoles, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyDefaultRoles)
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
user.Roles = defaultRoles
|
||||||
|
}
|
||||||
|
|
||||||
|
user.CreatedAt = time.Now().Unix()
|
||||||
|
user.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
err := collection.Put(user).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUser to update user information in database
|
||||||
|
func (p *provider) UpdateUser(ctx context.Context, user models.User) (models.User, error) {
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
|
||||||
|
if user.ID != "" {
|
||||||
|
|
||||||
|
user.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
err := UpdateByHashKey(collection, "id", user.ID, user)
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return user, err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUser to delete user information from database
|
||||||
|
func (p *provider) DeleteUser(ctx context.Context, user models.User) error {
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
sessionCollection := p.db.Table(models.Collections.Session)
|
||||||
|
|
||||||
|
if user.ID != "" {
|
||||||
|
err := collection.Delete("id", user.ID).Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = sessionCollection.Batch("id").Write().Delete(dynamo.Keys{"user_id", user.ID}).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUsers to get list of users from database
|
||||||
|
func (p *provider) ListUsers(ctx context.Context, pagination model.Pagination) (*model.Users, error) {
|
||||||
|
var user models.User
|
||||||
|
var lastEval dynamo.PagingKey
|
||||||
|
var iter dynamo.PagingIter
|
||||||
|
var iteration int64 = 0
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
users := []*model.User{}
|
||||||
|
|
||||||
|
paginationClone := pagination
|
||||||
|
scanner := collection.Scan()
|
||||||
|
count, err := scanner.Count()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for (paginationClone.Offset + paginationClone.Limit) > iteration {
|
||||||
|
iter = scanner.StartFrom(lastEval).Limit(paginationClone.Limit).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &user) {
|
||||||
|
if paginationClone.Offset == iteration {
|
||||||
|
users = append(users, user.AsAPIUser())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastEval = iter.LastEvaluatedKey()
|
||||||
|
iteration += paginationClone.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
err = iter.Err()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationClone.Total = count
|
||||||
|
|
||||||
|
return &model.Users{
|
||||||
|
Pagination: &paginationClone,
|
||||||
|
Users: users,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByEmail to get user information from database using email address
|
||||||
|
func (p *provider) GetUserByEmail(ctx context.Context, email string) (models.User, error) {
|
||||||
|
var users []models.User
|
||||||
|
var user models.User
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
err := collection.Scan().Index("email").Filter("'email' = ?", email).AllWithContext(ctx, &users)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(users) > 0 {
|
||||||
|
user = users[0]
|
||||||
|
return user, nil
|
||||||
|
} else {
|
||||||
|
return user, errors.New("no record found")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserByID to get user information from database using user ID
|
||||||
|
func (p *provider) GetUserByID(ctx context.Context, id string) (models.User, error) {
|
||||||
|
collection := p.db.Table(models.Collections.User)
|
||||||
|
var user models.User
|
||||||
|
err := collection.Get("id", id).OneWithContext(ctx, &user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if user.Email == "" {
|
||||||
|
return user, errors.New("no documets found")
|
||||||
|
} else {
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUsers to update multiple users, with parameters of user IDs slice
|
||||||
|
// If ids set to nil / empty all the users will be updated
|
||||||
|
func (p *provider) UpdateUsers(ctx context.Context, data map[string]interface{}, ids []string) error {
|
||||||
|
// set updated_at time for all users
|
||||||
|
userCollection := p.db.Table(models.Collections.User)
|
||||||
|
var allUsers []models.User
|
||||||
|
var res int64 = 0
|
||||||
|
var err error
|
||||||
|
if len(ids) > 0 {
|
||||||
|
for _, v := range ids {
|
||||||
|
err = UpdateByHashKey(userCollection, "id", v, data)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// as there is no facility to update all doc - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.UpdateData.html
|
||||||
|
userCollection.Scan().All(&allUsers)
|
||||||
|
|
||||||
|
for _, user := range allUsers {
|
||||||
|
err = UpdateByHashKey(userCollection, "id", user.ID, data)
|
||||||
|
if err == nil {
|
||||||
|
res = res + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
log.Info("Updated users: ", res)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
116
server/db/providers/dynamodb/verification_requests.go
Normal file
116
server/db/providers/dynamodb/verification_requests.go
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddVerification to save verification request in database
|
||||||
|
func (p *provider) AddVerificationRequest(ctx context.Context, verificationRequest models.VerificationRequest) (models.VerificationRequest, error) {
|
||||||
|
collection := p.db.Table(models.Collections.VerificationRequest)
|
||||||
|
|
||||||
|
if verificationRequest.ID == "" {
|
||||||
|
verificationRequest.ID = uuid.New().String()
|
||||||
|
verificationRequest.CreatedAt = time.Now().Unix()
|
||||||
|
verificationRequest.UpdatedAt = time.Now().Unix()
|
||||||
|
err := collection.Put(verificationRequest).RunWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return verificationRequest, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return verificationRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVerificationRequestByToken to get verification request from database using token
|
||||||
|
func (p *provider) GetVerificationRequestByToken(ctx context.Context, token string) (models.VerificationRequest, error) {
|
||||||
|
collection := p.db.Table(models.Collections.VerificationRequest)
|
||||||
|
var verificationRequest models.VerificationRequest
|
||||||
|
|
||||||
|
iter := collection.Scan().Filter("'token' = ?", token).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &verificationRequest) {
|
||||||
|
return verificationRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return verificationRequest, err
|
||||||
|
}
|
||||||
|
return verificationRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVerificationRequestByEmail to get verification request by email from database
|
||||||
|
func (p *provider) GetVerificationRequestByEmail(ctx context.Context, email string, identifier string) (models.VerificationRequest, error) {
|
||||||
|
var verificationRequest models.VerificationRequest
|
||||||
|
collection := p.db.Table(models.Collections.VerificationRequest)
|
||||||
|
iter := collection.Scan().Filter("'email' = ?", email).Filter("'identifier' = ?", identifier).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &verificationRequest) {
|
||||||
|
return verificationRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return verificationRequest, err
|
||||||
|
}
|
||||||
|
return verificationRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVerificationRequests to get list of verification requests from database
|
||||||
|
func (p *provider) ListVerificationRequests(ctx context.Context, pagination model.Pagination) (*model.VerificationRequests, error) {
|
||||||
|
verificationRequests := []*model.VerificationRequest{}
|
||||||
|
var verificationRequest models.VerificationRequest
|
||||||
|
var lastEval dynamo.PagingKey
|
||||||
|
var iter dynamo.PagingIter
|
||||||
|
var iteration int64 = 0
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.VerificationRequest)
|
||||||
|
paginationClone := pagination
|
||||||
|
|
||||||
|
scanner := collection.Scan()
|
||||||
|
count, err := scanner.Count()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for (paginationClone.Offset + paginationClone.Limit) > iteration {
|
||||||
|
iter = scanner.StartFrom(lastEval).Limit(paginationClone.Limit).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &verificationRequest) {
|
||||||
|
if paginationClone.Offset == iteration {
|
||||||
|
verificationRequests = append(verificationRequests, verificationRequest.AsAPIVerificationRequest())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
lastEval = iter.LastEvaluatedKey()
|
||||||
|
iteration += paginationClone.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationClone.Total = count
|
||||||
|
|
||||||
|
return &model.VerificationRequests{
|
||||||
|
VerificationRequests: verificationRequests,
|
||||||
|
Pagination: &paginationClone,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteVerificationRequest to delete verification request from database
|
||||||
|
func (p *provider) DeleteVerificationRequest(ctx context.Context, verificationRequest models.VerificationRequest) error {
|
||||||
|
collection := p.db.Table(models.Collections.VerificationRequest)
|
||||||
|
|
||||||
|
if verificationRequest.ID != "" {
|
||||||
|
err := collection.Delete("id", verificationRequest.ID).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
148
server/db/providers/dynamodb/webhook.go
Normal file
148
server/db/providers/dynamodb/webhook.go
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddWebhook to add webhook
|
||||||
|
func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*model.Webhook, error) {
|
||||||
|
collection := p.db.Table(models.Collections.Webhook)
|
||||||
|
|
||||||
|
if webhook.ID == "" {
|
||||||
|
webhook.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
webhook.Key = webhook.ID
|
||||||
|
webhook.CreatedAt = time.Now().Unix()
|
||||||
|
webhook.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
|
err := collection.Put(webhook).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return webhook.AsAPIWebhook(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateWebhook to update webhook
|
||||||
|
func (p *provider) UpdateWebhook(ctx context.Context, webhook models.Webhook) (*model.Webhook, error) {
|
||||||
|
collection := p.db.Table(models.Collections.Webhook)
|
||||||
|
|
||||||
|
webhook.UpdatedAt = time.Now().Unix()
|
||||||
|
err := UpdateByHashKey(collection, "id", webhook.ID, webhook)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return webhook.AsAPIWebhook(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWebhooks to list webhook
|
||||||
|
func (p *provider) ListWebhook(ctx context.Context, pagination model.Pagination) (*model.Webhooks, error) {
|
||||||
|
webhooks := []*model.Webhook{}
|
||||||
|
var webhook models.Webhook
|
||||||
|
var lastEval dynamo.PagingKey
|
||||||
|
var iter dynamo.PagingIter
|
||||||
|
var iteration int64 = 0
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.Webhook)
|
||||||
|
paginationClone := pagination
|
||||||
|
scanner := collection.Scan()
|
||||||
|
count, err := scanner.Count()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for (paginationClone.Offset + paginationClone.Limit) > iteration {
|
||||||
|
iter = scanner.StartFrom(lastEval).Limit(paginationClone.Limit).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &webhook) {
|
||||||
|
if paginationClone.Offset == iteration {
|
||||||
|
webhooks = append(webhooks, webhook.AsAPIWebhook())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
lastEval = iter.LastEvaluatedKey()
|
||||||
|
iteration += paginationClone.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationClone.Total = count
|
||||||
|
|
||||||
|
return &model.Webhooks{
|
||||||
|
Pagination: &paginationClone,
|
||||||
|
Webhooks: webhooks,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWebhookByID to get webhook by id
|
||||||
|
func (p *provider) GetWebhookByID(ctx context.Context, webhookID string) (*model.Webhook, error) {
|
||||||
|
collection := p.db.Table(models.Collections.Webhook)
|
||||||
|
var webhook models.Webhook
|
||||||
|
|
||||||
|
err := collection.Get("id", webhookID).OneWithContext(ctx, &webhook)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if webhook.ID == "" {
|
||||||
|
return webhook.AsAPIWebhook(), errors.New("no documets found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return webhook.AsAPIWebhook(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWebhookByEventName to get webhook by event_name
|
||||||
|
func (p *provider) GetWebhookByEventName(ctx context.Context, eventName string) (*model.Webhook, error) {
|
||||||
|
var webhook models.Webhook
|
||||||
|
collection := p.db.Table(models.Collections.Webhook)
|
||||||
|
|
||||||
|
iter := collection.Scan().Index("event_name").Filter("'event_name' = ?", eventName).Iter()
|
||||||
|
|
||||||
|
for iter.NextWithContext(ctx, &webhook) {
|
||||||
|
return webhook.AsAPIWebhook(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := iter.Err()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return webhook.AsAPIWebhook(), err
|
||||||
|
}
|
||||||
|
return webhook.AsAPIWebhook(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteWebhook to delete webhook
|
||||||
|
func (p *provider) DeleteWebhook(ctx context.Context, webhook *model.Webhook) error {
|
||||||
|
// Also delete webhook logs for given webhook id
|
||||||
|
if webhook.ID != "" {
|
||||||
|
webhookCollection := p.db.Table(models.Collections.Webhook)
|
||||||
|
pagination := model.Pagination{}
|
||||||
|
webhookLogCollection := p.db.Table(models.Collections.WebhookLog)
|
||||||
|
err := webhookCollection.Delete("id", webhook.ID).RunWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
webhookLogs, errIs := p.ListWebhookLogs(ctx, pagination, webhook.ID)
|
||||||
|
|
||||||
|
for _, webhookLog := range webhookLogs.WebhookLogs {
|
||||||
|
err = webhookLogCollection.Delete("id", webhookLog.ID).RunWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errIs != nil {
|
||||||
|
return errIs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
78
server/db/providers/dynamodb/webhook_log.go
Normal file
78
server/db/providers/dynamodb/webhook_log.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/guregu/dynamo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddWebhookLog to add webhook log
|
||||||
|
func (p *provider) AddWebhookLog(ctx context.Context, webhookLog models.WebhookLog) (*model.WebhookLog, error) {
|
||||||
|
collection := p.db.Table(models.Collections.WebhookLog)
|
||||||
|
|
||||||
|
if webhookLog.ID == "" {
|
||||||
|
webhookLog.ID = uuid.New().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
webhookLog.Key = webhookLog.ID
|
||||||
|
webhookLog.CreatedAt = time.Now().Unix()
|
||||||
|
webhookLog.UpdatedAt = time.Now().Unix()
|
||||||
|
err := collection.Put(webhookLog).RunWithContext(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return webhookLog.AsAPIWebhookLog(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWebhookLogs to list webhook logs
|
||||||
|
func (p *provider) ListWebhookLogs(ctx context.Context, pagination model.Pagination, webhookID string) (*model.WebhookLogs, error) {
|
||||||
|
webhookLogs := []*model.WebhookLog{}
|
||||||
|
var webhookLog models.WebhookLog
|
||||||
|
var lastEval dynamo.PagingKey
|
||||||
|
var iter dynamo.PagingIter
|
||||||
|
var iteration int64 = 0
|
||||||
|
var err error
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
collection := p.db.Table(models.Collections.WebhookLog)
|
||||||
|
paginationClone := pagination
|
||||||
|
scanner := collection.Scan()
|
||||||
|
|
||||||
|
if webhookID != "" {
|
||||||
|
iter = scanner.Index("webhook_id").Filter("'webhook_id' = ?", webhookID).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &webhookLog) {
|
||||||
|
webhookLogs = append(webhookLogs, webhookLog.AsAPIWebhookLog())
|
||||||
|
}
|
||||||
|
err = iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (paginationClone.Offset + paginationClone.Limit) > iteration {
|
||||||
|
iter = scanner.StartFrom(lastEval).Limit(paginationClone.Limit).Iter()
|
||||||
|
for iter.NextWithContext(ctx, &webhookLog) {
|
||||||
|
if paginationClone.Offset == iteration {
|
||||||
|
webhookLogs = append(webhookLogs, webhookLog.AsAPIWebhookLog())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = iter.Err()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
lastEval = iter.LastEvaluatedKey()
|
||||||
|
iteration += paginationClone.Limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationClone.Total = count
|
||||||
|
// paginationClone.Cursor = iter.LastEvaluatedKey()
|
||||||
|
return &model.WebhookLogs{
|
||||||
|
Pagination: &paginationClone,
|
||||||
|
WebhookLogs: webhookLogs,
|
||||||
|
}, nil
|
||||||
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
package sql
|
package sql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@@ -21,6 +22,16 @@ type provider struct {
|
|||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
phoneNumberIndexName = "UQ_phone_number"
|
||||||
|
phoneNumberColumnName = "phone_number"
|
||||||
|
)
|
||||||
|
|
||||||
|
type indexInfo struct {
|
||||||
|
IndexName string `json:"index_name"`
|
||||||
|
ColumnName string `json:"column_name"`
|
||||||
|
}
|
||||||
|
|
||||||
// NewProvider returns a new SQL provider
|
// NewProvider returns a new SQL provider
|
||||||
func NewProvider() (*provider, error) {
|
func NewProvider() (*provider, error) {
|
||||||
var sqlDB *gorm.DB
|
var sqlDB *gorm.DB
|
||||||
@@ -65,6 +76,32 @@ func NewProvider() (*provider, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unique constraint on phone number does not work with multiple null values for sqlserver
|
||||||
|
// for more information check https://stackoverflow.com/a/767702
|
||||||
|
if dbType == constants.DbTypeSqlserver {
|
||||||
|
var indexInfos []indexInfo
|
||||||
|
// remove index on phone number if present with different name
|
||||||
|
res := sqlDB.Raw("SELECT i.name AS index_name, i.type_desc AS index_algorithm, CASE i.is_unique WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS is_unique, ac.Name AS column_name FROM sys.tables AS t INNER JOIN sys.indexes AS i ON t.object_id = i.object_id INNER JOIN sys.index_columns AS ic ON ic.object_id = i.object_id AND ic.index_id = i.index_id INNER JOIN sys.all_columns AS ac ON ic.object_id = ac.object_id AND ic.column_id = ac.column_id WHERE t.name = 'authorizer_users' AND SCHEMA_NAME(t.schema_id) = 'dbo';").Scan(&indexInfos)
|
||||||
|
if res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, val := range indexInfos {
|
||||||
|
if val.ColumnName == phoneNumberColumnName && val.IndexName != phoneNumberIndexName {
|
||||||
|
// drop index & create new
|
||||||
|
if res := sqlDB.Exec(fmt.Sprintf(`ALTER TABLE authorizer_users DROP CONSTRAINT "%s";`, val.IndexName)); res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// create index
|
||||||
|
if res := sqlDB.Exec(fmt.Sprintf("CREATE UNIQUE NONCLUSTERED INDEX %s ON authorizer_users(phone_number) WHERE phone_number IS NOT NULL;", phoneNumberIndexName)); res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &provider{
|
return &provider{
|
||||||
db: sqlDB,
|
db: sqlDB,
|
||||||
}, nil
|
}, nil
|
||||||
|
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -126,6 +127,12 @@ func SendEmail(to []string, event string, data map[string]interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smtpLocalName, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeySmtpLocalName)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("Error while getting smtp localname from env variable: %v", err)
|
||||||
|
smtpLocalName = ""
|
||||||
|
}
|
||||||
|
|
||||||
isProd, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyIsProd)
|
isProd, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyIsProd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error while getting env variable: %v", err)
|
log.Errorf("Error while getting env variable: %v", err)
|
||||||
@@ -141,6 +148,11 @@ func SendEmail(to []string, event string, data map[string]interface{}) error {
|
|||||||
if !isProd {
|
if !isProd {
|
||||||
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.TrimSpace(smtpLocalName) != "" {
|
||||||
|
d.LocalName = smtpLocalName
|
||||||
|
}
|
||||||
|
|
||||||
if err := d.DialAndSend(m); err != nil {
|
if err := d.DialAndSend(m); err != nil {
|
||||||
log.Debug("SMTP Failed: ", err)
|
log.Debug("SMTP Failed: ", err)
|
||||||
return err
|
return err
|
||||||
|
32
server/env/env.go
vendored
32
server/env/env.go
vendored
@@ -55,6 +55,7 @@ func InitAllEnv() error {
|
|||||||
osSmtpPort := os.Getenv(constants.EnvKeySmtpPort)
|
osSmtpPort := os.Getenv(constants.EnvKeySmtpPort)
|
||||||
osSmtpUsername := os.Getenv(constants.EnvKeySmtpUsername)
|
osSmtpUsername := os.Getenv(constants.EnvKeySmtpUsername)
|
||||||
osSmtpPassword := os.Getenv(constants.EnvKeySmtpPassword)
|
osSmtpPassword := os.Getenv(constants.EnvKeySmtpPassword)
|
||||||
|
osSmtpLocalName := os.Getenv(constants.EnvKeySmtpLocalName)
|
||||||
osSenderEmail := os.Getenv(constants.EnvKeySenderEmail)
|
osSenderEmail := os.Getenv(constants.EnvKeySenderEmail)
|
||||||
osJwtType := os.Getenv(constants.EnvKeyJwtType)
|
osJwtType := os.Getenv(constants.EnvKeyJwtType)
|
||||||
osJwtSecret := os.Getenv(constants.EnvKeyJwtSecret)
|
osJwtSecret := os.Getenv(constants.EnvKeyJwtSecret)
|
||||||
@@ -77,6 +78,9 @@ func InitAllEnv() error {
|
|||||||
osResetPasswordURL := os.Getenv(constants.EnvKeyResetPasswordURL)
|
osResetPasswordURL := os.Getenv(constants.EnvKeyResetPasswordURL)
|
||||||
osOrganizationName := os.Getenv(constants.EnvKeyOrganizationName)
|
osOrganizationName := os.Getenv(constants.EnvKeyOrganizationName)
|
||||||
osOrganizationLogo := os.Getenv(constants.EnvKeyOrganizationLogo)
|
osOrganizationLogo := os.Getenv(constants.EnvKeyOrganizationLogo)
|
||||||
|
osAwsRegion := os.Getenv(constants.EnvAwsRegion)
|
||||||
|
osAwsAccessKey := os.Getenv(constants.EnvAwsAccessKeyID)
|
||||||
|
osAwsSecretKey := os.Getenv(constants.EnvAwsSecretAccessKey)
|
||||||
|
|
||||||
// os bool vars
|
// os bool vars
|
||||||
osAppCookieSecure := os.Getenv(constants.EnvKeyAppCookieSecure)
|
osAppCookieSecure := os.Getenv(constants.EnvKeyAppCookieSecure)
|
||||||
@@ -119,6 +123,27 @@ func InitAllEnv() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val, ok := envData[constants.EnvAwsRegion]; !ok || val == "" {
|
||||||
|
envData[constants.EnvAwsRegion] = osAwsRegion
|
||||||
|
}
|
||||||
|
if osAwsRegion != "" && envData[constants.EnvAwsRegion] != osAwsRegion {
|
||||||
|
envData[constants.EnvAwsRegion] = osAwsRegion
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, ok := envData[constants.EnvAwsAccessKeyID]; !ok || val == "" {
|
||||||
|
envData[constants.EnvAwsAccessKeyID] = osAwsAccessKey
|
||||||
|
}
|
||||||
|
if osAwsAccessKey != "" && envData[constants.EnvAwsAccessKeyID] != osAwsRegion {
|
||||||
|
envData[constants.EnvAwsAccessKeyID] = osAwsAccessKey
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, ok := envData[constants.EnvAwsSecretAccessKey]; !ok || val == "" {
|
||||||
|
envData[constants.EnvAwsSecretAccessKey] = osAwsSecretKey
|
||||||
|
}
|
||||||
|
if osAwsSecretKey != "" && envData[constants.EnvAwsSecretAccessKey] != osAwsRegion {
|
||||||
|
envData[constants.EnvAwsSecretAccessKey] = osAwsSecretKey
|
||||||
|
}
|
||||||
|
|
||||||
if val, ok := envData[constants.EnvKeyAppURL]; !ok || val == "" {
|
if val, ok := envData[constants.EnvKeyAppURL]; !ok || val == "" {
|
||||||
envData[constants.EnvKeyAppURL] = osAppURL
|
envData[constants.EnvKeyAppURL] = osAppURL
|
||||||
}
|
}
|
||||||
@@ -181,6 +206,13 @@ func InitAllEnv() error {
|
|||||||
envData[constants.EnvKeySmtpUsername] = osSmtpUsername
|
envData[constants.EnvKeySmtpUsername] = osSmtpUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val, ok := envData[constants.EnvKeySmtpLocalName]; !ok || val == "" {
|
||||||
|
envData[constants.EnvKeySmtpLocalName] = osSmtpLocalName
|
||||||
|
}
|
||||||
|
if osSmtpLocalName != "" && envData[constants.EnvKeySmtpLocalName] != osSmtpLocalName {
|
||||||
|
envData[constants.EnvKeySmtpLocalName] = osSmtpLocalName
|
||||||
|
}
|
||||||
|
|
||||||
if val, ok := envData[constants.EnvKeySmtpPassword]; !ok || val == "" {
|
if val, ok := envData[constants.EnvKeySmtpPassword]; !ok || val == "" {
|
||||||
envData[constants.EnvKeySmtpPassword] = osSmtpPassword
|
envData[constants.EnvKeySmtpPassword] = osSmtpPassword
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ go 1.16
|
|||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.17.20
|
github.com/99designs/gqlgen v0.17.20
|
||||||
github.com/arangodb/go-driver v1.2.1
|
github.com/arangodb/go-driver v1.2.1
|
||||||
|
github.com/aws/aws-sdk-go v1.44.109
|
||||||
github.com/coreos/go-oidc/v3 v3.1.0
|
github.com/coreos/go-oidc/v3 v3.1.0
|
||||||
github.com/gin-gonic/gin v1.8.1
|
github.com/gin-gonic/gin v1.8.1
|
||||||
github.com/go-playground/validator/v10 v10.11.1 // indirect
|
github.com/go-playground/validator/v10 v10.11.1 // indirect
|
||||||
@@ -14,6 +15,7 @@ require (
|
|||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
|
github.com/guregu/dynamo v1.16.0
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||||
|
@@ -49,10 +49,15 @@ github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2
|
|||||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||||
|
github.com/aws/aws-sdk-go v1.42.47/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc=
|
||||||
|
github.com/aws/aws-sdk-go v1.44.109 h1:+Na5JPeS0kiEHoBp5Umcuuf+IDqXqD0lXnM920E31YI=
|
||||||
|
github.com/aws/aws-sdk-go v1.44.109/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
|
||||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
|
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
|
||||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
|
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
|
||||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
@@ -118,8 +123,9 @@ github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
|
|||||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
github.com/gocql/gocql v1.2.0 h1:TZhsCd7fRuye4VyHr3WCvWwIQaZUmjsqnSIXK9FcVCE=
|
github.com/gocql/gocql v1.2.0 h1:TZhsCd7fRuye4VyHr3WCvWwIQaZUmjsqnSIXK9FcVCE=
|
||||||
github.com/gocql/gocql v1.2.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
github.com/gocql/gocql v1.2.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
|
||||||
|
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||||
@@ -185,6 +191,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
|
|||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/guregu/dynamo v1.16.0 h1:gmI8oi1VHwYQtq7+RPBeOiSssVLgxH/Az2t+NtDtL2c=
|
||||||
|
github.com/guregu/dynamo v1.16.0/go.mod h1:W2Gqcf3MtkrS+Q6fHPGAmRtT0Dyq+TGrqfqrUC9+R/c=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
@@ -247,6 +255,10 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
|
|||||||
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
|
github.com/jinzhu/now v1.1.3 h1:PlHq1bSCSZL9K0wUhbm2pGLoTWs2GwVhsP6emvGV/ZI=
|
||||||
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||||
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||||
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
@@ -480,6 +492,8 @@ golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b h1:uKO3Js8lXGjpjdc4J3rqs0/Ex5yDKUGfk43tTYWVLas=
|
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b h1:uKO3Js8lXGjpjdc4J3rqs0/Ex5yDKUGfk43tTYWVLas=
|
||||||
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
@@ -546,6 +560,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -555,6 +570,7 @@ golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
@@ -118,6 +118,7 @@ type ComplexityRoot struct {
|
|||||||
ResetPasswordURL func(childComplexity int) int
|
ResetPasswordURL func(childComplexity int) int
|
||||||
Roles func(childComplexity int) int
|
Roles func(childComplexity int) int
|
||||||
SMTPHost func(childComplexity int) int
|
SMTPHost func(childComplexity int) int
|
||||||
|
SMTPLocalName func(childComplexity int) int
|
||||||
SMTPPassword func(childComplexity int) int
|
SMTPPassword func(childComplexity int) int
|
||||||
SMTPPort func(childComplexity int) int
|
SMTPPort func(childComplexity int) int
|
||||||
SMTPUsername func(childComplexity int) int
|
SMTPUsername func(childComplexity int) int
|
||||||
@@ -245,6 +246,7 @@ type ComplexityRoot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ValidateJWTTokenResponse struct {
|
ValidateJWTTokenResponse struct {
|
||||||
|
Claims func(childComplexity int) int
|
||||||
IsValid func(childComplexity int) int
|
IsValid func(childComplexity int) int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,6 +807,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.Env.SMTPHost(childComplexity), true
|
return e.complexity.Env.SMTPHost(childComplexity), true
|
||||||
|
|
||||||
|
case "Env.SMTP_LOCAL_NAME":
|
||||||
|
if e.complexity.Env.SMTPLocalName == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.Env.SMTPLocalName(childComplexity), true
|
||||||
|
|
||||||
case "Env.SMTP_PASSWORD":
|
case "Env.SMTP_PASSWORD":
|
||||||
if e.complexity.Env.SMTPPassword == nil {
|
if e.complexity.Env.SMTPPassword == nil {
|
||||||
break
|
break
|
||||||
@@ -1638,6 +1647,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.Users.Users(childComplexity), true
|
return e.complexity.Users.Users(childComplexity), true
|
||||||
|
|
||||||
|
case "ValidateJWTTokenResponse.claims":
|
||||||
|
if e.complexity.ValidateJWTTokenResponse.Claims == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.ValidateJWTTokenResponse.Claims(childComplexity), true
|
||||||
|
|
||||||
case "ValidateJWTTokenResponse.is_valid":
|
case "ValidateJWTTokenResponse.is_valid":
|
||||||
if e.complexity.ValidateJWTTokenResponse.IsValid == nil {
|
if e.complexity.ValidateJWTTokenResponse.IsValid == nil {
|
||||||
break
|
break
|
||||||
@@ -2059,6 +2075,7 @@ type Env {
|
|||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
SMTP_USERNAME: String
|
SMTP_USERNAME: String
|
||||||
SMTP_PASSWORD: String
|
SMTP_PASSWORD: String
|
||||||
|
SMTP_LOCAL_NAME: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
@@ -2101,6 +2118,7 @@ type Env {
|
|||||||
|
|
||||||
type ValidateJWTTokenResponse {
|
type ValidateJWTTokenResponse {
|
||||||
is_valid: Boolean!
|
is_valid: Boolean!
|
||||||
|
claims: Map
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateJWTKeysResponse {
|
type GenerateJWTKeysResponse {
|
||||||
@@ -2168,6 +2186,7 @@ input UpdateEnvInput {
|
|||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
SMTP_USERNAME: String
|
SMTP_USERNAME: String
|
||||||
SMTP_PASSWORD: String
|
SMTP_PASSWORD: String
|
||||||
|
SMTP_LOCAL_NAME: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
@@ -4442,6 +4461,47 @@ func (ec *executionContext) fieldContext_Env_SMTP_PASSWORD(ctx context.Context,
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Env_SMTP_LOCAL_NAME(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
||||||
|
fc, err := ec.fieldContext_Env_SMTP_LOCAL_NAME(ctx, field)
|
||||||
|
if err != nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = graphql.Null
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
return obj.SMTPLocalName, 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) fieldContext_Env_SMTP_LOCAL_NAME(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "Env",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: false,
|
||||||
|
IsResolver: false,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return nil, errors.New("field of type String does not have child fields")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Env_SENDER_EMAIL(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Env_SENDER_EMAIL(ctx context.Context, field graphql.CollectedField, obj *model.Env) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_Env_SENDER_EMAIL(ctx, field)
|
fc, err := ec.fieldContext_Env_SENDER_EMAIL(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -9085,6 +9145,8 @@ func (ec *executionContext) fieldContext_Query_validate_jwt_token(ctx context.Co
|
|||||||
switch field.Name {
|
switch field.Name {
|
||||||
case "is_valid":
|
case "is_valid":
|
||||||
return ec.fieldContext_ValidateJWTTokenResponse_is_valid(ctx, field)
|
return ec.fieldContext_ValidateJWTTokenResponse_is_valid(ctx, field)
|
||||||
|
case "claims":
|
||||||
|
return ec.fieldContext_ValidateJWTTokenResponse_claims(ctx, field)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no field named %q was found under type ValidateJWTTokenResponse", field.Name)
|
return nil, fmt.Errorf("no field named %q was found under type ValidateJWTTokenResponse", field.Name)
|
||||||
},
|
},
|
||||||
@@ -9344,6 +9406,8 @@ func (ec *executionContext) fieldContext_Query__env(ctx context.Context, field g
|
|||||||
return ec.fieldContext_Env_SMTP_USERNAME(ctx, field)
|
return ec.fieldContext_Env_SMTP_USERNAME(ctx, field)
|
||||||
case "SMTP_PASSWORD":
|
case "SMTP_PASSWORD":
|
||||||
return ec.fieldContext_Env_SMTP_PASSWORD(ctx, field)
|
return ec.fieldContext_Env_SMTP_PASSWORD(ctx, field)
|
||||||
|
case "SMTP_LOCAL_NAME":
|
||||||
|
return ec.fieldContext_Env_SMTP_LOCAL_NAME(ctx, field)
|
||||||
case "SENDER_EMAIL":
|
case "SENDER_EMAIL":
|
||||||
return ec.fieldContext_Env_SENDER_EMAIL(ctx, field)
|
return ec.fieldContext_Env_SENDER_EMAIL(ctx, field)
|
||||||
case "JWT_TYPE":
|
case "JWT_TYPE":
|
||||||
@@ -10912,6 +10976,47 @@ func (ec *executionContext) fieldContext_ValidateJWTTokenResponse_is_valid(ctx c
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _ValidateJWTTokenResponse_claims(ctx context.Context, field graphql.CollectedField, obj *model.ValidateJWTTokenResponse) (ret graphql.Marshaler) {
|
||||||
|
fc, err := ec.fieldContext_ValidateJWTTokenResponse_claims(ctx, field)
|
||||||
|
if err != nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = graphql.Null
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
return obj.Claims, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
if resTmp == nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
res := resTmp.(map[string]interface{})
|
||||||
|
fc.Result = res
|
||||||
|
return ec.marshalOMap2map(ctx, field.Selections, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) fieldContext_ValidateJWTTokenResponse_claims(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
|
fc = &graphql.FieldContext{
|
||||||
|
Object: "ValidateJWTTokenResponse",
|
||||||
|
Field: field,
|
||||||
|
IsMethod: false,
|
||||||
|
IsResolver: false,
|
||||||
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
|
return nil, errors.New("field of type Map does not have child fields")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return fc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _VerificationRequest_id(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) {
|
func (ec *executionContext) _VerificationRequest_id(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) {
|
||||||
fc, err := ec.fieldContext_VerificationRequest_id(ctx, field)
|
fc, err := ec.fieldContext_VerificationRequest_id(ctx, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -14970,7 +15075,7 @@ func (ec *executionContext) unmarshalInputUpdateEnvInput(ctx context.Context, ob
|
|||||||
asMap[k] = v
|
asMap[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldsInOrder := [...]string{"ACCESS_TOKEN_EXPIRY_TIME", "ADMIN_SECRET", "CUSTOM_ACCESS_TOKEN_SCRIPT", "OLD_ADMIN_SECRET", "SMTP_HOST", "SMTP_PORT", "SMTP_USERNAME", "SMTP_PASSWORD", "SENDER_EMAIL", "JWT_TYPE", "JWT_SECRET", "JWT_PRIVATE_KEY", "JWT_PUBLIC_KEY", "ALLOWED_ORIGINS", "APP_URL", "RESET_PASSWORD_URL", "APP_COOKIE_SECURE", "ADMIN_COOKIE_SECURE", "DISABLE_EMAIL_VERIFICATION", "DISABLE_BASIC_AUTHENTICATION", "DISABLE_MAGIC_LINK_LOGIN", "DISABLE_LOGIN_PAGE", "DISABLE_SIGN_UP", "DISABLE_REDIS_FOR_ENV", "DISABLE_STRONG_PASSWORD", "DISABLE_MULTI_FACTOR_AUTHENTICATION", "ENFORCE_MULTI_FACTOR_AUTHENTICATION", "ROLES", "PROTECTED_ROLES", "DEFAULT_ROLES", "JWT_ROLE_CLAIM", "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "FACEBOOK_CLIENT_ID", "FACEBOOK_CLIENT_SECRET", "LINKEDIN_CLIENT_ID", "LINKEDIN_CLIENT_SECRET", "APPLE_CLIENT_ID", "APPLE_CLIENT_SECRET", "TWITTER_CLIENT_ID", "TWITTER_CLIENT_SECRET", "ORGANIZATION_NAME", "ORGANIZATION_LOGO"}
|
fieldsInOrder := [...]string{"ACCESS_TOKEN_EXPIRY_TIME", "ADMIN_SECRET", "CUSTOM_ACCESS_TOKEN_SCRIPT", "OLD_ADMIN_SECRET", "SMTP_HOST", "SMTP_PORT", "SMTP_USERNAME", "SMTP_PASSWORD", "SMTP_LOCAL_NAME", "SENDER_EMAIL", "JWT_TYPE", "JWT_SECRET", "JWT_PRIVATE_KEY", "JWT_PUBLIC_KEY", "ALLOWED_ORIGINS", "APP_URL", "RESET_PASSWORD_URL", "APP_COOKIE_SECURE", "ADMIN_COOKIE_SECURE", "DISABLE_EMAIL_VERIFICATION", "DISABLE_BASIC_AUTHENTICATION", "DISABLE_MAGIC_LINK_LOGIN", "DISABLE_LOGIN_PAGE", "DISABLE_SIGN_UP", "DISABLE_REDIS_FOR_ENV", "DISABLE_STRONG_PASSWORD", "DISABLE_MULTI_FACTOR_AUTHENTICATION", "ENFORCE_MULTI_FACTOR_AUTHENTICATION", "ROLES", "PROTECTED_ROLES", "DEFAULT_ROLES", "JWT_ROLE_CLAIM", "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "FACEBOOK_CLIENT_ID", "FACEBOOK_CLIENT_SECRET", "LINKEDIN_CLIENT_ID", "LINKEDIN_CLIENT_SECRET", "APPLE_CLIENT_ID", "APPLE_CLIENT_SECRET", "TWITTER_CLIENT_ID", "TWITTER_CLIENT_SECRET", "ORGANIZATION_NAME", "ORGANIZATION_LOGO"}
|
||||||
for _, k := range fieldsInOrder {
|
for _, k := range fieldsInOrder {
|
||||||
v, ok := asMap[k]
|
v, ok := asMap[k]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -15041,6 +15146,14 @@ func (ec *executionContext) unmarshalInputUpdateEnvInput(ctx context.Context, ob
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return it, err
|
return it, err
|
||||||
}
|
}
|
||||||
|
case "SMTP_LOCAL_NAME":
|
||||||
|
var err error
|
||||||
|
|
||||||
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SMTP_LOCAL_NAME"))
|
||||||
|
it.SMTPLocalName, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
return it, err
|
||||||
|
}
|
||||||
case "SENDER_EMAIL":
|
case "SENDER_EMAIL":
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -16026,6 +16139,10 @@ func (ec *executionContext) _Env(ctx context.Context, sel ast.SelectionSet, obj
|
|||||||
|
|
||||||
out.Values[i] = ec._Env_SMTP_PASSWORD(ctx, field, obj)
|
out.Values[i] = ec._Env_SMTP_PASSWORD(ctx, field, obj)
|
||||||
|
|
||||||
|
case "SMTP_LOCAL_NAME":
|
||||||
|
|
||||||
|
out.Values[i] = ec._Env_SMTP_LOCAL_NAME(ctx, field, obj)
|
||||||
|
|
||||||
case "SENDER_EMAIL":
|
case "SENDER_EMAIL":
|
||||||
|
|
||||||
out.Values[i] = ec._Env_SENDER_EMAIL(ctx, field, obj)
|
out.Values[i] = ec._Env_SENDER_EMAIL(ctx, field, obj)
|
||||||
@@ -17288,6 +17405,10 @@ func (ec *executionContext) _ValidateJWTTokenResponse(ctx context.Context, sel a
|
|||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
|
case "claims":
|
||||||
|
|
||||||
|
out.Values[i] = ec._ValidateJWTTokenResponse_claims(ctx, field, obj)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
|
@@ -74,6 +74,7 @@ type Env struct {
|
|||||||
SMTPPort *string `json:"SMTP_PORT"`
|
SMTPPort *string `json:"SMTP_PORT"`
|
||||||
SMTPUsername *string `json:"SMTP_USERNAME"`
|
SMTPUsername *string `json:"SMTP_USERNAME"`
|
||||||
SMTPPassword *string `json:"SMTP_PASSWORD"`
|
SMTPPassword *string `json:"SMTP_PASSWORD"`
|
||||||
|
SMTPLocalName *string `json:"SMTP_LOCAL_NAME"`
|
||||||
SenderEmail *string `json:"SENDER_EMAIL"`
|
SenderEmail *string `json:"SENDER_EMAIL"`
|
||||||
JwtType *string `json:"JWT_TYPE"`
|
JwtType *string `json:"JWT_TYPE"`
|
||||||
JwtSecret *string `json:"JWT_SECRET"`
|
JwtSecret *string `json:"JWT_SECRET"`
|
||||||
@@ -271,6 +272,7 @@ type UpdateEnvInput struct {
|
|||||||
SMTPPort *string `json:"SMTP_PORT"`
|
SMTPPort *string `json:"SMTP_PORT"`
|
||||||
SMTPUsername *string `json:"SMTP_USERNAME"`
|
SMTPUsername *string `json:"SMTP_USERNAME"`
|
||||||
SMTPPassword *string `json:"SMTP_PASSWORD"`
|
SMTPPassword *string `json:"SMTP_PASSWORD"`
|
||||||
|
SMTPLocalName *string `json:"SMTP_LOCAL_NAME"`
|
||||||
SenderEmail *string `json:"SENDER_EMAIL"`
|
SenderEmail *string `json:"SENDER_EMAIL"`
|
||||||
JwtType *string `json:"JWT_TYPE"`
|
JwtType *string `json:"JWT_TYPE"`
|
||||||
JwtSecret *string `json:"JWT_SECRET"`
|
JwtSecret *string `json:"JWT_SECRET"`
|
||||||
@@ -385,6 +387,7 @@ type ValidateJWTTokenInput struct {
|
|||||||
|
|
||||||
type ValidateJWTTokenResponse struct {
|
type ValidateJWTTokenResponse struct {
|
||||||
IsValid bool `json:"is_valid"`
|
IsValid bool `json:"is_valid"`
|
||||||
|
Claims map[string]interface{} `json:"claims"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerificationRequest struct {
|
type VerificationRequest struct {
|
||||||
|
@@ -110,6 +110,7 @@ type Env {
|
|||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
SMTP_USERNAME: String
|
SMTP_USERNAME: String
|
||||||
SMTP_PASSWORD: String
|
SMTP_PASSWORD: String
|
||||||
|
SMTP_LOCAL_NAME: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
@@ -152,6 +153,7 @@ type Env {
|
|||||||
|
|
||||||
type ValidateJWTTokenResponse {
|
type ValidateJWTTokenResponse {
|
||||||
is_valid: Boolean!
|
is_valid: Boolean!
|
||||||
|
claims: Map
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateJWTKeysResponse {
|
type GenerateJWTKeysResponse {
|
||||||
@@ -219,6 +221,7 @@ input UpdateEnvInput {
|
|||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
SMTP_USERNAME: String
|
SMTP_USERNAME: String
|
||||||
SMTP_PASSWORD: String
|
SMTP_PASSWORD: String
|
||||||
|
SMTP_LOCAL_NAME: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
|
@@ -30,7 +30,7 @@ func AppHandler() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect_uri := strings.TrimSpace(c.Query("redirect_uri"))
|
redirectURI := strings.TrimSpace(c.Query("redirect_uri"))
|
||||||
state := strings.TrimSpace(c.Query("state"))
|
state := strings.TrimSpace(c.Query("state"))
|
||||||
scopeString := strings.TrimSpace(c.Query("scope"))
|
scopeString := strings.TrimSpace(c.Query("scope"))
|
||||||
|
|
||||||
@@ -41,11 +41,11 @@ func AppHandler() gin.HandlerFunc {
|
|||||||
scope = strings.Split(scopeString, " ")
|
scope = strings.Split(scopeString, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if redirect_uri == "" {
|
if redirectURI == "" {
|
||||||
redirect_uri = hostname + "/app"
|
redirectURI = hostname + "/app"
|
||||||
} else {
|
} else {
|
||||||
// validate redirect url with allowed origins
|
// validate redirect url with allowed origins
|
||||||
if !validators.IsValidOrigin(redirect_uri) {
|
if !validators.IsValidOrigin(redirectURI) {
|
||||||
log.Debug("Invalid redirect_uri")
|
log.Debug("Invalid redirect_uri")
|
||||||
c.JSON(400, gin.H{"error": "invalid redirect url"})
|
c.JSON(400, gin.H{"error": "invalid redirect url"})
|
||||||
return
|
return
|
||||||
@@ -75,7 +75,7 @@ func AppHandler() gin.HandlerFunc {
|
|||||||
c.HTML(http.StatusOK, "app.tmpl", gin.H{
|
c.HTML(http.StatusOK, "app.tmpl", gin.H{
|
||||||
"data": map[string]interface{}{
|
"data": map[string]interface{}{
|
||||||
"authorizerURL": hostname,
|
"authorizerURL": hostname,
|
||||||
"redirectURL": redirect_uri,
|
"redirectURL": redirectURI,
|
||||||
"scope": scope,
|
"scope": scope,
|
||||||
"state": state,
|
"state": state,
|
||||||
"organizationName": orgName,
|
"organizationName": orgName,
|
||||||
|
@@ -17,14 +17,14 @@ func OpenIDConfigurationHandler() gin.HandlerFunc {
|
|||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"issuer": issuer,
|
"issuer": issuer,
|
||||||
"authorization_endpoint": issuer + "/authorize",
|
"authorization_endpoint": issuer + "/authorize",
|
||||||
"token_endpoint": issuer + "/token",
|
"token_endpoint": issuer + "/oauth/token",
|
||||||
"userinfo_endpoint": issuer + "/userinfo",
|
"userinfo_endpoint": issuer + "/userinfo",
|
||||||
"jwks_uri": issuer + "/.well-known/jwks.json",
|
"jwks_uri": issuer + "/.well-known/jwks.json",
|
||||||
"response_types_supported": []string{"code", "token", "id_token", "code token", "code id_token", "token id_token", "code token id_token"},
|
"response_types_supported": []string{"code", "token", "id_token"},
|
||||||
"scopes_supported": []string{"openid", "email", "profile", "email_verified", "given_name", "family_name", "nick_name", "picture"},
|
"scopes_supported": []string{"openid", "email", "profile", "email_verified", "given_name", "family_name", "nick_name", "picture"},
|
||||||
"response_modes_supported": []string{"query", "fragment", "form_post"},
|
"response_modes_supported": []string{"query", "fragment", "form_post", "web_message"},
|
||||||
"id_token_signing_alg_values_supported": []string{jwtType},
|
"id_token_signing_alg_values_supported": []string{jwtType},
|
||||||
"claims_supported": []string{"aud", "exp", "iss", "iat", "sub", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "picture", "email", "email_verified", "roles", "gender", "birthdate", "phone_number", "phone_number_verified"},
|
"claims_supported": []string{"aud", "exp", "iss", "iat", "sub", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "picture", "email", "email_verified", "roles", "role", "gender", "birthdate", "phone_number", "phone_number_verified", "nonce", "updated_at", "created_at", "revoked_timestamp", "login_method", "signup_methods", "token_type"},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -154,6 +154,7 @@ func TokenHandler() gin.HandlerFunc {
|
|||||||
"error": "invalid_refresh_token",
|
"error": "invalid_refresh_token",
|
||||||
"error_description": "The refresh token is invalid",
|
"error_description": "The refresh token is invalid",
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
claims, err := token.ValidateRefreshToken(gc, refreshToken)
|
claims, err := token.ValidateRefreshToken(gc, refreshToken)
|
||||||
@@ -163,6 +164,7 @@ func TokenHandler() gin.HandlerFunc {
|
|||||||
"error": "unauthorized",
|
"error": "unauthorized",
|
||||||
"error_description": err.Error(),
|
"error_description": err.Error(),
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
userID = claims["sub"].(string)
|
userID = claims["sub"].(string)
|
||||||
loginMethod := claims["login_method"]
|
loginMethod := claims["login_method"]
|
||||||
|
@@ -15,12 +15,15 @@ import (
|
|||||||
"github.com/authorizerdev/authorizer/server/routes"
|
"github.com/authorizerdev/authorizer/server/routes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// VERSION is used to define the version of authorizer from build tags
|
||||||
var VERSION string
|
var VERSION string
|
||||||
|
|
||||||
|
// LogUTCFormatter hels in setting UTC time format for the logs
|
||||||
type LogUTCFormatter struct {
|
type LogUTCFormatter struct {
|
||||||
log.Formatter
|
log.Formatter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format helps fomratting time to UTC
|
||||||
func (u LogUTCFormatter) Format(e *log.Entry) ([]byte, error) {
|
func (u LogUTCFormatter) Format(e *log.Entry) ([]byte, error) {
|
||||||
e.Time = e.Time.UTC()
|
e.Time = e.Time.UTC()
|
||||||
return u.Formatter.Format(e)
|
return u.Formatter.Format(e)
|
||||||
|
@@ -57,7 +57,7 @@ func InitMemStore() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redisURL := requiredEnvs.RedisURL
|
redisURL := requiredEnvs.RedisURL
|
||||||
if redisURL != "" && !requiredEnvs.disableRedisForEnv {
|
if redisURL != "" && !requiredEnvs.DisableRedisForEnv {
|
||||||
log.Info("Initializing Redis memory store")
|
log.Info("Initializing Redis memory store")
|
||||||
Provider, err = redis.NewRedisProvider(redisURL)
|
Provider, err = redis.NewRedisProvider(redisURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -27,7 +27,11 @@ type RequiredEnv struct {
|
|||||||
DatabaseCertKey string `json:"DATABASE_CERT_KEY"`
|
DatabaseCertKey string `json:"DATABASE_CERT_KEY"`
|
||||||
DatabaseCACert string `json:"DATABASE_CA_CERT"`
|
DatabaseCACert string `json:"DATABASE_CA_CERT"`
|
||||||
RedisURL string `json:"REDIS_URL"`
|
RedisURL string `json:"REDIS_URL"`
|
||||||
disableRedisForEnv bool `json:"DISABLE_REDIS_FOR_ENV"`
|
DisableRedisForEnv bool `json:"DISABLE_REDIS_FOR_ENV"`
|
||||||
|
// AWS Related Envs
|
||||||
|
AwsRegion string `json:"AWS_REGION"`
|
||||||
|
AwsAccessKeyID string `json:"AWS_ACCESS_KEY_ID"`
|
||||||
|
AwsSecretAccessKey string `json:"AWS_SECRET_ACCESS_KEY"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredEnvObj is a simple in-memory store for sessions.
|
// RequiredEnvObj is a simple in-memory store for sessions.
|
||||||
@@ -53,7 +57,8 @@ func (r *RequiredEnvStore) SetRequiredEnv(requiredEnv RequiredEnv) {
|
|||||||
|
|
||||||
var RequiredEnvStoreObj *RequiredEnvStore
|
var RequiredEnvStoreObj *RequiredEnvStore
|
||||||
|
|
||||||
// InitRequiredEnv to initialize EnvData and through error if required env are not present
|
// InitRequiredEnv to initialize EnvData and throw error if required env are not present
|
||||||
|
// This includes env that only configurable via env vars and not the ui
|
||||||
func InitRequiredEnv() error {
|
func InitRequiredEnv() error {
|
||||||
envPath := os.Getenv(constants.EnvKeyEnvPath)
|
envPath := os.Getenv(constants.EnvKeyEnvPath)
|
||||||
|
|
||||||
@@ -85,6 +90,9 @@ func InitRequiredEnv() error {
|
|||||||
dbCACert := os.Getenv(constants.EnvKeyDatabaseCACert)
|
dbCACert := os.Getenv(constants.EnvKeyDatabaseCACert)
|
||||||
redisURL := os.Getenv(constants.EnvKeyRedisURL)
|
redisURL := os.Getenv(constants.EnvKeyRedisURL)
|
||||||
disableRedisForEnv := os.Getenv(constants.EnvKeyDisableRedisForEnv) == "true"
|
disableRedisForEnv := os.Getenv(constants.EnvKeyDisableRedisForEnv) == "true"
|
||||||
|
awsRegion := os.Getenv(constants.EnvAwsRegion)
|
||||||
|
awsAccessKeyID := os.Getenv(constants.EnvAwsAccessKeyID)
|
||||||
|
awsSecretAccessKey := os.Getenv(constants.EnvAwsSecretAccessKey)
|
||||||
|
|
||||||
if strings.TrimSpace(redisURL) == "" {
|
if strings.TrimSpace(redisURL) == "" {
|
||||||
if cli.ARG_REDIS_URL != nil && *cli.ARG_REDIS_URL != "" {
|
if cli.ARG_REDIS_URL != nil && *cli.ARG_REDIS_URL != "" {
|
||||||
@@ -113,7 +121,8 @@ func InitRequiredEnv() error {
|
|||||||
dbURL = strings.TrimSpace(*cli.ARG_DB_URL)
|
dbURL = strings.TrimSpace(*cli.ARG_DB_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dbURL == "" && dbPort == "" && dbHost == "" && dbUsername == "" && dbPassword == "" {
|
// In dynamoDB these field are not always mandatory
|
||||||
|
if dbType != constants.DbTypeDynamoDB && dbURL == "" && dbPort == "" && dbHost == "" && dbUsername == "" && dbPassword == "" {
|
||||||
log.Debug("DATABASE_URL is not set")
|
log.Debug("DATABASE_URL is not set")
|
||||||
return errors.New("invalid database url. DATABASE_URL is required")
|
return errors.New("invalid database url. DATABASE_URL is required")
|
||||||
}
|
}
|
||||||
@@ -138,7 +147,10 @@ func InitRequiredEnv() error {
|
|||||||
DatabaseCertKey: dbCertKey,
|
DatabaseCertKey: dbCertKey,
|
||||||
DatabaseCACert: dbCACert,
|
DatabaseCACert: dbCACert,
|
||||||
RedisURL: redisURL,
|
RedisURL: redisURL,
|
||||||
disableRedisForEnv: disableRedisForEnv,
|
DisableRedisForEnv: disableRedisForEnv,
|
||||||
|
AwsRegion: awsRegion,
|
||||||
|
AwsAccessKeyID: awsAccessKeyID,
|
||||||
|
AwsSecretAccessKey: awsSecretAccessKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
RequiredEnvStoreObj = &RequiredEnvStore{
|
RequiredEnvStoreObj = &RequiredEnvStore{
|
||||||
|
@@ -89,6 +89,9 @@ func EnvResolver(ctx context.Context) (*model.Env, error) {
|
|||||||
if val, ok := store[constants.EnvKeySenderEmail]; ok {
|
if val, ok := store[constants.EnvKeySenderEmail]; ok {
|
||||||
res.SenderEmail = refs.NewStringRef(val.(string))
|
res.SenderEmail = refs.NewStringRef(val.(string))
|
||||||
}
|
}
|
||||||
|
if val, ok := store[constants.EnvKeySmtpLocalName]; ok {
|
||||||
|
res.SMTPLocalName = refs.NewStringRef(val.(string))
|
||||||
|
}
|
||||||
if val, ok := store[constants.EnvKeyJwtType]; ok {
|
if val, ok := store[constants.EnvKeyJwtType]; ok {
|
||||||
res.JwtType = refs.NewStringRef(val.(string))
|
res.JwtType = refs.NewStringRef(val.(string))
|
||||||
}
|
}
|
||||||
|
@@ -62,12 +62,21 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
|||||||
log.Debug("Failed to generate nonce: ", err)
|
log.Debug("Failed to generate nonce: ", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
redirectURL := parsers.GetAppURL(gc)
|
|
||||||
|
redirectURI := ""
|
||||||
|
// give higher preference to params redirect uri
|
||||||
if strings.TrimSpace(refs.StringValue(params.RedirectURI)) != "" {
|
if strings.TrimSpace(refs.StringValue(params.RedirectURI)) != "" {
|
||||||
redirectURL = refs.StringValue(params.RedirectURI)
|
redirectURI = refs.StringValue(params.RedirectURI)
|
||||||
|
} else {
|
||||||
|
redirectURI, err = memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyResetPasswordURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("ResetPasswordURL not found using default app url: ", err)
|
||||||
|
redirectURI = hostname + "/app/reset-password"
|
||||||
|
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyResetPasswordURL, redirectURI)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURL)
|
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to create verification token", err)
|
log.Debug("Failed to create verification token", err)
|
||||||
return res, err
|
return res, err
|
||||||
@@ -78,7 +87,7 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
|||||||
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
||||||
Email: params.Email,
|
Email: params.Email,
|
||||||
Nonce: nonceHash,
|
Nonce: nonceHash,
|
||||||
RedirectURI: redirectURL,
|
RedirectURI: redirectURI,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to add verification request", err)
|
log.Debug("Failed to add verification request", err)
|
||||||
@@ -89,7 +98,7 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
|||||||
go email.SendEmail([]string{params.Email}, constants.VerificationTypeForgotPassword, map[string]interface{}{
|
go email.SendEmail([]string{params.Email}, constants.VerificationTypeForgotPassword, map[string]interface{}{
|
||||||
"user": user.ToMap(),
|
"user": user.ToMap(),
|
||||||
"organization": utils.GetOrganization(),
|
"organization": utils.GetOrganization(),
|
||||||
"verification_url": utils.GetForgotPasswordURL(verificationToken, hostname),
|
"verification_url": utils.GetForgotPasswordURL(verificationToken, redirectURI),
|
||||||
})
|
})
|
||||||
|
|
||||||
res = &model.Response{
|
res = &model.Response{
|
||||||
|
@@ -93,5 +93,6 @@ func ValidateJwtTokenResolver(ctx context.Context, params model.ValidateJWTToken
|
|||||||
}
|
}
|
||||||
return &model.ValidateJWTTokenResponse{
|
return &model.ValidateJWTTokenResponse{
|
||||||
IsValid: true,
|
IsValid: true,
|
||||||
|
Claims: claims,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ func TestResolvers(t *testing.T) {
|
|||||||
constants.DbTypeArangodb: "http://localhost:8529",
|
constants.DbTypeArangodb: "http://localhost:8529",
|
||||||
constants.DbTypeMongodb: "mongodb://localhost:27017",
|
constants.DbTypeMongodb: "mongodb://localhost:27017",
|
||||||
constants.DbTypeScyllaDB: "127.0.0.1:9042",
|
constants.DbTypeScyllaDB: "127.0.0.1:9042",
|
||||||
|
constants.DbTypeDynamoDB: "http://0.0.0.0:8000",
|
||||||
}
|
}
|
||||||
|
|
||||||
testDBs := strings.Split(os.Getenv("TEST_DBS"), ",")
|
testDBs := strings.Split(os.Getenv("TEST_DBS"), ",")
|
||||||
@@ -51,25 +52,33 @@ func TestResolvers(t *testing.T) {
|
|||||||
os.Setenv(constants.EnvKeyDatabaseURL, dbURL)
|
os.Setenv(constants.EnvKeyDatabaseURL, dbURL)
|
||||||
os.Setenv(constants.EnvKeyDatabaseType, dbType)
|
os.Setenv(constants.EnvKeyDatabaseType, dbType)
|
||||||
os.Setenv(constants.EnvKeyDatabaseName, testDb)
|
os.Setenv(constants.EnvKeyDatabaseName, testDb)
|
||||||
|
|
||||||
|
if dbType == constants.DbTypeDynamoDB {
|
||||||
|
memorystore.Provider.UpdateEnvVariable(constants.EnvAwsRegion, "ap-south-1")
|
||||||
|
os.Setenv(constants.EnvAwsRegion, "ap-south-1")
|
||||||
|
}
|
||||||
|
|
||||||
memorystore.InitRequiredEnv()
|
memorystore.InitRequiredEnv()
|
||||||
|
|
||||||
err := db.InitDB()
|
err := db.InitDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error initializing database: %s", err.Error())
|
t.Logf("Error initializing database: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean the persisted config for test to use fresh config
|
// clean the persisted config for test to use fresh config
|
||||||
envData, err := db.Provider.GetEnv(ctx)
|
envData, err := db.Provider.GetEnv(ctx)
|
||||||
if err == nil {
|
if err == nil && envData.ID != "" {
|
||||||
envData.EnvData = ""
|
envData.EnvData = ""
|
||||||
_, err = db.Provider.UpdateEnv(ctx, envData)
|
_, err = db.Provider.UpdateEnv(ctx, envData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error updating env: %s", err.Error())
|
t.Logf("Error updating env: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
} else if err != nil {
|
||||||
|
t.Logf("Error getting env: %s", err.Error())
|
||||||
}
|
}
|
||||||
err = env.PersistEnv()
|
err = env.PersistEnv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error persisting env: %s", err.Error())
|
t.Logf("Error persisting env: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyEnv, "test")
|
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyEnv, "test")
|
||||||
|
@@ -84,7 +84,7 @@ func testSetup() TestSetup {
|
|||||||
testData := TestData{
|
testData := TestData{
|
||||||
Email: fmt.Sprintf("%d_authorizer_tester@yopmail.com", time.Now().Unix()),
|
Email: fmt.Sprintf("%d_authorizer_tester@yopmail.com", time.Now().Unix()),
|
||||||
Password: "Test@123",
|
Password: "Test@123",
|
||||||
WebhookEndpoint: "https://62cbc6738042b16aa7c22df2.mockapi.io/api/v1/webhook",
|
WebhookEndpoint: "https://62f93101e05644803533cf36.mockapi.io/authorizer/webhook",
|
||||||
TestWebhookEventTypes: []string{constants.UserAccessEnabledWebhookEvent, constants.UserAccessRevokedWebhookEvent, constants.UserCreatedWebhookEvent, constants.UserDeletedWebhookEvent, constants.UserLoginWebhookEvent, constants.UserSignUpWebhookEvent},
|
TestWebhookEventTypes: []string{constants.UserAccessEnabledWebhookEvent, constants.UserAccessRevokedWebhookEvent, constants.UserCreatedWebhookEvent, constants.UserDeletedWebhookEvent, constants.UserLoginWebhookEvent, constants.UserSignUpWebhookEvent},
|
||||||
TestEmailTemplateEventTypes: []string{constants.VerificationTypeBasicAuthSignup, constants.VerificationTypeForgotPassword, constants.VerificationTypeMagicLinkLogin, constants.VerificationTypeUpdateEmail},
|
TestEmailTemplateEventTypes: []string{constants.VerificationTypeBasicAuthSignup, constants.VerificationTypeForgotPassword, constants.VerificationTypeMagicLinkLogin, constants.VerificationTypeUpdateEmail},
|
||||||
}
|
}
|
||||||
|
@@ -93,5 +93,6 @@ func validateJwtTokenTest(t *testing.T, s TestSetup) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, res.IsValid)
|
assert.True(t, res.IsValid)
|
||||||
|
assert.Equal(t, user.Email, res.Claims["email"])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -81,17 +81,8 @@ func GetOrganization() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetForgotPasswordURL to get url for given token and hostname
|
// GetForgotPasswordURL to get url for given token and hostname
|
||||||
func GetForgotPasswordURL(token, hostname string) string {
|
func GetForgotPasswordURL(token, redirectURI string) string {
|
||||||
resetPasswordUrl, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyResetPasswordURL)
|
verificationURL := redirectURI + "?token=" + token
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if resetPasswordUrl == "" {
|
|
||||||
if err := memorystore.Provider.UpdateEnvVariable(constants.EnvKeyResetPasswordURL, hostname+"/app/reset-password"); err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
verificationURL := resetPasswordUrl + "?token=" + token
|
|
||||||
return verificationURL
|
return verificationURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user