mirror of
https://github.com/FlowiseAI/Flowise.git
synced 2026-10-12 02:02:17 +00:00
fix: remove basic auth (#5680)
Co-authored-by: yau-wd <[email protected]>
This commit is contained in:
@@ -102,7 +102,6 @@
|
||||
"csv-parser": "^3.0.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.17.3",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"express-mysql-session": "^3.0.3",
|
||||
"express-rate-limit": "^6.9.0",
|
||||
"express-session": "^1.18.1",
|
||||
|
||||
@@ -130,27 +130,6 @@ export class AccountController {
|
||||
}
|
||||
}
|
||||
|
||||
public async getBasicAuth(req: Request, res: Response) {
|
||||
if (process.env.FLOWISE_USERNAME && process.env.FLOWISE_PASSWORD) {
|
||||
return res.status(StatusCodes.OK).json({
|
||||
isUsernamePasswordSet: true
|
||||
})
|
||||
} else {
|
||||
return res.status(StatusCodes.OK).json({
|
||||
isUsernamePasswordSet: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public async checkBasicAuth(req: Request, res: Response) {
|
||||
const { username, password } = req.body
|
||||
if (username === process.env.FLOWISE_USERNAME && password === process.env.FLOWISE_PASSWORD) {
|
||||
return res.json({ message: 'Authentication successful' })
|
||||
} else {
|
||||
return res.json({ message: 'Authentication failed' })
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(req: Request, res: Response, next: NextFunction) {
|
||||
let queryRunner: QueryRunner | undefined
|
||||
try {
|
||||
|
||||
@@ -32,10 +32,6 @@ router.post('/reset-password', accountController.resetPassword)
|
||||
|
||||
router.post('/billing', accountController.createStripeCustomerPortalSession)
|
||||
|
||||
router.get('/basic-auth', accountController.getBasicAuth)
|
||||
|
||||
router.post('/basic-auth', accountController.checkBasicAuth)
|
||||
|
||||
router.delete('/delete', accountController.delete)
|
||||
|
||||
export default router
|
||||
|
||||
@@ -34,7 +34,6 @@ export const WHITELIST_URLS = [
|
||||
'/api/v1/account/forgot-password',
|
||||
'/api/v1/account/reset-password',
|
||||
'/api/v1/account/confirm-email-change',
|
||||
'/api/v1/account/basic-auth',
|
||||
'/api/v1/loginmethod/default',
|
||||
'/api/v1/pricing',
|
||||
'/api/v1/user/test',
|
||||
|
||||
@@ -9,8 +9,6 @@ const forgotPassword = (body) => client.post('/account/forgot-password', body)
|
||||
const resetPassword = (body) => client.post('/account/reset-password', body)
|
||||
const getBillingData = () => client.post('/account/billing')
|
||||
const logout = () => client.post('/account/logout')
|
||||
const getBasicAuth = () => client.get('/account/basic-auth')
|
||||
const checkBasicAuth = (body) => client.post('/account/basic-auth', body)
|
||||
const deleteAccount = (body) => client.delete('/account/delete', { data: body })
|
||||
|
||||
export default {
|
||||
@@ -23,7 +21,5 @@ export default {
|
||||
forgotPassword,
|
||||
resetPassword,
|
||||
logout,
|
||||
getBasicAuth,
|
||||
checkBasicAuth,
|
||||
deleteAccount
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'
|
||||
import { z } from 'zod/v3'
|
||||
|
||||
// material-ui
|
||||
import { Alert, Box, Button, Chip, Divider, Icon, List, ListItemText, Stack, TextField, Typography } from '@mui/material'
|
||||
import { Alert, Box, Button, Chip, Divider, Icon, List, ListItemText, Stack, Typography } from '@mui/material'
|
||||
|
||||
// project imports
|
||||
import { StyledButton } from '@/ui-component/button/StyledButton'
|
||||
@@ -91,17 +91,13 @@ const OrganizationSetupPage = () => {
|
||||
const [confirmPassword, setConfirmPassword] = useState('')
|
||||
const [username, setUsername] = useState('')
|
||||
const [orgName, setOrgName] = useState('')
|
||||
const [existingUsername, setExistingUsername] = useState('')
|
||||
const [existingPassword, setExistingPassword] = useState('')
|
||||
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [authError, setAuthError] = useState('')
|
||||
const [successMsg, setSuccessMsg] = useState(undefined)
|
||||
const [requiresAuthentication, setRequiresAuthentication] = useState(false)
|
||||
|
||||
const loginApi = useApi(authApi.login)
|
||||
const registerAccountApi = useApi(accountApi.registerAccount)
|
||||
const getBasicAuthApi = useApi(accountApi.getBasicAuth)
|
||||
const navigate = useNavigate()
|
||||
|
||||
const getDefaultProvidersApi = useApi(loginMethodApi.getDefaultLoginMethods)
|
||||
@@ -120,26 +116,6 @@ const OrganizationSetupPage = () => {
|
||||
setLoading(true)
|
||||
setAuthError('')
|
||||
|
||||
// Check authentication first if required
|
||||
if (requiresAuthentication) {
|
||||
try {
|
||||
const authResult = await accountApi.checkBasicAuth({
|
||||
username: existingUsername,
|
||||
password: existingPassword
|
||||
})
|
||||
|
||||
if (!authResult || !authResult.data || authResult.data.message !== 'Authentication successful') {
|
||||
setAuthError('Authentication failed. Please check your existing credentials.')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
setAuthError('Authentication failed. Please check your existing credentials.')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Proceed with registration after successful authentication
|
||||
const body = {
|
||||
user: {
|
||||
@@ -179,17 +155,9 @@ const OrganizationSetupPage = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [registerAccountApi.error])
|
||||
|
||||
useEffect(() => {
|
||||
if (getBasicAuthApi.data && getBasicAuthApi.data.isUsernamePasswordSet === true) {
|
||||
setRequiresAuthentication(true)
|
||||
}
|
||||
}, [getBasicAuthApi.data])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpenSource) {
|
||||
getDefaultProvidersApi.request()
|
||||
} else {
|
||||
getBasicAuthApi.request()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
@@ -270,11 +238,6 @@ const OrganizationSetupPage = () => {
|
||||
<Stack sx={{ gap: 1 }}>
|
||||
<Typography variant='h1'>Setup Account</Typography>
|
||||
</Stack>
|
||||
{requiresAuthentication && (
|
||||
<Alert severity='info'>
|
||||
Application authentication now requires email and password. Contact administrator to setup an account.
|
||||
</Alert>
|
||||
)}
|
||||
{(isOpenSource || isEnterpriseLicensed) && (
|
||||
<Typography variant='caption'>
|
||||
Account setup does not make any external connections, your data stays securely on your locally hosted server.
|
||||
@@ -282,48 +245,6 @@ const OrganizationSetupPage = () => {
|
||||
)}
|
||||
<form onSubmit={register}>
|
||||
<Stack sx={{ width: '100%', flexDirection: 'column', alignItems: 'left', justifyContent: 'center', gap: 2 }}>
|
||||
{requiresAuthentication && (
|
||||
<>
|
||||
<Box>
|
||||
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
||||
<Typography sx={{ mb: 1 }}>
|
||||
Existing Username<span style={{ color: 'red' }}> *</span>
|
||||
</Typography>
|
||||
<div style={{ flexGrow: 1 }}></div>
|
||||
</div>
|
||||
<TextField
|
||||
fullWidth
|
||||
placeholder='Existing Username'
|
||||
value={existingUsername}
|
||||
onChange={(e) => setExistingUsername(e.target.value)}
|
||||
/>
|
||||
<Typography variant='caption'>
|
||||
<i>Existing username that was set as FLOWISE_USERNAME environment variable</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box>
|
||||
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
||||
<Typography sx={{ mb: 1 }}>
|
||||
Existing Password<span style={{ color: 'red' }}> *</span>
|
||||
</Typography>
|
||||
<div style={{ flexGrow: 1 }}></div>
|
||||
</div>
|
||||
<TextField
|
||||
fullWidth
|
||||
type='password'
|
||||
placeholder='Existing Password'
|
||||
value={existingPassword}
|
||||
onChange={(e) => setExistingPassword(e.target.value)}
|
||||
/>
|
||||
<Typography variant='caption'>
|
||||
<i>Existing password that was set as FLOWISE_PASSWORD environment variable</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
<Divider>
|
||||
<Chip label='New Account Details' size='small' />
|
||||
</Divider>
|
||||
</>
|
||||
)}
|
||||
{isEnterpriseLicensed && (
|
||||
<>
|
||||
<Box>
|
||||
@@ -415,12 +336,7 @@ const OrganizationSetupPage = () => {
|
||||
<i>Reconfirm your password. Must match the password typed above.</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
<StyledButton
|
||||
variant='contained'
|
||||
style={{ borderRadius: 12, height: 40, marginRight: 5 }}
|
||||
type='submit'
|
||||
disabled={requiresAuthentication && (!existingUsername || !existingPassword)}
|
||||
>
|
||||
<StyledButton variant='contained' style={{ borderRadius: 12, height: 40, marginRight: 5 }} type='submit'>
|
||||
Sign Up
|
||||
</StyledButton>
|
||||
{configuredSsoProviders && configuredSsoProviders.length > 0 && <Divider sx={{ width: '100%' }}>OR</Divider>}
|
||||
|
||||
Generated
-18
@@ -924,9 +924,6 @@ importers:
|
||||
express:
|
||||
specifier: ^4.17.3
|
||||
version: 4.18.3
|
||||
express-basic-auth:
|
||||
specifier: ^1.2.1
|
||||
version: 1.2.1
|
||||
express-mysql-session:
|
||||
specifier: ^3.0.3
|
||||
version: 3.0.3
|
||||
@@ -10206,10 +10203,6 @@ packages:
|
||||
resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -12344,9 +12337,6 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-L6YQ1wQ/mNjVLAmK3AG1RK6VkokA1BIY6wmiH304Xtt/cLTps40EusZsU1Uop+v9lTDPxdtzbFmdXfFO3KEnwA==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-sEYrzFrOs3er+Ie/uk1dt93qz4AQ9SU1mpJJ0HPs0MJ4t4hE9AcDRNq0sZQUwy2F/SbXusBt1E5+FY6KzSqXNg==}
|
||||
|
||||
@@ -32937,10 +32927,6 @@ snapshots:
|
||||
mixin-deep: 1.3.2
|
||||
pascalcase: 0.1.1
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
safe-buffer: 5.1.2
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -35544,10 +35530,6 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
basic-auth: 2.0.1
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
debug: 4.3.4([email protected])
|
||||
|
||||
Reference in New Issue
Block a user