Commit graph

4,697 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
8d96c32c2b 🔧 chore(manager.py): add teardown method to DatabaseManager class for cleaning up the database
🔧 chore(manager.py): remove default superuser if auto_login is enabled during teardown to ensure clean database state
2023-08-31 10:21:03 -03:00
Gabriel Luiz Freitas Almeida
29a616bc77 🐛 fix(utils.py): remove unnecessary code and simplify create_super_user function
 feat(utils.py): refactor create_user_longterm_token to use settings_manager for username and password
2023-08-31 10:20:53 -03:00
Gabriel Luiz Freitas Almeida
91ea879e50 🔧 fix(base.py): make Service class inherit from ABC to make it an abstract base class
 feat(manager.py): add debug log messages for service creation and update to improve debugging
 feat(manager.py): add teardown method to ServiceManager to teardown all services and clear state
 feat(manager.py): add teardown_services function to teardown all services and clear state
2023-08-31 10:20:40 -03:00
Gabriel Luiz Freitas Almeida
08407abe9a 🔧 chore(main.py): add teardown_services function to be called on app shutdown event to properly clean up resources 2023-08-31 10:20:20 -03:00
anovazzi1
19dd994c12 chore(frontend): update dependencies in package.json
- Update "@emotion/react" to version "^11.11.1"
- Update "@emotion/styled" to version "^11.11.0"
- Update "@headlessui/react" to version "^1.7.17"
- Update "@heroicons/react" to version "^2.0.18"
- Update "@mui/material" to version "^5.14.7"
- Update "@tabler/icons-react" to version "^2.32.0"
- Update "@tailwindcss/forms" to version "^0.5.6"
- Update "ace-builds" to version "^1.24.1"
- Update "axios" to version "^1.5.0"
- Update "class-variance-authority" to version "^0.6.1"
- Update "dompurify" to version "^3.0.5"
- Update "esbuild" to version "^0.17.19"
- Update "react-error-boundary" to version "^4.0.11"
- Update "react-icons" to version "^4.10.1"
- Update "react-router-dom" to version "^6.15.0"
- Update "react-tabs" to version "^6.0.2"
- Update "react-tooltip" to version "^5.21.1"
- Update "rehype-mathjax" to version "^4.0.3"
- Update "shadcn-ui" to version "^0.2.3"
- Update "tailwind-merge" to version "^1.14.0"
- Update "tailwindcss-animate" to version "^1.0.7"

chore(frontend): update devDependencies in package.json

- Update "@swc/cli" to version "^0.1.62"
- Update "@swc/core" to version "^1.3.80"
- Update "@tailwindcss/typography" to version "^0.5.9"
- Update "@testing-library/jest-dom" to version "^5.17.0"
- Update "@testing-library/react" to version "^13.4.0"
- Update "@testing-library/user-event" to version "^13.5.0"
- Update "@types/lodash" to version "^4.14.197"
- Update "@types/node" to version "^16.18.46"
- Update "@types/react
2023-08-30 19:12:28 -03:00
anovazzi1
f30c818053
Improves secret key implementation (#846)
Secret key is now set once if not passed using the env variable and
saved into the CONFIG_DIR.
There are separate implementations depending on the OS
2023-08-30 19:08:19 -03:00
Cristhian Zanforlin Lousa
c06cfce385 🐛 fix(api.tsx): handle null values when calling login function to prevent potential errors 2023-08-30 19:02:52 -03:00
Gabriel Luiz Freitas Almeida
98dfc01934 🔒 refactor(auth.py): move SECRET_KEY logic to AuthSettings class to improve code organization and reusability
🔒 refactor(base.py): remove SECRET_KEY field from Settings class since it is now handled by AuthSettings class
🔒 refactor(manager.py): pass CONFIG_DIR to AuthSettings constructor when creating an instance
2023-08-30 18:58:12 -03:00
anovazzi1
60945ce883 added check to onCloseWebsocket event 2023-08-30 18:49:41 -03:00
Gabriel Luiz Freitas Almeida
3a90b07235 fix exception 2023-08-30 18:18:22 -03:00
Gabriel Luiz Freitas Almeida
1407719f2f 🐛 fix(chat.py): handle unauthorized error in chat websocket to return WS_1008_POLICY_VIOLATION status code and "Unauthorized" reason 2023-08-30 18:12:03 -03:00
anovazzi1
418bddd322 fix(formModal): encode the accessToken parameter in the chatEndpoint URL to handle special characters correctly
The accessToken parameter in the chatEndpoint URL is now encoded using the encodeURIComponent function to handle special characters correctly. This ensures that the accessToken is properly passed to the chat endpoint without causing any issues.
2023-08-30 18:01:21 -03:00
Gabriel Luiz Freitas Almeida
9d7deccc53 🐛 fix(chat.py): handle and log any exception that occurs in the chat websocket to prevent unhandled errors and provide better error messages 2023-08-30 17:54:58 -03:00
Gabriel Luiz Freitas Almeida
163a7c49cd 🐛 fix(utils.py): fix TypeError when comparing offset-naive and offset-aware datetimes in get_current_user function 2023-08-30 17:51:57 -03:00
Gabriel Luiz Freitas Almeida
61f0a93cc6 🔥 refactor(manager.py): remove redundant code in connect method by removing unnecessary await websocket.accept() call 2023-08-30 17:40:22 -03:00
Gabriel Luiz Freitas Almeida
a8b9c08a9d 🐛 fix(base.py): fix issue with loading and saving secret key in Settings class
🐛 fix(utils.py): fix issue with writing secret key to file in write_secret_to_file function
2023-08-30 17:39:51 -03:00
Gabriel Luiz Freitas Almeida
eacf558e70 🐛 fix(chat.py): close websocket connection with status code 1008 and reason "Unauthorized" if user is not authenticated or inactive
🐛 fix(auth/utils.py): raise credentials_exception if token has expired
2023-08-30 17:29:07 -03:00
Gabriel Luiz Freitas Almeida
53b9565ac6 Merge remote-tracking branch 'origin/dev' into fix_secret_key 2023-08-30 16:48:04 -03:00
Gabriel Luiz Freitas Almeida
269116b834 🐛 fix(test_cli.py): convert temp_dir to string before checking if it is in COMPONENTS_PATH to ensure comparison correctness 2023-08-30 16:25:52 -03:00
Gabriel Luiz Freitas Almeida
b3c2fd26a5 🐛 fix(base.py): fix import statements for read_secret_from_file and write_secret_to_file functions
🔒 chore(utils.py): add write_secret_to_file and read_secret_from_file functions to handle secret key file read/write operations
2023-08-30 16:14:27 -03:00
Gabriel Luiz Freitas Almeida
971d777074 🔧 chore(pyproject.toml): add markupsafe dependency to improve compatibility and security
🔧 chore(pyproject.toml): add pywin32 dependency for Windows platform to support specific functionality
2023-08-30 16:05:53 -03:00
Gabriel Luiz Freitas Almeida
e2e890464f 🔧 fix(base.py): import set_secure_permissions function from utils module to fix NameError
🔒 feat(utils.py): add set_secure_permissions function to set secure file permissions based on the operating system
2023-08-30 15:53:32 -03:00
anovazzi1
c64594c0a8 removed dead code 2023-08-29 22:33:19 -03:00
anovazzi1
6457725d13 fix(genericModal/index.tsx): remove debugger statement for cleaner code
fix(genericModal/index.tsx): update condition for setting nodeClass to avoid unnecessary re-rendering
2023-08-29 22:29:41 -03:00
Cristhian Zanforlin Lousa
f86c7c1689 🐛 fix(genericModal/index.tsx): add conditional check before setting nodeClass to prevent potential null or undefined value 2023-08-29 22:13:28 -03:00
Cristhian Zanforlin Lousa
89a0918dc5 🔧 fix(codeTabsComponent): remove unused useContext for isTweakPage in codeTabsComponent
🔧 fix(alertContext): remove isTweakPage and setIsTweakPage from alertContext

🔧 fix(genericModal): add null check for nodeClass before calling postValidatePrompt

🔧 fix(extraSidebarComponent): remove setIsTweakPage from extraSidebarComponent

🔧 fix(typesContext): remove isTweakPage and setIsTweakPage from typesContext
2023-08-29 22:07:18 -03:00
anovazzi1
8a772086e2 fix(api): make frontend_node field optional in ValidatePromptRequest to allow for a tweak call without a frontend_node
fix(api): handle case where frontend_node is None in post_validate_prompt to avoid attempting to update a non-existent node
2023-08-29 22:03:54 -03:00
anovazzi1
02cc23d6b1
Login (#802)
### Description
This pull request introduces a significant enhancement to the project by
incorporating robust authentication logic. The enhancement addresses the
critical need for secure user access and data protection within the
application. With this addition, the system will be able to authenticate
users, verify their identities, and provide access only to authorized
individuals.

### Changes Implemented
- **Authentication Middleware**: A new middleware module has been
implemented to intercept incoming requests and validate user
authentication. This middleware checks for valid authentication tokens
or credentials and ensures that only authenticated users can access
protected resources.

- **User Authentication Endpoint**: A new endpoint has been created to
handle user authentication. This endpoint allows users to provide their
credentials, which are then securely processed and validated against the
stored user data.

- **Password Hashing**: User passwords are now securely hashed using a
strong cryptographic algorithm before being stored in the database. This
ensures that even if the database is compromised, user passwords remain
inaccessible.

- **Token-Based Authentication**: Upon successful authentication, the
system generates a time-limited access token for the user. This token
must be included in subsequent requests to access protected resources.
Token validity is maintained through token expiration and refresh
mechanisms.

- **Authorization Checks**: The logic has been extended to include
authorization checks after successful authentication. This ensures that
authenticated users only have access to the resources they are
authorized to use, based on their roles and permissions.

### Benefits
1. **Enhanced Security**: By implementing strong authentication
mechanisms and password hashing, the project significantly improves
security, minimizing the risk of unauthorized access or data breaches.

2. **User-Friendly Experience**: Users can securely access the
application, confident in the knowledge that their credentials and data
are protected. The token-based authentication simplifies the user
experience by eliminating the need for frequent re-authentication.

3. **Scalability**: The authentication logic has been designed with
scalability in mind, ensuring that the system can handle a growing
number of users and requests without compromising security or
performance.

4. **Modularity**: The new authentication logic has been integrated as a
separate module, enhancing the project's modularity and maintainability.
2023-08-29 17:38:20 -03:00
anovazzi1
cf8df6c62b fix(users.py): update error message to be more generic and not reveal specific reason for username unavailability
fix(AdminPage/index.tsx): fix nullish assertion for create_at and updated_at properties to avoid potential errors
fix(signUpPage/index.tsx): fix error handling to correctly display error message
fix(types/components/index.ts): make id, create_at, and updated_at properties optional in UserInputType
2023-08-29 16:44:15 -03:00
anovazzi1
d73b3b0b52 fix(users.py): improve error message when trying to add a user with an already claimed username 2023-08-29 16:26:15 -03:00
Lucas Oliveira
2cfd772387 React Flow update and minor style fixes 2023-08-29 15:42:30 -03:00
Cristhian Zanforlin Lousa
27455cbd77 Merge branch 'login' of https://github.com/logspace-ai/langflow into login 2023-08-29 11:46:52 -03:00
Cristhian Zanforlin Lousa
3e55e5f394 🐛 fix(headerComponent): change Sign out button to anchor tag for better accessibility and consistency
 feat(headerComponent): add Home link when on admin page for easier navigation
 feat(headerComponent): add Admin page link for easier navigation to admin page
🐛 fix(ApiKeysPage): handle case when api_keys.name is null or undefined by displaying "-" instead
🐛 fix(ApiKeysPage): handle case when api_keys.last_used_at is an invalid date by displaying "Never" instead
 feat(ApiKeysPage): add Total Uses column to display the total number of uses for each API key
🐛 fix(loginPage): set isAdmin context variable based on user's is_superuser property
🐛 fix(loginPage): increase delay before fetching logged user to 500ms for better user experience
🐛 fix(types): add total_uses property to ApiKey type to match backend response
2023-08-29 11:46:48 -03:00
Gabriel Luiz Freitas Almeida
8c77613f72 🔀 refactor(utils.py): change return type annotation of authenticate_user function from Union[User, None] to Optional[User] for clarity and consistency 2023-08-29 10:45:10 -03:00
Gabriel Luiz Freitas Almeida
408caea750 🔒 chore(api.tsx): refactor request interceptor logic to improve readability and maintainability 2023-08-29 10:40:09 -03:00
igorrCarvalho
787c7844f5 Merge login into login 2023-08-28 20:44:05 -03:00
igorrCarvalho
5b75d44c3e Fix: remove admin page and signout on flow page 2023-08-28 20:41:54 -03:00
anovazzi1
166cd7e9f0 added flex to avoid scroll bug on admin page 2023-08-28 20:33:39 -03:00
anovazzi1
bf81507447 feat(AdminPage): add support for displaying user ID, creation date, and update date in the user table
fix(AdminPage): add type annotations to user variables in filter and map functions to improve type safety
2023-08-28 20:07:52 -03:00
igorrCarvalho
21ef1b43c7 fix: Remove redundant button on admin page header 2023-08-28 20:04:56 -03:00
igorrCarvalho
bb4ed111ef fix: Remove redundant button on admin page header 2023-08-28 19:58:25 -03:00
anovazzi1
d1ffe5ab11 fix glitch on apiKey page 2023-08-28 18:59:59 -03:00
Cristhian Zanforlin Lousa
6c03edc50a 🐛 fix(auth.py): set AUTO_LOGIN to False to disable automatic login as a super user
🐛 fix(API/index.ts): add null check for response object before checking status to prevent potential error
2023-08-28 18:22:59 -03:00
Gabriel Luiz Freitas Almeida
acd661f629 🔧 chore(__main__.py): remove unused imports and functions to improve code cleanliness and maintainability
🔧 chore(main.py): update import statement to use get_number_of_workers from __main__ module
🔧 chore(util.py): remove unused imports and functions to improve code cleanliness and maintainability
2023-08-28 18:09:26 -03:00
Gabriel Luiz Freitas Almeida
9804d58d32 🐛 fix(base.py): add *args and **kwargs to build method in Vertex class to allow for additional arguments to be passed
🐛 fix(types.py): add *args and **kwargs to build method in AgentVertex, LLMVertex, WrapperVertex, ChainVertex, and PromptVertex classes to allow for additional arguments to be passed
🐛 fix(utils.py): change return type annotation in api_key_security function from Optional[ApiKey] to Optional[User] to reflect the actual return type
2023-08-28 18:05:43 -03:00
Gabriel Luiz Freitas Almeida
23651e3a45 🔧 chore(Makefile): exclude .venv directory from mypy type checking to improve performance and avoid unnecessary errors 2023-08-28 18:05:29 -03:00
Cristhian Zanforlin Lousa
aba898adf7 Merge branch 'login' of https://github.com/logspace-ai/langflow into login 2023-08-28 17:56:56 -03:00
Gabriel Luiz Freitas Almeida
099921514c 🐛 fix(endpoints.py): add missing colon after if statement condition to fix syntax error
🔒 chore(endpoints.py): fix indentation and add missing colon after if statement condition for better code readability
2023-08-28 17:56:40 -03:00
Gabriel Luiz Freitas Almeida
1b79c1bd7e 🐛 fix(types.py): pass user_id parameter to build methods in AgentVertex, LLMVertex, WrapperVertex, ChainVertex, and PromptVertex to enable user-specific functionality 2023-08-28 17:56:39 -03:00
Gabriel Luiz Freitas Almeida
ac6d2ff8b4 🔥 refactor(service.py): remove unused import and commented code in AuthManager class 2023-08-28 17:56:38 -03:00