Compare commits

..

25 Commits

Author SHA1 Message Date
Lakhan Samani
25cb9a831b feat: add cursor for pagination 2022-09-26 23:50:24 +05:30
Lakhan Samani
19e2153379 Update README.md 2022-09-15 12:24:47 +05:30
Lakhan Samani
221009bf0a Merge pull request #229 from ruessej/main
feat: Add a option to disable httpOnly cookies
2022-09-15 11:22:27 +05:30
ruessej
6085c2d535 Fix incorrect type 2022-09-14 12:24:19 +02:00
Jerebtw
8e0c5e4380 Make the default value true 2022-09-14 11:56:48 +02:00
Lakhan Samani
21b70e4b26 Merge pull request #230 from authorizerdev/fix/github-oauth-scopes
fix: scope for github auth
2022-09-14 11:46:46 +05:30
Lakhan Samani
993693884d fix: scope for github auth 2022-09-14 11:45:38 +05:30
Lakhan Samani
ed849fa6f6 Merge branch 'main' of https://github.com/authorizerdev/authorizer 2022-09-14 10:44:09 +05:30
Lakhan Samani
aec1f5df53 fix: github endpoint to get user emails 2022-09-14 10:44:01 +05:30
ruessej
195bd1bc6a Add a option to disable httpOnly cookies 2022-09-12 14:37:42 +02:00
Lakhan Samani
45b4c41bca Merge pull request #228 from Deep-Codes/main 2022-09-10 11:40:11 +05:30
Deepankar
63d486821e fix: lint 2022-09-10 11:39:01 +05:30
Deep-Codes
4b56afdc98 fix(type): __authorizer__ on window 2022-09-10 11:23:20 +05:30
Lakhan Samani
6455ff956a fix: remove varible log 2022-09-10 10:52:56 +05:30
Lakhan Samani
3898e43fff feat: add button to jwt config as json 2022-09-10 10:50:15 +05:30
Lakhan Samani
2c305e5bde Update README.md 2022-09-09 10:24:30 +05:30
Lakhan Samani
b8fd08e576 Update README.md 2022-09-09 09:29:27 +05:30
Lakhan Samani
6dafa45051 fix: invalid login message
Resolves #224
2022-09-03 21:48:33 +05:30
Lakhan Samani
ead3514113 chore: update railway template 2022-08-31 13:09:00 +05:30
Lakhan Samani
75a413e5f2 Merge branch 'main' of https://github.com/authorizerdev/authorizer 2022-08-31 11:02:50 +05:30
Lakhan Samani
91bf0e2478 fix: use replace all 2022-08-31 11:02:46 +05:30
Lakhan Samani
7a1305cf96 Merge pull request #222 from Deep-Codes/main 2022-08-31 07:04:20 +05:30
Deep-Codes
ff5a6ec301 feat(server): add log to show PORT 2022-08-30 23:35:43 +05:30
Lakhan Samani
b7b97b4f8d Merge pull request #221 from Deep-Codes/main
fix(dashboard): users table overflow
2022-08-30 22:38:49 +05:30
Deep-Codes
d9bc989c74 fix(dashboard): users table overflow 2022-08-30 21:56:28 +05:30
18 changed files with 1294 additions and 1117 deletions

View File

@@ -7,19 +7,17 @@
Authorizer Authorizer
</h1> </h1>
**Authorizer** is an open-source authentication and authorization solution for your applications. Bring your database and have complete control over the user information. You can self-host authorizer instances and connect to any database (Currently supports [Postgres](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), [SQLite](https://www.sqlite.org/index.html), [SQLServer](https://www.microsoft.com/en-us/sql-server/), [MongoDB](https://mongodb.com/), [ArangoDB](https://www.arangodb.com/)). **Authorizer** is an open-source authentication and authorization solution for your applications. Bring your database and have complete control over the user information. You can self-host authorizer instances and connect to any database (Currently supports 11+ databases including [Postgres](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), [SQLite](https://www.sqlite.org/index.html), [SQLServer](https://www.microsoft.com/en-us/sql-server/), [YugaByte](https://www.yugabyte.com/), [MariaDB](https://mariadb.org/), [PlanetScale](https://planetscale.com/), [CassandraDB](https://cassandra.apache.org/_/index.html), [ScyllaDB](https://www.scylladb.com/), [MongoDB](https://mongodb.com/), [ArangoDB](https://www.arangodb.com/)).
## Table of contents For more information check:
- [Introduction](#introduction)
- [Getting Started](#getting-started)
- [Contributing](https://github.com/authorizerdev/authorizer/blob/main/.github/CONTRIBUTING.md)
- [Docs](http://docs.authorizer.dev/) - [Docs](http://docs.authorizer.dev/)
- [Join Community](https://discord.gg/Zv2D5h6kkK) - [Discord Community](https://discord.gg/Zv2D5h6kkK)
- [Contributing Guide](https://github.com/authorizerdev/authorizer/blob/main/.github/CONTRIBUTING.md)
# Introduction # Introduction
<img src="https://github.com/authorizerdev/authorizer/blob/main/assets/authorizer-architecture.png" style="height:20em"/> <img src="https://docs.authorizer.dev/images/authorizer-arch.png" style="height:20em"/>
#### We offer the following functionality #### We offer the following functionality
@@ -38,13 +36,13 @@
## Roadmap ## Roadmap
- VueJS SDK - [VueJS SDK](https://github.com/authorizerdev/authorizer-vue)
- Svelte SDK - [Svelte SDK](https://github.com/authorizerdev/authorizer-svelte)
- [Golang SDK](https://github.com/authorizerdev/authorizer-go)
- React Native SDK - React Native SDK
- Flutter SDK - Flutter SDK
- Android Native SDK - Android Native SDK
- iOS native SDK - iOS native SDK
- Golang SDK
- Python SDK - Python SDK
- PHP SDK - PHP SDK
- WordPress plugin - WordPress plugin
@@ -65,11 +63,11 @@
Deploy production ready Authorizer instance using one click deployment options available below Deploy production ready Authorizer instance using one click deployment options available below
| **Infra provider** | **One-click link** | **Additional information** | | **Infra provider** | **One-click link** | **Additional information** |
| :----------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------: | | :----------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------: |
| Railway.app | <a href="https://railway.app/new/template?template=https://github.com/authorizerdev/authorizer-railway&amp;plugins=postgresql,redis"><img src="https://railway.app/button.svg" style="height: 44px" alt="Deploy on Railway"></a> | [docs](https://docs.authorizer.dev/deployment/railway) | | Railway.app | <a href="https://railway.app/new/template/nwXp1C?referralCode=FEF4uT"><img src="https://railway.app/button.svg" style="height: 44px" alt="Deploy on Railway"></a> | [docs](https://docs.authorizer.dev/deployment/railway) |
| Heroku | <a href="https://heroku.com/deploy?template=https://github.com/authorizerdev/authorizer-heroku"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku" style="height: 44px;"></a> | [docs](https://docs.authorizer.dev/deployment/heroku) | | Heroku | <a href="https://heroku.com/deploy?template=https://github.com/authorizerdev/authorizer-heroku"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku" style="height: 44px;"></a> | [docs](https://docs.authorizer.dev/deployment/heroku) |
| Render | [![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/authorizerdev/authorizer-render) | [docs](https://docs.authorizer.dev/deployment/render) | | Render | [![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/authorizerdev/authorizer-render) | [docs](https://docs.authorizer.dev/deployment/render) |
### Deploy Authorizer Using Source Code ### Deploy Authorizer Using Source Code

View File

@@ -4,6 +4,12 @@ import { AuthorizerProvider } from '@authorizerdev/authorizer-react';
import Root from './Root'; import Root from './Root';
import { createRandomString } from './utils/common'; import { createRandomString } from './utils/common';
declare global {
interface Window {
__authorizer__: any;
}
}
export default function App() { export default function App() {
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
const state = searchParams.get('state') || createRandomString(); const state = searchParams.get('state') || createRandomString();
@@ -24,7 +30,6 @@ export default function App() {
urlProps.redirectURL = window.location.origin + '/app'; urlProps.redirectURL = window.location.origin + '/app';
} }
const globalState: Record<string, string> = { const globalState: Record<string, string> = {
// @ts-ignore
...window['__authorizer__'], ...window['__authorizer__'],
...urlProps, ...urlProps,
}; };

View File

@@ -1,154 +1,201 @@
import React from "react"; import React from 'react';
import { Flex, Stack, Center, Text, useMediaQuery } from "@chakra-ui/react";
import { import {
HiddenInputType, Flex,
TextInputType, Stack,
TextAreaInputType, Center,
} from "../../constants"; Text,
import GenerateKeysModal from "../GenerateKeysModal"; useMediaQuery,
import InputField from "../InputField"; Button,
useToast,
} from '@chakra-ui/react';
import {
HiddenInputType,
TextInputType,
TextAreaInputType,
} from '../../constants';
import GenerateKeysModal from '../GenerateKeysModal';
import InputField from '../InputField';
import { copyTextToClipboard } from '../../utils';
const JSTConfigurations = ({ const JSTConfigurations = ({
variables, variables,
setVariables, setVariables,
fieldVisibility, fieldVisibility,
setFieldVisibility, setFieldVisibility,
SelectInputType, SelectInputType,
getData, getData,
HMACEncryptionType, HMACEncryptionType,
RSAEncryptionType, RSAEncryptionType,
ECDSAEncryptionType, ECDSAEncryptionType,
}: any) => { }: any) => {
const [isNotSmallerScreen] = useMediaQuery("(min-width:600px)"); const [isNotSmallerScreen] = useMediaQuery('(min-width:600px)');
const toast = useToast();
return ( const copyJSON = async () => {
<div> try {
{" "} await copyTextToClipboard(
<Flex JSON.stringify({
borderRadius={5} type: variables.JWT_TYPE,
width="100%" key: variables.JWT_PUBLIC_KEY || variables.JWT_SECRET,
justifyContent="space-between" })
alignItems="center" );
paddingTop="2%" toast({
> title: `JWT config copied successfully`,
<Text isClosable: true,
fontSize={isNotSmallerScreen ? "md" : "sm"} status: 'success',
fontWeight="bold" position: 'bottom-right',
mb={5} });
> } catch (err) {
JWT (JSON Web Tokens) Configurations console.error({
</Text> message: `Failed to copy JWT config`,
<Flex mb={7}> error: err,
<GenerateKeysModal jwtType={variables.JWT_TYPE} getData={getData} /> });
</Flex> toast({
</Flex> title: `Failed to copy JWT config`,
<Stack spacing={6} padding="2% 0%"> isClosable: true,
<Flex direction={isNotSmallerScreen ? "row" : "column"}> status: 'error',
<Flex w="30%" justifyContent="start" alignItems="center"> position: 'bottom-right',
<Text fontSize="sm">JWT Type:</Text> });
</Flex> }
<Flex };
w={isNotSmallerScreen ? "70%" : "100%"}
mt={isNotSmallerScreen ? "0" : "2"} return (
> <div>
<InputField {' '}
borderRadius={5} <Flex
variables={variables} borderRadius={5}
setVariables={setVariables} width="100%"
inputType={SelectInputType} justifyContent="space-between"
value={SelectInputType} alignItems="center"
options={{ paddingTop="2%"
...HMACEncryptionType, >
...RSAEncryptionType, <Text
...ECDSAEncryptionType, fontSize={isNotSmallerScreen ? 'md' : 'sm'}
}} fontWeight="bold"
/> mb={5}
</Flex> >
</Flex> JWT (JSON Web Tokens) Configurations
{Object.values(HMACEncryptionType).includes(variables.JWT_TYPE) ? ( </Text>
<Flex direction={isNotSmallerScreen ? "row" : "column"}> <Flex mb={7}>
<Flex w="30%" justifyContent="start" alignItems="center"> <Button
<Text fontSize="sm">JWT Secret</Text> colorScheme="blue"
</Flex> h="1.75rem"
<Center size="sm"
w={isNotSmallerScreen ? "70%" : "100%"} variant="ghost"
mt={isNotSmallerScreen ? "0" : "2"} onClick={copyJSON}
> >
<InputField Copy As JSON Config
borderRadius={5} </Button>
variables={variables} <GenerateKeysModal jwtType={variables.JWT_TYPE} getData={getData} />
setVariables={setVariables} </Flex>
fieldVisibility={fieldVisibility} </Flex>
setFieldVisibility={setFieldVisibility} <Stack spacing={6} padding="2% 0%">
inputType={HiddenInputType.JWT_SECRET} <Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
/> <Flex w="30%" justifyContent="start" alignItems="center">
</Center> <Text fontSize="sm">JWT Type:</Text>
</Flex> </Flex>
) : ( <Flex
<> w={isNotSmallerScreen ? '70%' : '100%'}
<Flex direction={isNotSmallerScreen ? "row" : "column"}> mt={isNotSmallerScreen ? '0' : '2'}
<Flex w="30%" justifyContent="start" alignItems="center"> >
<Text fontSize="sm">Public Key</Text> <InputField
</Flex> borderRadius={5}
<Center variables={variables}
w={isNotSmallerScreen ? "70%" : "100%"} setVariables={setVariables}
mt={isNotSmallerScreen ? "0" : "2"} inputType={SelectInputType}
> value={SelectInputType}
<InputField options={{
borderRadius={5} ...HMACEncryptionType,
variables={variables} ...RSAEncryptionType,
setVariables={setVariables} ...ECDSAEncryptionType,
inputType={TextAreaInputType.JWT_PUBLIC_KEY} }}
placeholder="Add public key here" />
minH="25vh" </Flex>
/> </Flex>
</Center> {Object.values(HMACEncryptionType).includes(variables.JWT_TYPE) ? (
</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">JWT Secret</Text>
<Text fontSize="sm">Private Key</Text> </Flex>
</Flex> <Center
<Center w={isNotSmallerScreen ? '70%' : '100%'}
w={isNotSmallerScreen ? "70%" : "100%"} mt={isNotSmallerScreen ? '0' : '2'}
mt={isNotSmallerScreen ? "0" : "2"} >
> <InputField
<InputField borderRadius={5}
borderRadius={5} variables={variables}
variables={variables} setVariables={setVariables}
setVariables={setVariables} fieldVisibility={fieldVisibility}
inputType={TextAreaInputType.JWT_PRIVATE_KEY} setFieldVisibility={setFieldVisibility}
placeholder="Add private key here" inputType={HiddenInputType.JWT_SECRET}
minH="25vh" />
/> </Center>
</Center> </Flex>
</Flex> ) : (
</> <>
)} <Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
<Flex direction={isNotSmallerScreen ? "row" : "column"}> <Flex w="30%" justifyContent="start" alignItems="center">
<Flex <Text fontSize="sm">Public Key</Text>
w={isNotSmallerScreen ? "30%" : "40%"} </Flex>
justifyContent="start" <Center
alignItems="center" w={isNotSmallerScreen ? '70%' : '100%'}
> mt={isNotSmallerScreen ? '0' : '2'}
<Text fontSize="sm" orientation="vertical"> >
JWT Role Claim: <InputField
</Text> borderRadius={5}
</Flex> variables={variables}
<Center setVariables={setVariables}
w={isNotSmallerScreen ? "70%" : "100%"} inputType={TextAreaInputType.JWT_PUBLIC_KEY}
mt={isNotSmallerScreen ? "0" : "2"} placeholder="Add public key here"
> minH="25vh"
<InputField />
borderRadius={5} </Center>
variables={variables} </Flex>
setVariables={setVariables} <Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
inputType={TextInputType.JWT_ROLE_CLAIM} <Flex w="30%" justifyContent="start" alignItems="center">
/> <Text fontSize="sm">Private Key</Text>
</Center> </Flex>
</Flex> <Center
</Stack> w={isNotSmallerScreen ? '70%' : '100%'}
</div> mt={isNotSmallerScreen ? '0' : '2'}
); >
<InputField
borderRadius={5}
variables={variables}
setVariables={setVariables}
inputType={TextAreaInputType.JWT_PRIVATE_KEY}
placeholder="Add private key here"
minH="25vh"
/>
</Center>
</Flex>
</>
)}
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
<Flex
w={isNotSmallerScreen ? '30%' : '40%'}
justifyContent="start"
alignItems="center"
>
<Text fontSize="sm" orientation="vertical">
JWT Role Claim:
</Text>
</Flex>
<Center
w={isNotSmallerScreen ? '70%' : '100%'}
mt={isNotSmallerScreen ? '0' : '2'}
>
<InputField
borderRadius={5}
variables={variables}
setVariables={setVariables}
inputType={TextInputType.JWT_ROLE_CLAIM}
/>
</Center>
</Flex>
</Stack>
</div>
);
}; };
export default JSTConfigurations; export default JSTConfigurations;

View File

@@ -29,6 +29,7 @@ import {
MenuItem, MenuItem,
useToast, useToast,
Spinner, Spinner,
TableContainer
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { import {
FaAngleLeft, FaAngleLeft,
@@ -262,9 +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 ${ title: `Multi factor authentication ${user.is_multi_factor_auth_enabled ? 'disabled' : 'enabled'
user.is_multi_factor_auth_enabled ? 'disabled' : 'enabled' } for user`,
} for user`,
isClosable: true, isClosable: true,
status: 'success', status: 'success',
position: 'bottom-right', position: 'bottom-right',
@@ -293,260 +293,262 @@ export default function Users() {
</Flex> </Flex>
{!loading ? ( {!loading ? (
userList.length > 0 ? ( userList.length > 0 ? (
<Table variant="simple"> <TableContainer>
<Thead> <Table variant="simple">
<Tr> <Thead>
<Th>Email</Th> <Tr>
<Th>Created At</Th> <Th>Email</Th>
<Th>Signup Methods</Th> <Th>Created At</Th>
<Th>Roles</Th> <Th>Signup Methods</Th>
<Th>Verified</Th> <Th>Roles</Th>
<Th>Access</Th> <Th>Verified</Th>
<Th> <Th>Access</Th>
<Tooltip label="MultiFactor Authentication Enabled / Disabled"> <Th>
MFA <Tooltip label="MultiFactor Authentication Enabled / Disabled">
</Tooltip> MFA
</Th> </Tooltip>
<Th>Actions</Th> </Th>
</Tr> <Th>Actions</Th>
</Thead> </Tr>
<Tbody> </Thead>
{userList.map((user: userDataTypes) => { <Tbody>
const { email_verified, created_at, ...rest }: any = user; {userList.map((user: userDataTypes) => {
return ( const { email_verified, created_at, ...rest }: any = user;
<Tr key={user.id} style={{ fontSize: 14 }}> return (
<Td maxW="300">{user.email}</Td> <Tr key={user.id} style={{ fontSize: 14 }}>
<Td> <Td maxW="300">{user.email}</Td>
{dayjs(user.created_at * 1000).format('MMM DD, YYYY')} <Td>
</Td> {dayjs(user.created_at * 1000).format('MMM DD, YYYY')}
<Td>{user.signup_methods}</Td> </Td>
<Td>{user.roles.join(', ')}</Td> <Td>{user.signup_methods}</Td>
<Td> <Td>{user.roles.join(', ')}</Td>
<Tag <Td>
size="sm" <Tag
variant="outline" size="sm"
colorScheme={user.email_verified ? 'green' : 'yellow'} variant="outline"
> colorScheme={user.email_verified ? 'green' : 'yellow'}
{user.email_verified.toString()} >
</Tag> {user.email_verified.toString()}
</Td> </Tag>
<Td> </Td>
<Tag <Td>
size="sm" <Tag
variant="outline" size="sm"
colorScheme={user.revoked_timestamp ? 'red' : 'green'} variant="outline"
> colorScheme={user.revoked_timestamp ? 'red' : 'green'}
{user.revoked_timestamp ? 'Revoked' : 'Enabled'} >
</Tag> {user.revoked_timestamp ? 'Revoked' : 'Enabled'}
</Td> </Tag>
<Td> </Td>
<Tag <Td>
size="sm" <Tag
variant="outline" size="sm"
colorScheme={ variant="outline"
user.is_multi_factor_auth_enabled ? 'green' : 'red' colorScheme={
} user.is_multi_factor_auth_enabled ? 'green' : 'red'
> }
{user.is_multi_factor_auth_enabled >
? 'Enabled' {user.is_multi_factor_auth_enabled
: 'Disabled'} ? 'Enabled'
</Tag> : 'Disabled'}
</Td> </Tag>
<Td> </Td>
<Menu> <Td>
<MenuButton as={Button} variant="unstyled" size="sm"> <Menu>
<Flex <MenuButton as={Button} variant="unstyled" size="sm">
justifyContent="space-between" <Flex
alignItems="center" justifyContent="space-between"
> alignItems="center"
<Text fontSize="sm" fontWeight="light">
Menu
</Text>
<FaAngleDown style={{ marginLeft: 10 }} />
</Flex>
</MenuButton>
<MenuList>
{!user.email_verified && (
<MenuItem
onClick={() => userVerificationHandler(user)}
> >
Verify User <Text fontSize="sm" fontWeight="light">
</MenuItem> Menu
)} </Text>
<EditUserModal <FaAngleDown style={{ marginLeft: 10 }} />
user={rest} </Flex>
updateUserList={updateUserList} </MenuButton>
/> <MenuList>
<DeleteUserModal {!user.email_verified && (
user={rest} <MenuItem
updateUserList={updateUserList} onClick={() => userVerificationHandler(user)}
/> >
{user.revoked_timestamp ? ( Verify User
<MenuItem </MenuItem>
onClick={() => )}
updateAccessHandler( <EditUserModal
user.id, user={rest}
updateAccessActions.ENABLE updateUserList={updateUserList}
) />
} <DeleteUserModal
> user={rest}
Enable Access updateUserList={updateUserList}
</MenuItem> />
) : ( {user.revoked_timestamp ? (
<MenuItem <MenuItem
onClick={() => onClick={() =>
updateAccessHandler( updateAccessHandler(
user.id, user.id,
updateAccessActions.REVOKE updateAccessActions.ENABLE
) )
} }
> >
Revoke Access Enable Access
</MenuItem> </MenuItem>
)} ) : (
{user.is_multi_factor_auth_enabled ? ( <MenuItem
<MenuItem onClick={() =>
onClick={() => multiFactorAuthUpdateHandler(user)} updateAccessHandler(
> user.id,
Disable MultiFactor Authentication updateAccessActions.REVOKE
</MenuItem> )
) : ( }
<MenuItem >
onClick={() => multiFactorAuthUpdateHandler(user)} Revoke Access
> </MenuItem>
Enable MultiFactor Authentication )}
</MenuItem> {user.is_multi_factor_auth_enabled ? (
)} <MenuItem
</MenuList> onClick={() => multiFactorAuthUpdateHandler(user)}
</Menu> >
</Td> Disable MultiFactor Authentication
</Tr> </MenuItem>
); ) : (
})} <MenuItem
</Tbody> onClick={() => multiFactorAuthUpdateHandler(user)}
{(paginationProps.maxPages > 1 || paginationProps.total >= 5) && ( >
<TableCaption> Enable MultiFactor Authentication
<Flex </MenuItem>
justifyContent="space-between" )}
alignItems="center" </MenuList>
m="2% 0" </Menu>
> </Td>
<Flex flex="1"> </Tr>
<Tooltip label="First Page"> );
<IconButton })}
aria-label="icon button" </Tbody>
onClick={() => {(paginationProps.maxPages > 1 || paginationProps.total >= 5) && (
<TableCaption>
<Flex
justifyContent="space-between"
alignItems="center"
m="2% 0"
>
<Flex flex="1">
<Tooltip label="First Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: 1,
})
}
isDisabled={paginationProps.page <= 1}
mr={4}
icon={<FaAngleDoubleLeft />}
/>
</Tooltip>
<Tooltip label="Previous Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: paginationProps.page - 1,
})
}
isDisabled={paginationProps.page <= 1}
icon={<FaAngleLeft />}
/>
</Tooltip>
</Flex>
<Flex
flex="8"
justifyContent="space-evenly"
alignItems="center"
>
<Text mr={8}>
Page{' '}
<Text fontWeight="bold" as="span">
{paginationProps.page}
</Text>{' '}
of{' '}
<Text fontWeight="bold" as="span">
{paginationProps.maxPages}
</Text>
</Text>
<Flex alignItems="center">
<Text flexShrink="0">Go to page:</Text>{' '}
<NumberInput
ml={2}
mr={8}
w={28}
min={1}
max={paginationProps.maxPages}
onChange={(value) =>
paginationHandler({
page: parseInt(value),
})
}
value={paginationProps.page}
>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
</Flex>
<Select
w={32}
value={paginationProps.limit}
onChange={(e) =>
paginationHandler({ paginationHandler({
page: 1, page: 1,
limit: parseInt(e.target.value),
}) })
} }
isDisabled={paginationProps.page <= 1}
mr={4}
icon={<FaAngleDoubleLeft />}
/>
</Tooltip>
<Tooltip label="Previous Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: paginationProps.page - 1,
})
}
isDisabled={paginationProps.page <= 1}
icon={<FaAngleLeft />}
/>
</Tooltip>
</Flex>
<Flex
flex="8"
justifyContent="space-evenly"
alignItems="center"
>
<Text mr={8}>
Page{' '}
<Text fontWeight="bold" as="span">
{paginationProps.page}
</Text>{' '}
of{' '}
<Text fontWeight="bold" as="span">
{paginationProps.maxPages}
</Text>
</Text>
<Flex alignItems="center">
<Text flexShrink="0">Go to page:</Text>{' '}
<NumberInput
ml={2}
mr={8}
w={28}
min={1}
max={paginationProps.maxPages}
onChange={(value) =>
paginationHandler({
page: parseInt(value),
})
}
value={paginationProps.page}
> >
<NumberInputField /> {getLimits(paginationProps).map((pageSize) => (
<NumberInputStepper> <option key={pageSize} value={pageSize}>
<NumberIncrementStepper /> Show {pageSize}
<NumberDecrementStepper /> </option>
</NumberInputStepper> ))}
</NumberInput> </Select>
</Flex>
<Flex flex="1">
<Tooltip label="Next Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: paginationProps.page + 1,
})
}
isDisabled={
paginationProps.page >= paginationProps.maxPages
}
icon={<FaAngleRight />}
/>
</Tooltip>
<Tooltip label="Last Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: paginationProps.maxPages,
})
}
isDisabled={
paginationProps.page >= paginationProps.maxPages
}
ml={4}
icon={<FaAngleDoubleRight />}
/>
</Tooltip>
</Flex> </Flex>
<Select
w={32}
value={paginationProps.limit}
onChange={(e) =>
paginationHandler({
page: 1,
limit: parseInt(e.target.value),
})
}
>
{getLimits(paginationProps).map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</Select>
</Flex> </Flex>
<Flex flex="1"> </TableCaption>
<Tooltip label="Next Page"> )}
<IconButton </Table>
aria-label="icon button" </TableContainer>
onClick={() =>
paginationHandler({
page: paginationProps.page + 1,
})
}
isDisabled={
paginationProps.page >= paginationProps.maxPages
}
icon={<FaAngleRight />}
/>
</Tooltip>
<Tooltip label="Last Page">
<IconButton
aria-label="icon button"
onClick={() =>
paginationHandler({
page: paginationProps.maxPages,
})
}
isDisabled={
paginationProps.page >= paginationProps.maxPages
}
ml={4}
icon={<FaAngleDoubleRight />}
/>
</Tooltip>
</Flex>
</Flex>
</TableCaption>
)}
</Table>
) : ( ) : (
<Flex <Flex
flexDirection="column" flexDirection="column"

View File

@@ -29,19 +29,16 @@ const fallbackCopyTextToClipboard = (text: string) => {
document.body.removeChild(textArea); document.body.removeChild(textArea);
}; };
export const copyTextToClipboard = (text: string) => { export const copyTextToClipboard = async (text: string) => {
if (!navigator.clipboard) { if (!navigator.clipboard) {
fallbackCopyTextToClipboard(text); fallbackCopyTextToClipboard(text);
return; return;
} }
navigator.clipboard.writeText(text).then( try {
() => { navigator.clipboard.writeText(text);
console.log('Async: Copying to clipboard was successful!'); } catch (err) {
}, throw err;
(err) => { }
console.error('Async: Could not copy text: ', err);
}
);
}; };
export const getObjectDiff = (obj1: any, obj2: any) => { export const getObjectDiff = (obj1: any, obj2: any) => {

View File

@@ -49,6 +49,10 @@ const (
EnvKeySenderEmail = "SENDER_EMAIL" EnvKeySenderEmail = "SENDER_EMAIL"
// EnvKeyIsEmailServiceEnabled key for env variable IS_EMAIL_SERVICE_ENABLED // EnvKeyIsEmailServiceEnabled key for env variable IS_EMAIL_SERVICE_ENABLED
EnvKeyIsEmailServiceEnabled = "IS_EMAIL_SERVICE_ENABLED" EnvKeyIsEmailServiceEnabled = "IS_EMAIL_SERVICE_ENABLED"
// EnvKeyAppCookieSecure key for env variable APP_COOKIE_SECURE
EnvKeyAppCookieSecure = "APP_COOKIE_SECURE"
// EnvKeyAdminCookieSecure key for env variable ADMIN_COOKIE_SECURE
EnvKeyAdminCookieSecure = "ADMIN_COOKIE_SECURE"
// EnvKeyJwtType key for env variable JWT_TYPE // EnvKeyJwtType key for env variable JWT_TYPE
EnvKeyJwtType = "JWT_TYPE" EnvKeyJwtType = "JWT_TYPE"
// EnvKeyJwtSecret key for env variable JWT_SECRET // EnvKeyJwtSecret key for env variable JWT_SECRET

View File

@@ -9,7 +9,7 @@ const (
// Ref: https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#3-your-github-app-accesses-the-api-with-the-users-access-token // Ref: https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#3-your-github-app-accesses-the-api-with-the-users-access-token
GithubUserInfoURL = "https://api.github.com/user" GithubUserInfoURL = "https://api.github.com/user"
// Get github user emails when user info email is empty Ref: https://stackoverflow.com/a/35387123 // Get github user emails when user info email is empty Ref: https://stackoverflow.com/a/35387123
GithubUserEmails = "https://api/github.com/user/emails" GithubUserEmails = "https://api.github.com/user/emails"
// Ref: https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api // Ref: https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api
LinkedInUserInfoURL = "https://api.linkedin.com/v2/me?projection=(id,localizedFirstName,localizedLastName,emailAddress,profilePicture(displayImage~:playableStreams))" LinkedInUserInfoURL = "https://api.linkedin.com/v2/me?projection=(id,localizedFirstName,localizedLastName,emailAddress,profilePicture(displayImage~:playableStreams))"

View File

@@ -3,15 +3,24 @@ package cookie
import ( import (
"net/url" "net/url"
log "github.com/sirupsen/logrus"
"github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/memorystore"
"github.com/authorizerdev/authorizer/server/parsers" "github.com/authorizerdev/authorizer/server/parsers"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// SetAdminCookie sets the admin cookie in the response // SetAdminCookie sets the admin cookie in the response
func SetAdminCookie(gc *gin.Context, token string) { func SetAdminCookie(gc *gin.Context, token string) {
secure := true adminCookieSecure, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyAdminCookieSecure)
httpOnly := true if err != nil {
log.Debug("Error while getting admin cookie secure from env variable: %v", err)
adminCookieSecure = true
}
secure := adminCookieSecure
httpOnly := adminCookieSecure
hostname := parsers.GetHost(gc) hostname := parsers.GetHost(gc)
host, _ := parsers.GetHostParts(hostname) host, _ := parsers.GetHostParts(hostname)
gc.SetCookie(constants.AdminCookieName, token, 3600, "/", host, secure, httpOnly) gc.SetCookie(constants.AdminCookieName, token, 3600, "/", host, secure, httpOnly)
@@ -35,8 +44,14 @@ func GetAdminCookie(gc *gin.Context) (string, error) {
// DeleteAdminCookie sets the response cookie to empty // DeleteAdminCookie sets the response cookie to empty
func DeleteAdminCookie(gc *gin.Context) { func DeleteAdminCookie(gc *gin.Context) {
secure := true adminCookieSecure, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyAdminCookieSecure)
httpOnly := true if err != nil {
log.Debug("Error while getting admin cookie secure from env variable: %v", err)
adminCookieSecure = true
}
secure := adminCookieSecure
httpOnly := adminCookieSecure
hostname := parsers.GetHost(gc) hostname := parsers.GetHost(gc)
host, _ := parsers.GetHostParts(hostname) host, _ := parsers.GetHostParts(hostname)
gc.SetCookie(constants.AdminCookieName, "", -1, "/", host, secure, httpOnly) gc.SetCookie(constants.AdminCookieName, "", -1, "/", host, secure, httpOnly)

View File

@@ -4,15 +4,24 @@ import (
"net/http" "net/http"
"net/url" "net/url"
log "github.com/sirupsen/logrus"
"github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/memorystore"
"github.com/authorizerdev/authorizer/server/parsers" "github.com/authorizerdev/authorizer/server/parsers"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// SetSession sets the session cookie in the response // SetSession sets the session cookie in the response
func SetSession(gc *gin.Context, sessionID string) { func SetSession(gc *gin.Context, sessionID string) {
secure := true appCookieSecure, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyAppCookieSecure)
httpOnly := true if err != nil {
log.Debug("Error while getting app cookie secure from env variable: %v", err)
appCookieSecure = true
}
secure := appCookieSecure
httpOnly := appCookieSecure
hostname := parsers.GetHost(gc) hostname := parsers.GetHost(gc)
host, _ := parsers.GetHostParts(hostname) host, _ := parsers.GetHostParts(hostname)
domain := parsers.GetDomainName(hostname) domain := parsers.GetDomainName(hostname)
@@ -30,8 +39,14 @@ func SetSession(gc *gin.Context, sessionID string) {
// DeleteSession sets session cookies to expire // DeleteSession sets session cookies to expire
func DeleteSession(gc *gin.Context) { func DeleteSession(gc *gin.Context) {
secure := true appCookieSecure, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyAppCookieSecure)
httpOnly := true if err != nil {
log.Debug("Error while getting app cookie secure from env variable: %v", err)
appCookieSecure = true
}
secure := appCookieSecure
httpOnly := appCookieSecure
hostname := parsers.GetHost(gc) hostname := parsers.GetHost(gc)
host, _ := parsers.GetHostParts(hostname) host, _ := parsers.GetHostParts(hostname)
domain := parsers.GetDomainName(hostname) domain := parsers.GetDomainName(hostname)

36
server/env/env.go vendored
View File

@@ -79,6 +79,8 @@ func InitAllEnv() error {
osOrganizationLogo := os.Getenv(constants.EnvKeyOrganizationLogo) osOrganizationLogo := os.Getenv(constants.EnvKeyOrganizationLogo)
// os bool vars // os bool vars
osAppCookieSecure := os.Getenv(constants.EnvKeyAppCookieSecure)
osAdminCookieSecure := os.Getenv(constants.EnvKeyAdminCookieSecure)
osDisableBasicAuthentication := os.Getenv(constants.EnvKeyDisableBasicAuthentication) osDisableBasicAuthentication := os.Getenv(constants.EnvKeyDisableBasicAuthentication)
osDisableEmailVerification := os.Getenv(constants.EnvKeyDisableEmailVerification) osDisableEmailVerification := os.Getenv(constants.EnvKeyDisableEmailVerification)
osDisableMagicLinkLogin := os.Getenv(constants.EnvKeyDisableMagicLinkLogin) osDisableMagicLinkLogin := os.Getenv(constants.EnvKeyDisableMagicLinkLogin)
@@ -417,6 +419,40 @@ func InitAllEnv() error {
envData[constants.EnvKeyOrganizationLogo] = osOrganizationLogo envData[constants.EnvKeyOrganizationLogo] = osOrganizationLogo
} }
if _, ok := envData[constants.EnvKeyAppCookieSecure]; !ok {
if osAppCookieSecure == "" {
envData[constants.EnvKeyAppCookieSecure] = true
} else {
envData[constants.EnvKeyAppCookieSecure] = osAppCookieSecure == "true"
}
}
if osAppCookieSecure != "" {
boolValue, err := strconv.ParseBool(osAppCookieSecure)
if err != nil {
return err
}
if boolValue != envData[constants.EnvKeyAppCookieSecure].(bool) {
envData[constants.EnvKeyAppCookieSecure] = boolValue
}
}
if _, ok := envData[constants.EnvKeyAdminCookieSecure]; !ok {
if osAdminCookieSecure == "" {
envData[constants.EnvKeyAdminCookieSecure] = true
} else {
envData[constants.EnvKeyAdminCookieSecure] = osAdminCookieSecure == "true"
}
}
if osAdminCookieSecure != "" {
boolValue, err := strconv.ParseBool(osAdminCookieSecure)
if err != nil {
return err
}
if boolValue != envData[constants.EnvKeyAdminCookieSecure].(bool) {
envData[constants.EnvKeyAdminCookieSecure] = boolValue
}
}
if _, ok := envData[constants.EnvKeyDisableBasicAuthentication]; !ok { if _, ok := envData[constants.EnvKeyDisableBasicAuthentication]; !ok {
envData[constants.EnvKeyDisableBasicAuthentication] = osDisableBasicAuthentication == "true" envData[constants.EnvKeyDisableBasicAuthentication] = osDisableBasicAuthentication == "true"
} }

View File

@@ -184,6 +184,7 @@ type ComplexityRoot struct {
} }
Pagination struct { Pagination struct {
Cursor func(childComplexity int) int
Limit func(childComplexity int) int Limit func(childComplexity int) int
Offset func(childComplexity int) int Offset func(childComplexity int) int
Page func(childComplexity int) int Page func(childComplexity int) int
@@ -1301,6 +1302,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Mutation.VerifyOtp(childComplexity, args["params"].(model.VerifyOTPRequest)), true return e.complexity.Mutation.VerifyOtp(childComplexity, args["params"].(model.VerifyOTPRequest)), true
case "Pagination.cursor":
if e.complexity.Pagination.Cursor == nil {
break
}
return e.complexity.Pagination.Cursor(childComplexity), true
case "Pagination.limit": case "Pagination.limit":
if e.complexity.Pagination.Limit == nil { if e.complexity.Pagination.Limit == nil {
break break
@@ -1903,494 +1911,496 @@ scalar Map
scalar Any scalar Any
type Pagination { type Pagination {
limit: Int64! limit: Int64!
page: Int64! page: Int64!
offset: Int64! cursor: String
total: Int64! offset: Int64!
total: Int64!
} }
type Meta { type Meta {
version: String! version: String!
client_id: String! client_id: String!
is_google_login_enabled: Boolean! is_google_login_enabled: Boolean!
is_facebook_login_enabled: Boolean! is_facebook_login_enabled: Boolean!
is_github_login_enabled: Boolean! is_github_login_enabled: Boolean!
is_linkedin_login_enabled: Boolean! is_linkedin_login_enabled: Boolean!
is_apple_login_enabled: Boolean! is_apple_login_enabled: Boolean!
is_twitter_login_enabled: Boolean! is_twitter_login_enabled: Boolean!
is_email_verification_enabled: Boolean! is_email_verification_enabled: Boolean!
is_basic_authentication_enabled: Boolean! is_basic_authentication_enabled: Boolean!
is_magic_link_login_enabled: Boolean! is_magic_link_login_enabled: Boolean!
is_sign_up_enabled: Boolean! is_sign_up_enabled: Boolean!
is_strong_password_enabled: Boolean! is_strong_password_enabled: Boolean!
is_multi_factor_auth_enabled: Boolean! is_multi_factor_auth_enabled: Boolean!
} }
type User { type User {
id: ID! id: ID!
email: String! email: String!
email_verified: Boolean! email_verified: Boolean!
signup_methods: String! signup_methods: String!
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
# defaults to email # defaults to email
preferred_username: String preferred_username: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
phone_number_verified: Boolean phone_number_verified: Boolean
picture: String picture: String
roles: [String!]! roles: [String!]!
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
revoked_timestamp: Int64 revoked_timestamp: Int64
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
type Users { type Users {
pagination: Pagination! pagination: Pagination!
users: [User!]! users: [User!]!
} }
type VerificationRequest { type VerificationRequest {
id: ID! id: ID!
identifier: String identifier: String
token: String token: String
email: String email: String
expires: Int64 expires: Int64
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
nonce: String nonce: String
redirect_uri: String redirect_uri: String
} }
type VerificationRequests { type VerificationRequests {
pagination: Pagination! pagination: Pagination!
verification_requests: [VerificationRequest!]! verification_requests: [VerificationRequest!]!
} }
type Error { type Error {
message: String! message: String!
reason: String! reason: String!
} }
type AuthResponse { type AuthResponse {
message: String! message: String!
should_show_otp_screen: Boolean should_show_otp_screen: Boolean
access_token: String access_token: String
id_token: String id_token: String
refresh_token: String refresh_token: String
expires_in: Int64 expires_in: Int64
user: User user: User
} }
type Response { type Response {
message: String! message: String!
} }
type Env { type Env {
ACCESS_TOKEN_EXPIRY_TIME: String ACCESS_TOKEN_EXPIRY_TIME: String
ADMIN_SECRET: String ADMIN_SECRET: String
DATABASE_NAME: String DATABASE_NAME: String
DATABASE_URL: String DATABASE_URL: String
DATABASE_TYPE: String DATABASE_TYPE: String
DATABASE_USERNAME: String DATABASE_USERNAME: String
DATABASE_PASSWORD: String DATABASE_PASSWORD: String
DATABASE_HOST: String DATABASE_HOST: String
DATABASE_PORT: String DATABASE_PORT: String
CLIENT_ID: String! CLIENT_ID: String!
CLIENT_SECRET: String! CLIENT_SECRET: String!
CUSTOM_ACCESS_TOKEN_SCRIPT: String CUSTOM_ACCESS_TOKEN_SCRIPT: String
SMTP_HOST: String SMTP_HOST: String
SMTP_PORT: String SMTP_PORT: String
SMTP_USERNAME: String SMTP_USERNAME: String
SMTP_PASSWORD: String SMTP_PASSWORD: String
SENDER_EMAIL: String SENDER_EMAIL: String
JWT_TYPE: String JWT_TYPE: String
JWT_SECRET: String JWT_SECRET: String
JWT_PRIVATE_KEY: String JWT_PRIVATE_KEY: String
JWT_PUBLIC_KEY: String JWT_PUBLIC_KEY: String
ALLOWED_ORIGINS: [String!] ALLOWED_ORIGINS: [String!]
APP_URL: String APP_URL: String
REDIS_URL: String REDIS_URL: String
RESET_PASSWORD_URL: String RESET_PASSWORD_URL: String
DISABLE_EMAIL_VERIFICATION: Boolean! DISABLE_EMAIL_VERIFICATION: Boolean!
DISABLE_BASIC_AUTHENTICATION: Boolean! DISABLE_BASIC_AUTHENTICATION: Boolean!
DISABLE_MAGIC_LINK_LOGIN: Boolean! DISABLE_MAGIC_LINK_LOGIN: Boolean!
DISABLE_LOGIN_PAGE: Boolean! DISABLE_LOGIN_PAGE: Boolean!
DISABLE_SIGN_UP: Boolean! DISABLE_SIGN_UP: Boolean!
DISABLE_REDIS_FOR_ENV: Boolean! DISABLE_REDIS_FOR_ENV: Boolean!
DISABLE_STRONG_PASSWORD: Boolean! DISABLE_STRONG_PASSWORD: Boolean!
DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean! DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean!
ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean! ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean!
ROLES: [String!] ROLES: [String!]
PROTECTED_ROLES: [String!] PROTECTED_ROLES: [String!]
DEFAULT_ROLES: [String!] DEFAULT_ROLES: [String!]
JWT_ROLE_CLAIM: String JWT_ROLE_CLAIM: String
GOOGLE_CLIENT_ID: String GOOGLE_CLIENT_ID: String
GOOGLE_CLIENT_SECRET: String GOOGLE_CLIENT_SECRET: String
GITHUB_CLIENT_ID: String GITHUB_CLIENT_ID: String
GITHUB_CLIENT_SECRET: String GITHUB_CLIENT_SECRET: String
FACEBOOK_CLIENT_ID: String FACEBOOK_CLIENT_ID: String
FACEBOOK_CLIENT_SECRET: String FACEBOOK_CLIENT_SECRET: String
LINKEDIN_CLIENT_ID: String LINKEDIN_CLIENT_ID: String
LINKEDIN_CLIENT_SECRET: String LINKEDIN_CLIENT_SECRET: String
APPLE_CLIENT_ID: String APPLE_CLIENT_ID: String
APPLE_CLIENT_SECRET: String APPLE_CLIENT_SECRET: String
TWITTER_CLIENT_ID: String TWITTER_CLIENT_ID: String
TWITTER_CLIENT_SECRET: String TWITTER_CLIENT_SECRET: String
ORGANIZATION_NAME: String ORGANIZATION_NAME: String
ORGANIZATION_LOGO: String ORGANIZATION_LOGO: String
} }
type ValidateJWTTokenResponse { type ValidateJWTTokenResponse {
is_valid: Boolean! is_valid: Boolean!
} }
type GenerateJWTKeysResponse { type GenerateJWTKeysResponse {
secret: String secret: String
public_key: String public_key: String
private_key: String private_key: String
} }
type Webhook { type Webhook {
id: ID! id: ID!
event_name: String event_name: String
endpoint: String endpoint: String
enabled: Boolean enabled: Boolean
headers: Map headers: Map
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type Webhooks { type Webhooks {
pagination: Pagination! pagination: Pagination!
webhooks: [Webhook!]! webhooks: [Webhook!]!
} }
type WebhookLog { type WebhookLog {
id: ID! id: ID!
http_status: Int64 http_status: Int64
response: String response: String
request: String request: String
webhook_id: ID webhook_id: ID
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type TestEndpointResponse { type TestEndpointResponse {
http_status: Int64 http_status: Int64
response: String response: String
} }
type WebhookLogs { type WebhookLogs {
pagination: Pagination! pagination: Pagination!
webhook_logs: [WebhookLog!]! webhook_logs: [WebhookLog!]!
} }
type EmailTemplate { type EmailTemplate {
id: ID! id: ID!
event_name: String! event_name: String!
template: String! template: String!
design: String! design: String!
subject: String! subject: String!
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type EmailTemplates { type EmailTemplates {
pagination: Pagination! pagination: Pagination!
email_templates: [EmailTemplate!]! email_templates: [EmailTemplate!]!
} }
input UpdateEnvInput { input UpdateEnvInput {
ACCESS_TOKEN_EXPIRY_TIME: String ACCESS_TOKEN_EXPIRY_TIME: String
ADMIN_SECRET: String ADMIN_SECRET: String
CUSTOM_ACCESS_TOKEN_SCRIPT: String CUSTOM_ACCESS_TOKEN_SCRIPT: String
OLD_ADMIN_SECRET: String OLD_ADMIN_SECRET: String
SMTP_HOST: String SMTP_HOST: String
SMTP_PORT: String SMTP_PORT: String
SMTP_USERNAME: String SMTP_USERNAME: String
SMTP_PASSWORD: String SMTP_PASSWORD: String
SENDER_EMAIL: String SENDER_EMAIL: String
JWT_TYPE: String JWT_TYPE: String
JWT_SECRET: String JWT_SECRET: String
JWT_PRIVATE_KEY: String JWT_PRIVATE_KEY: String
JWT_PUBLIC_KEY: String JWT_PUBLIC_KEY: String
ALLOWED_ORIGINS: [String!] ALLOWED_ORIGINS: [String!]
APP_URL: String APP_URL: String
RESET_PASSWORD_URL: String RESET_PASSWORD_URL: String
DISABLE_EMAIL_VERIFICATION: Boolean DISABLE_EMAIL_VERIFICATION: Boolean
DISABLE_BASIC_AUTHENTICATION: Boolean DISABLE_BASIC_AUTHENTICATION: Boolean
DISABLE_MAGIC_LINK_LOGIN: Boolean DISABLE_MAGIC_LINK_LOGIN: Boolean
DISABLE_LOGIN_PAGE: Boolean DISABLE_LOGIN_PAGE: Boolean
DISABLE_SIGN_UP: Boolean DISABLE_SIGN_UP: Boolean
DISABLE_REDIS_FOR_ENV: Boolean DISABLE_REDIS_FOR_ENV: Boolean
DISABLE_STRONG_PASSWORD: Boolean DISABLE_STRONG_PASSWORD: Boolean
DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean
ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean
ROLES: [String!] ROLES: [String!]
PROTECTED_ROLES: [String!] PROTECTED_ROLES: [String!]
DEFAULT_ROLES: [String!] DEFAULT_ROLES: [String!]
JWT_ROLE_CLAIM: String JWT_ROLE_CLAIM: String
GOOGLE_CLIENT_ID: String GOOGLE_CLIENT_ID: String
GOOGLE_CLIENT_SECRET: String GOOGLE_CLIENT_SECRET: String
GITHUB_CLIENT_ID: String GITHUB_CLIENT_ID: String
GITHUB_CLIENT_SECRET: String GITHUB_CLIENT_SECRET: String
FACEBOOK_CLIENT_ID: String FACEBOOK_CLIENT_ID: String
FACEBOOK_CLIENT_SECRET: String FACEBOOK_CLIENT_SECRET: String
LINKEDIN_CLIENT_ID: String LINKEDIN_CLIENT_ID: String
LINKEDIN_CLIENT_SECRET: String LINKEDIN_CLIENT_SECRET: String
APPLE_CLIENT_ID: String APPLE_CLIENT_ID: String
APPLE_CLIENT_SECRET: String APPLE_CLIENT_SECRET: String
TWITTER_CLIENT_ID: String TWITTER_CLIENT_ID: String
TWITTER_CLIENT_SECRET: String TWITTER_CLIENT_SECRET: String
ORGANIZATION_NAME: String ORGANIZATION_NAME: String
ORGANIZATION_LOGO: String ORGANIZATION_LOGO: String
} }
input AdminLoginInput { input AdminLoginInput {
admin_secret: String! admin_secret: String!
} }
input AdminSignupInput { input AdminSignupInput {
admin_secret: String! admin_secret: String!
} }
input SignUpInput { input SignUpInput {
email: String! email: String!
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
password: String! password: String!
confirm_password: String! confirm_password: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
redirect_uri: String redirect_uri: String
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input LoginInput { input LoginInput {
email: String! email: String!
password: String! password: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
} }
input VerifyEmailInput { input VerifyEmailInput {
token: String! token: String!
} }
input ResendVerifyEmailInput { input ResendVerifyEmailInput {
email: String! email: String!
identifier: String! identifier: String!
} }
input UpdateProfileInput { input UpdateProfileInput {
old_password: String old_password: String
new_password: String new_password: String
confirm_new_password: String confirm_new_password: String
email: String email: String
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input UpdateUserInput { input UpdateUserInput {
id: ID! id: ID!
email: String email: String
email_verified: Boolean email_verified: Boolean
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
roles: [String] roles: [String]
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input ForgotPasswordInput { input ForgotPasswordInput {
email: String! email: String!
state: String state: String
redirect_uri: String redirect_uri: String
} }
input ResetPasswordInput { input ResetPasswordInput {
token: String! token: String!
password: String! password: String!
confirm_password: String! confirm_password: String!
} }
input DeleteUserInput { input DeleteUserInput {
email: String! email: String!
} }
input MagicLinkLoginInput { input MagicLinkLoginInput {
email: String! email: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
state: String state: String
redirect_uri: String redirect_uri: String
} }
input SessionQueryInput { input SessionQueryInput {
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
} }
input PaginationInput { input PaginationInput {
limit: Int64 limit: Int64
page: Int64 page: Int64
cursor: String
} }
input PaginatedInput { input PaginatedInput {
pagination: PaginationInput pagination: PaginationInput
} }
input OAuthRevokeInput { input OAuthRevokeInput {
refresh_token: String! refresh_token: String!
} }
input InviteMemberInput { input InviteMemberInput {
emails: [String!]! emails: [String!]!
redirect_uri: String redirect_uri: String
} }
input UpdateAccessInput { input UpdateAccessInput {
user_id: String! user_id: String!
} }
input ValidateJWTTokenInput { input ValidateJWTTokenInput {
token_type: String! token_type: String!
token: String! token: String!
roles: [String!] roles: [String!]
} }
input GenerateJWTKeysInput { input GenerateJWTKeysInput {
type: String! type: String!
} }
input ListWebhookLogRequest { input ListWebhookLogRequest {
pagination: PaginationInput pagination: PaginationInput
webhook_id: String webhook_id: String
} }
input AddWebhookRequest { input AddWebhookRequest {
event_name: String! event_name: String!
endpoint: String! endpoint: String!
enabled: Boolean! enabled: Boolean!
headers: Map headers: Map
} }
input UpdateWebhookRequest { input UpdateWebhookRequest {
id: ID! id: ID!
event_name: String event_name: String
endpoint: String endpoint: String
enabled: Boolean enabled: Boolean
headers: Map headers: Map
} }
input WebhookRequest { input WebhookRequest {
id: ID! id: ID!
} }
input TestEndpointRequest { input TestEndpointRequest {
endpoint: String! endpoint: String!
event_name: String! event_name: String!
headers: Map headers: Map
} }
input AddEmailTemplateRequest { input AddEmailTemplateRequest {
event_name: String! event_name: String!
subject: String! subject: String!
template: String! template: String!
design: String! design: String!
} }
input UpdateEmailTemplateRequest { input UpdateEmailTemplateRequest {
id: ID! id: ID!
event_name: String event_name: String
template: String template: String
subject: String subject: String
design: String design: String
} }
input DeleteEmailTemplateRequest { input DeleteEmailTemplateRequest {
id: ID! id: ID!
} }
input VerifyOTPRequest { input VerifyOTPRequest {
email: String! email: String!
otp: String! otp: String!
} }
input ResendOTPRequest { input ResendOTPRequest {
email: String! email: String!
} }
type Mutation { type Mutation {
signup(params: SignUpInput!): AuthResponse! signup(params: SignUpInput!): AuthResponse!
login(params: LoginInput!): AuthResponse! login(params: LoginInput!): AuthResponse!
magic_link_login(params: MagicLinkLoginInput!): Response! magic_link_login(params: MagicLinkLoginInput!): Response!
logout: Response! logout: Response!
update_profile(params: UpdateProfileInput!): Response! update_profile(params: UpdateProfileInput!): Response!
verify_email(params: VerifyEmailInput!): AuthResponse! verify_email(params: VerifyEmailInput!): AuthResponse!
resend_verify_email(params: ResendVerifyEmailInput!): Response! resend_verify_email(params: ResendVerifyEmailInput!): Response!
forgot_password(params: ForgotPasswordInput!): Response! forgot_password(params: ForgotPasswordInput!): Response!
reset_password(params: ResetPasswordInput!): Response! reset_password(params: ResetPasswordInput!): Response!
revoke(params: OAuthRevokeInput!): Response! revoke(params: OAuthRevokeInput!): Response!
verify_otp(params: VerifyOTPRequest!): AuthResponse! verify_otp(params: VerifyOTPRequest!): AuthResponse!
resend_otp(params: ResendOTPRequest!): Response! resend_otp(params: ResendOTPRequest!): Response!
# admin only apis # admin only apis
_delete_user(params: DeleteUserInput!): Response! _delete_user(params: DeleteUserInput!): Response!
_update_user(params: UpdateUserInput!): User! _update_user(params: UpdateUserInput!): User!
_admin_signup(params: AdminSignupInput!): Response! _admin_signup(params: AdminSignupInput!): Response!
_admin_login(params: AdminLoginInput!): Response! _admin_login(params: AdminLoginInput!): Response!
_admin_logout: Response! _admin_logout: Response!
_update_env(params: UpdateEnvInput!): Response! _update_env(params: UpdateEnvInput!): Response!
_invite_members(params: InviteMemberInput!): Response! _invite_members(params: InviteMemberInput!): Response!
_revoke_access(param: UpdateAccessInput!): Response! _revoke_access(param: UpdateAccessInput!): Response!
_enable_access(param: UpdateAccessInput!): Response! _enable_access(param: UpdateAccessInput!): Response!
_generate_jwt_keys(params: GenerateJWTKeysInput!): GenerateJWTKeysResponse! _generate_jwt_keys(params: GenerateJWTKeysInput!): GenerateJWTKeysResponse!
_add_webhook(params: AddWebhookRequest!): Response! _add_webhook(params: AddWebhookRequest!): Response!
_update_webhook(params: UpdateWebhookRequest!): Response! _update_webhook(params: UpdateWebhookRequest!): Response!
_delete_webhook(params: WebhookRequest!): Response! _delete_webhook(params: WebhookRequest!): Response!
_test_endpoint(params: TestEndpointRequest!): TestEndpointResponse! _test_endpoint(params: TestEndpointRequest!): TestEndpointResponse!
_add_email_template(params: AddEmailTemplateRequest!): Response! _add_email_template(params: AddEmailTemplateRequest!): Response!
_update_email_template(params: UpdateEmailTemplateRequest!): Response! _update_email_template(params: UpdateEmailTemplateRequest!): Response!
_delete_email_template(params: DeleteEmailTemplateRequest!): Response! _delete_email_template(params: DeleteEmailTemplateRequest!): Response!
} }
type Query { type Query {
meta: Meta! meta: Meta!
session(params: SessionQueryInput): AuthResponse! session(params: SessionQueryInput): AuthResponse!
profile: User! profile: User!
validate_jwt_token(params: ValidateJWTTokenInput!): ValidateJWTTokenResponse! validate_jwt_token(params: ValidateJWTTokenInput!): ValidateJWTTokenResponse!
# admin only apis # admin only apis
_users(params: PaginatedInput): Users! _users(params: PaginatedInput): Users!
_verification_requests(params: PaginatedInput): VerificationRequests! _verification_requests(params: PaginatedInput): VerificationRequests!
_admin_session: Response! _admin_session: Response!
_env: Env! _env: Env!
_webhook(params: WebhookRequest!): Webhook! _webhook(params: WebhookRequest!): Webhook!
_webhooks(params: PaginatedInput): Webhooks! _webhooks(params: PaginatedInput): Webhooks!
_webhook_logs(params: ListWebhookLogRequest): WebhookLogs! _webhook_logs(params: ListWebhookLogRequest): WebhookLogs!
_email_templates(params: PaginatedInput): EmailTemplates! _email_templates(params: PaginatedInput): EmailTemplates!
} }
`, BuiltIn: false}, `, BuiltIn: false},
} }
@@ -7141,6 +7151,38 @@ func (ec *executionContext) _Pagination_page(ctx context.Context, field graphql.
return ec.marshalNInt642int64(ctx, field.Selections, res) return ec.marshalNInt642int64(ctx, field.Selections, res)
} }
func (ec *executionContext) _Pagination_cursor(ctx context.Context, field graphql.CollectedField, obj *model.Pagination) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Pagination",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Cursor, 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) _Pagination_offset(ctx context.Context, field graphql.CollectedField, obj *model.Pagination) (ret graphql.Marshaler) { func (ec *executionContext) _Pagination_offset(ctx context.Context, field graphql.CollectedField, obj *model.Pagination) (ret graphql.Marshaler) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
@@ -11145,6 +11187,14 @@ func (ec *executionContext) unmarshalInputPaginationInput(ctx context.Context, o
if err != nil { if err != nil {
return it, err return it, err
} }
case "cursor":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cursor"))
it.Cursor, err = ec.unmarshalOString2ᚖstring(ctx, v)
if err != nil {
return it, err
}
} }
} }
@@ -12928,6 +12978,8 @@ func (ec *executionContext) _Pagination(ctx context.Context, sel ast.SelectionSe
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {
invalids++ invalids++
} }
case "cursor":
out.Values[i] = ec._Pagination_cursor(ctx, field, obj)
case "offset": case "offset":
out.Values[i] = ec._Pagination_offset(ctx, field, obj) out.Values[i] = ec._Pagination_offset(ctx, field, obj)
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {

View File

@@ -184,15 +184,17 @@ type PaginatedInput struct {
} }
type Pagination struct { type Pagination struct {
Limit int64 `json:"limit"` Limit int64 `json:"limit"`
Page int64 `json:"page"` Page int64 `json:"page"`
Offset int64 `json:"offset"` Cursor *string `json:"cursor"`
Total int64 `json:"total"` Offset int64 `json:"offset"`
Total int64 `json:"total"`
} }
type PaginationInput struct { type PaginationInput struct {
Limit *int64 `json:"limit"` Limit *int64 `json:"limit"`
Page *int64 `json:"page"` Page *int64 `json:"page"`
Cursor *string `json:"cursor"`
} }
type ResendOTPRequest struct { type ResendOTPRequest struct {

View File

@@ -6,492 +6,494 @@ scalar Map
scalar Any scalar Any
type Pagination { type Pagination {
limit: Int64! limit: Int64!
page: Int64! page: Int64!
offset: Int64! cursor: String
total: Int64! offset: Int64!
total: Int64!
} }
type Meta { type Meta {
version: String! version: String!
client_id: String! client_id: String!
is_google_login_enabled: Boolean! is_google_login_enabled: Boolean!
is_facebook_login_enabled: Boolean! is_facebook_login_enabled: Boolean!
is_github_login_enabled: Boolean! is_github_login_enabled: Boolean!
is_linkedin_login_enabled: Boolean! is_linkedin_login_enabled: Boolean!
is_apple_login_enabled: Boolean! is_apple_login_enabled: Boolean!
is_twitter_login_enabled: Boolean! is_twitter_login_enabled: Boolean!
is_email_verification_enabled: Boolean! is_email_verification_enabled: Boolean!
is_basic_authentication_enabled: Boolean! is_basic_authentication_enabled: Boolean!
is_magic_link_login_enabled: Boolean! is_magic_link_login_enabled: Boolean!
is_sign_up_enabled: Boolean! is_sign_up_enabled: Boolean!
is_strong_password_enabled: Boolean! is_strong_password_enabled: Boolean!
is_multi_factor_auth_enabled: Boolean! is_multi_factor_auth_enabled: Boolean!
} }
type User { type User {
id: ID! id: ID!
email: String! email: String!
email_verified: Boolean! email_verified: Boolean!
signup_methods: String! signup_methods: String!
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
# defaults to email # defaults to email
preferred_username: String preferred_username: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
phone_number_verified: Boolean phone_number_verified: Boolean
picture: String picture: String
roles: [String!]! roles: [String!]!
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
revoked_timestamp: Int64 revoked_timestamp: Int64
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
type Users { type Users {
pagination: Pagination! pagination: Pagination!
users: [User!]! users: [User!]!
} }
type VerificationRequest { type VerificationRequest {
id: ID! id: ID!
identifier: String identifier: String
token: String token: String
email: String email: String
expires: Int64 expires: Int64
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
nonce: String nonce: String
redirect_uri: String redirect_uri: String
} }
type VerificationRequests { type VerificationRequests {
pagination: Pagination! pagination: Pagination!
verification_requests: [VerificationRequest!]! verification_requests: [VerificationRequest!]!
} }
type Error { type Error {
message: String! message: String!
reason: String! reason: String!
} }
type AuthResponse { type AuthResponse {
message: String! message: String!
should_show_otp_screen: Boolean should_show_otp_screen: Boolean
access_token: String access_token: String
id_token: String id_token: String
refresh_token: String refresh_token: String
expires_in: Int64 expires_in: Int64
user: User user: User
} }
type Response { type Response {
message: String! message: String!
} }
type Env { type Env {
ACCESS_TOKEN_EXPIRY_TIME: String ACCESS_TOKEN_EXPIRY_TIME: String
ADMIN_SECRET: String ADMIN_SECRET: String
DATABASE_NAME: String DATABASE_NAME: String
DATABASE_URL: String DATABASE_URL: String
DATABASE_TYPE: String DATABASE_TYPE: String
DATABASE_USERNAME: String DATABASE_USERNAME: String
DATABASE_PASSWORD: String DATABASE_PASSWORD: String
DATABASE_HOST: String DATABASE_HOST: String
DATABASE_PORT: String DATABASE_PORT: String
CLIENT_ID: String! CLIENT_ID: String!
CLIENT_SECRET: String! CLIENT_SECRET: String!
CUSTOM_ACCESS_TOKEN_SCRIPT: String CUSTOM_ACCESS_TOKEN_SCRIPT: String
SMTP_HOST: String SMTP_HOST: String
SMTP_PORT: String SMTP_PORT: String
SMTP_USERNAME: String SMTP_USERNAME: String
SMTP_PASSWORD: String SMTP_PASSWORD: String
SENDER_EMAIL: String SENDER_EMAIL: String
JWT_TYPE: String JWT_TYPE: String
JWT_SECRET: String JWT_SECRET: String
JWT_PRIVATE_KEY: String JWT_PRIVATE_KEY: String
JWT_PUBLIC_KEY: String JWT_PUBLIC_KEY: String
ALLOWED_ORIGINS: [String!] ALLOWED_ORIGINS: [String!]
APP_URL: String APP_URL: String
REDIS_URL: String REDIS_URL: String
RESET_PASSWORD_URL: String RESET_PASSWORD_URL: String
DISABLE_EMAIL_VERIFICATION: Boolean! DISABLE_EMAIL_VERIFICATION: Boolean!
DISABLE_BASIC_AUTHENTICATION: Boolean! DISABLE_BASIC_AUTHENTICATION: Boolean!
DISABLE_MAGIC_LINK_LOGIN: Boolean! DISABLE_MAGIC_LINK_LOGIN: Boolean!
DISABLE_LOGIN_PAGE: Boolean! DISABLE_LOGIN_PAGE: Boolean!
DISABLE_SIGN_UP: Boolean! DISABLE_SIGN_UP: Boolean!
DISABLE_REDIS_FOR_ENV: Boolean! DISABLE_REDIS_FOR_ENV: Boolean!
DISABLE_STRONG_PASSWORD: Boolean! DISABLE_STRONG_PASSWORD: Boolean!
DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean! DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean!
ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean! ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean!
ROLES: [String!] ROLES: [String!]
PROTECTED_ROLES: [String!] PROTECTED_ROLES: [String!]
DEFAULT_ROLES: [String!] DEFAULT_ROLES: [String!]
JWT_ROLE_CLAIM: String JWT_ROLE_CLAIM: String
GOOGLE_CLIENT_ID: String GOOGLE_CLIENT_ID: String
GOOGLE_CLIENT_SECRET: String GOOGLE_CLIENT_SECRET: String
GITHUB_CLIENT_ID: String GITHUB_CLIENT_ID: String
GITHUB_CLIENT_SECRET: String GITHUB_CLIENT_SECRET: String
FACEBOOK_CLIENT_ID: String FACEBOOK_CLIENT_ID: String
FACEBOOK_CLIENT_SECRET: String FACEBOOK_CLIENT_SECRET: String
LINKEDIN_CLIENT_ID: String LINKEDIN_CLIENT_ID: String
LINKEDIN_CLIENT_SECRET: String LINKEDIN_CLIENT_SECRET: String
APPLE_CLIENT_ID: String APPLE_CLIENT_ID: String
APPLE_CLIENT_SECRET: String APPLE_CLIENT_SECRET: String
TWITTER_CLIENT_ID: String TWITTER_CLIENT_ID: String
TWITTER_CLIENT_SECRET: String TWITTER_CLIENT_SECRET: String
ORGANIZATION_NAME: String ORGANIZATION_NAME: String
ORGANIZATION_LOGO: String ORGANIZATION_LOGO: String
} }
type ValidateJWTTokenResponse { type ValidateJWTTokenResponse {
is_valid: Boolean! is_valid: Boolean!
} }
type GenerateJWTKeysResponse { type GenerateJWTKeysResponse {
secret: String secret: String
public_key: String public_key: String
private_key: String private_key: String
} }
type Webhook { type Webhook {
id: ID! id: ID!
event_name: String event_name: String
endpoint: String endpoint: String
enabled: Boolean enabled: Boolean
headers: Map headers: Map
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type Webhooks { type Webhooks {
pagination: Pagination! pagination: Pagination!
webhooks: [Webhook!]! webhooks: [Webhook!]!
} }
type WebhookLog { type WebhookLog {
id: ID! id: ID!
http_status: Int64 http_status: Int64
response: String response: String
request: String request: String
webhook_id: ID webhook_id: ID
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type TestEndpointResponse { type TestEndpointResponse {
http_status: Int64 http_status: Int64
response: String response: String
} }
type WebhookLogs { type WebhookLogs {
pagination: Pagination! pagination: Pagination!
webhook_logs: [WebhookLog!]! webhook_logs: [WebhookLog!]!
} }
type EmailTemplate { type EmailTemplate {
id: ID! id: ID!
event_name: String! event_name: String!
template: String! template: String!
design: String! design: String!
subject: String! subject: String!
created_at: Int64 created_at: Int64
updated_at: Int64 updated_at: Int64
} }
type EmailTemplates { type EmailTemplates {
pagination: Pagination! pagination: Pagination!
email_templates: [EmailTemplate!]! email_templates: [EmailTemplate!]!
} }
input UpdateEnvInput { input UpdateEnvInput {
ACCESS_TOKEN_EXPIRY_TIME: String ACCESS_TOKEN_EXPIRY_TIME: String
ADMIN_SECRET: String ADMIN_SECRET: String
CUSTOM_ACCESS_TOKEN_SCRIPT: String CUSTOM_ACCESS_TOKEN_SCRIPT: String
OLD_ADMIN_SECRET: String OLD_ADMIN_SECRET: String
SMTP_HOST: String SMTP_HOST: String
SMTP_PORT: String SMTP_PORT: String
SMTP_USERNAME: String SMTP_USERNAME: String
SMTP_PASSWORD: String SMTP_PASSWORD: String
SENDER_EMAIL: String SENDER_EMAIL: String
JWT_TYPE: String JWT_TYPE: String
JWT_SECRET: String JWT_SECRET: String
JWT_PRIVATE_KEY: String JWT_PRIVATE_KEY: String
JWT_PUBLIC_KEY: String JWT_PUBLIC_KEY: String
ALLOWED_ORIGINS: [String!] ALLOWED_ORIGINS: [String!]
APP_URL: String APP_URL: String
RESET_PASSWORD_URL: String RESET_PASSWORD_URL: String
DISABLE_EMAIL_VERIFICATION: Boolean DISABLE_EMAIL_VERIFICATION: Boolean
DISABLE_BASIC_AUTHENTICATION: Boolean DISABLE_BASIC_AUTHENTICATION: Boolean
DISABLE_MAGIC_LINK_LOGIN: Boolean DISABLE_MAGIC_LINK_LOGIN: Boolean
DISABLE_LOGIN_PAGE: Boolean DISABLE_LOGIN_PAGE: Boolean
DISABLE_SIGN_UP: Boolean DISABLE_SIGN_UP: Boolean
DISABLE_REDIS_FOR_ENV: Boolean DISABLE_REDIS_FOR_ENV: Boolean
DISABLE_STRONG_PASSWORD: Boolean DISABLE_STRONG_PASSWORD: Boolean
DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean DISABLE_MULTI_FACTOR_AUTHENTICATION: Boolean
ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean ENFORCE_MULTI_FACTOR_AUTHENTICATION: Boolean
ROLES: [String!] ROLES: [String!]
PROTECTED_ROLES: [String!] PROTECTED_ROLES: [String!]
DEFAULT_ROLES: [String!] DEFAULT_ROLES: [String!]
JWT_ROLE_CLAIM: String JWT_ROLE_CLAIM: String
GOOGLE_CLIENT_ID: String GOOGLE_CLIENT_ID: String
GOOGLE_CLIENT_SECRET: String GOOGLE_CLIENT_SECRET: String
GITHUB_CLIENT_ID: String GITHUB_CLIENT_ID: String
GITHUB_CLIENT_SECRET: String GITHUB_CLIENT_SECRET: String
FACEBOOK_CLIENT_ID: String FACEBOOK_CLIENT_ID: String
FACEBOOK_CLIENT_SECRET: String FACEBOOK_CLIENT_SECRET: String
LINKEDIN_CLIENT_ID: String LINKEDIN_CLIENT_ID: String
LINKEDIN_CLIENT_SECRET: String LINKEDIN_CLIENT_SECRET: String
APPLE_CLIENT_ID: String APPLE_CLIENT_ID: String
APPLE_CLIENT_SECRET: String APPLE_CLIENT_SECRET: String
TWITTER_CLIENT_ID: String TWITTER_CLIENT_ID: String
TWITTER_CLIENT_SECRET: String TWITTER_CLIENT_SECRET: String
ORGANIZATION_NAME: String ORGANIZATION_NAME: String
ORGANIZATION_LOGO: String ORGANIZATION_LOGO: String
} }
input AdminLoginInput { input AdminLoginInput {
admin_secret: String! admin_secret: String!
} }
input AdminSignupInput { input AdminSignupInput {
admin_secret: String! admin_secret: String!
} }
input SignUpInput { input SignUpInput {
email: String! email: String!
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
password: String! password: String!
confirm_password: String! confirm_password: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
redirect_uri: String redirect_uri: String
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input LoginInput { input LoginInput {
email: String! email: String!
password: String! password: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
} }
input VerifyEmailInput { input VerifyEmailInput {
token: String! token: String!
} }
input ResendVerifyEmailInput { input ResendVerifyEmailInput {
email: String! email: String!
identifier: String! identifier: String!
} }
input UpdateProfileInput { input UpdateProfileInput {
old_password: String old_password: String
new_password: String new_password: String
confirm_new_password: String confirm_new_password: String
email: String email: String
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input UpdateUserInput { input UpdateUserInput {
id: ID! id: ID!
email: String email: String
email_verified: Boolean email_verified: Boolean
given_name: String given_name: String
family_name: String family_name: String
middle_name: String middle_name: String
nickname: String nickname: String
gender: String gender: String
birthdate: String birthdate: String
phone_number: String phone_number: String
picture: String picture: String
roles: [String] roles: [String]
is_multi_factor_auth_enabled: Boolean is_multi_factor_auth_enabled: Boolean
} }
input ForgotPasswordInput { input ForgotPasswordInput {
email: String! email: String!
state: String state: String
redirect_uri: String redirect_uri: String
} }
input ResetPasswordInput { input ResetPasswordInput {
token: String! token: String!
password: String! password: String!
confirm_password: String! confirm_password: String!
} }
input DeleteUserInput { input DeleteUserInput {
email: String! email: String!
} }
input MagicLinkLoginInput { input MagicLinkLoginInput {
email: String! email: String!
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
state: String state: String
redirect_uri: String redirect_uri: String
} }
input SessionQueryInput { input SessionQueryInput {
roles: [String!] roles: [String!]
scope: [String!] scope: [String!]
} }
input PaginationInput { input PaginationInput {
limit: Int64 limit: Int64
page: Int64 page: Int64
cursor: String
} }
input PaginatedInput { input PaginatedInput {
pagination: PaginationInput pagination: PaginationInput
} }
input OAuthRevokeInput { input OAuthRevokeInput {
refresh_token: String! refresh_token: String!
} }
input InviteMemberInput { input InviteMemberInput {
emails: [String!]! emails: [String!]!
redirect_uri: String redirect_uri: String
} }
input UpdateAccessInput { input UpdateAccessInput {
user_id: String! user_id: String!
} }
input ValidateJWTTokenInput { input ValidateJWTTokenInput {
token_type: String! token_type: String!
token: String! token: String!
roles: [String!] roles: [String!]
} }
input GenerateJWTKeysInput { input GenerateJWTKeysInput {
type: String! type: String!
} }
input ListWebhookLogRequest { input ListWebhookLogRequest {
pagination: PaginationInput pagination: PaginationInput
webhook_id: String webhook_id: String
} }
input AddWebhookRequest { input AddWebhookRequest {
event_name: String! event_name: String!
endpoint: String! endpoint: String!
enabled: Boolean! enabled: Boolean!
headers: Map headers: Map
} }
input UpdateWebhookRequest { input UpdateWebhookRequest {
id: ID! id: ID!
event_name: String event_name: String
endpoint: String endpoint: String
enabled: Boolean enabled: Boolean
headers: Map headers: Map
} }
input WebhookRequest { input WebhookRequest {
id: ID! id: ID!
} }
input TestEndpointRequest { input TestEndpointRequest {
endpoint: String! endpoint: String!
event_name: String! event_name: String!
headers: Map headers: Map
} }
input AddEmailTemplateRequest { input AddEmailTemplateRequest {
event_name: String! event_name: String!
subject: String! subject: String!
template: String! template: String!
design: String! design: String!
} }
input UpdateEmailTemplateRequest { input UpdateEmailTemplateRequest {
id: ID! id: ID!
event_name: String event_name: String
template: String template: String
subject: String subject: String
design: String design: String
} }
input DeleteEmailTemplateRequest { input DeleteEmailTemplateRequest {
id: ID! id: ID!
} }
input VerifyOTPRequest { input VerifyOTPRequest {
email: String! email: String!
otp: String! otp: String!
} }
input ResendOTPRequest { input ResendOTPRequest {
email: String! email: String!
} }
type Mutation { type Mutation {
signup(params: SignUpInput!): AuthResponse! signup(params: SignUpInput!): AuthResponse!
login(params: LoginInput!): AuthResponse! login(params: LoginInput!): AuthResponse!
magic_link_login(params: MagicLinkLoginInput!): Response! magic_link_login(params: MagicLinkLoginInput!): Response!
logout: Response! logout: Response!
update_profile(params: UpdateProfileInput!): Response! update_profile(params: UpdateProfileInput!): Response!
verify_email(params: VerifyEmailInput!): AuthResponse! verify_email(params: VerifyEmailInput!): AuthResponse!
resend_verify_email(params: ResendVerifyEmailInput!): Response! resend_verify_email(params: ResendVerifyEmailInput!): Response!
forgot_password(params: ForgotPasswordInput!): Response! forgot_password(params: ForgotPasswordInput!): Response!
reset_password(params: ResetPasswordInput!): Response! reset_password(params: ResetPasswordInput!): Response!
revoke(params: OAuthRevokeInput!): Response! revoke(params: OAuthRevokeInput!): Response!
verify_otp(params: VerifyOTPRequest!): AuthResponse! verify_otp(params: VerifyOTPRequest!): AuthResponse!
resend_otp(params: ResendOTPRequest!): Response! resend_otp(params: ResendOTPRequest!): Response!
# admin only apis # admin only apis
_delete_user(params: DeleteUserInput!): Response! _delete_user(params: DeleteUserInput!): Response!
_update_user(params: UpdateUserInput!): User! _update_user(params: UpdateUserInput!): User!
_admin_signup(params: AdminSignupInput!): Response! _admin_signup(params: AdminSignupInput!): Response!
_admin_login(params: AdminLoginInput!): Response! _admin_login(params: AdminLoginInput!): Response!
_admin_logout: Response! _admin_logout: Response!
_update_env(params: UpdateEnvInput!): Response! _update_env(params: UpdateEnvInput!): Response!
_invite_members(params: InviteMemberInput!): Response! _invite_members(params: InviteMemberInput!): Response!
_revoke_access(param: UpdateAccessInput!): Response! _revoke_access(param: UpdateAccessInput!): Response!
_enable_access(param: UpdateAccessInput!): Response! _enable_access(param: UpdateAccessInput!): Response!
_generate_jwt_keys(params: GenerateJWTKeysInput!): GenerateJWTKeysResponse! _generate_jwt_keys(params: GenerateJWTKeysInput!): GenerateJWTKeysResponse!
_add_webhook(params: AddWebhookRequest!): Response! _add_webhook(params: AddWebhookRequest!): Response!
_update_webhook(params: UpdateWebhookRequest!): Response! _update_webhook(params: UpdateWebhookRequest!): Response!
_delete_webhook(params: WebhookRequest!): Response! _delete_webhook(params: WebhookRequest!): Response!
_test_endpoint(params: TestEndpointRequest!): TestEndpointResponse! _test_endpoint(params: TestEndpointRequest!): TestEndpointResponse!
_add_email_template(params: AddEmailTemplateRequest!): Response! _add_email_template(params: AddEmailTemplateRequest!): Response!
_update_email_template(params: UpdateEmailTemplateRequest!): Response! _update_email_template(params: UpdateEmailTemplateRequest!): Response!
_delete_email_template(params: DeleteEmailTemplateRequest!): Response! _delete_email_template(params: DeleteEmailTemplateRequest!): Response!
} }
type Query { type Query {
meta: Meta! meta: Meta!
session(params: SessionQueryInput): AuthResponse! session(params: SessionQueryInput): AuthResponse!
profile: User! profile: User!
validate_jwt_token(params: ValidateJWTTokenInput!): ValidateJWTTokenResponse! validate_jwt_token(params: ValidateJWTTokenInput!): ValidateJWTTokenResponse!
# admin only apis # admin only apis
_users(params: PaginatedInput): Users! _users(params: PaginatedInput): Users!
_verification_requests(params: PaginatedInput): VerificationRequests! _verification_requests(params: PaginatedInput): VerificationRequests!
_admin_session: Response! _admin_session: Response!
_env: Env! _env: Env!
_webhook(params: WebhookRequest!): Webhook! _webhook(params: WebhookRequest!): Webhook!
_webhooks(params: PaginatedInput): Webhooks! _webhooks(params: PaginatedInput): Webhooks!
_webhook_logs(params: ListWebhookLogRequest): WebhookLogs! _webhook_logs(params: ListWebhookLogRequest): WebhookLogs!
_email_templates(params: PaginatedInput): EmailTemplates! _email_templates(params: PaginatedInput): EmailTemplates!
} }

View File

@@ -287,9 +287,9 @@ func processGithubUserInfo(code string) (models.User, error) {
log.Debug("Failed to create github user info request: ", err) log.Debug("Failed to create github user info request: ", err)
return user, fmt.Errorf("error creating github user info request: %s", err.Error()) return user, fmt.Errorf("error creating github user info request: %s", err.Error())
} }
req.Header = http.Header{ req.Header.Set(
"Authorization": []string{fmt.Sprintf("token %s", oauth2Token.AccessToken)}, "Authorization", fmt.Sprintf("token %s", oauth2Token.AccessToken),
} )
response, err := client.Do(req) response, err := client.Do(req)
if err != nil { if err != nil {
@@ -331,14 +331,14 @@ func processGithubUserInfo(code string) (models.User, error) {
} }
// fetch using /users/email endpoint // fetch using /users/email endpoint
req, err := http.NewRequest("GET", constants.GithubUserEmails, nil) req, err := http.NewRequest(http.MethodGet, constants.GithubUserEmails, nil)
if err != nil { if err != nil {
log.Debug("Failed to create github emails request: ", err) log.Debug("Failed to create github emails request: ", err)
return user, fmt.Errorf("error creating github user info request: %s", err.Error()) return user, fmt.Errorf("error creating github user info request: %s", err.Error())
} }
req.Header = http.Header{ req.Header.Set(
"Authorization": []string{fmt.Sprintf("token %s", oauth2Token.AccessToken)}, "Authorization", fmt.Sprintf("token %s", oauth2Token.AccessToken),
} )
response, err := client.Do(req) response, err := client.Do(req)
if err != nil { if err != nil {

View File

@@ -109,6 +109,7 @@ func main() {
router := routes.InitRouter(log) router := routes.InitRouter(log)
log.Info("Starting Authorizer: ", VERSION) log.Info("Starting Authorizer: ", VERSION)
port, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyPort) port, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyPort)
log.Info("Authorizer running at PORT: ", port)
if err != nil { if err != nil {
log.Info("Error while getting port from env using default port 8080: ", err) log.Info("Error while getting port from env using default port 8080: ", err)
port = "8080" port = "8080"

View File

@@ -75,6 +75,7 @@ func InitOAuth() error {
ClientSecret: githubClientSecret, ClientSecret: githubClientSecret,
RedirectURL: "/oauth_callback/github", RedirectURL: "/oauth_callback/github",
Endpoint: githubOAuth2.Endpoint, Endpoint: githubOAuth2.Endpoint,
Scopes: []string{"read:user", "user:email"},
} }
} }

View File

@@ -50,7 +50,7 @@ func LoginResolver(ctx context.Context, params model.LoginInput) (*model.AuthRes
user, err := db.Provider.GetUserByEmail(ctx, params.Email) user, err := db.Provider.GetUserByEmail(ctx, params.Email)
if err != nil { if err != nil {
log.Debug("Failed to get user by email: ", err) log.Debug("Failed to get user by email: ", err)
return res, fmt.Errorf(`user with this email not found`) return res, fmt.Errorf(`bad user credentials`)
} }
if user.RevokedTimestamp != nil { if user.RevokedTimestamp != nil {
@@ -72,7 +72,7 @@ func LoginResolver(ctx context.Context, params model.LoginInput) (*model.AuthRes
if err != nil { if err != nil {
log.Debug("Failed to compare password: ", err) log.Debug("Failed to compare password: ", err)
return res, fmt.Errorf(`invalid password`) return res, fmt.Errorf(`bad user credentials`)
} }
defaultRolesString, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyDefaultRoles) defaultRolesString, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyDefaultRoles)

View File

@@ -30,8 +30,8 @@ func IsValidOrigin(url string) bool {
replacedString := origin replacedString := origin
// if has regex whitelisted domains // if has regex whitelisted domains
if strings.Contains(origin, "*") { if strings.Contains(origin, "*") {
replacedString = strings.Replace(origin, ".", "\\.", -1) replacedString = strings.ReplaceAll(origin, ".", "\\.")
replacedString = strings.Replace(replacedString, "*", ".*", -1) replacedString = strings.ReplaceAll(replacedString, "*", ".*")
if strings.HasPrefix(replacedString, ".*") { if strings.HasPrefix(replacedString, ".*") {
replacedString += "\\b" replacedString += "\\b"