-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication Loop #3438
Comments
To resolve the authentication loop issue in Langflow version 1.0.15 with a Docker installation using PostgreSQL 16, you should enable the
Here is the relevant code snippet from @router.get("/auto_login")
async def auto_login(
response: Response,
db: Session = Depends(get_session),
settings_service=Depends(get_settings_service),
):
auth_settings = settings_service.auth_settings
if settings_service.auth_settings.AUTO_LOGIN:
user_id, tokens = create_user_longterm_token(db)
response.set_cookie(
"access_token_lf",
tokens["access_token"],
httponly=auth_settings.ACCESS_HTTPONLY,
samesite=auth_settings.ACCESS_SAME_SITE,
secure=auth_settings.ACCESS_SECURE,
expires=None, # Set to None to make it a session cookie
domain=auth_settings.COOKIE_DOMAIN,
)
return tokens
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={
"message": "Auto login is disabled. Please enable it in the settings",
"auto_login": False,
},
) To handle incorrect credentials, the following part of the @router.post("/login", response_model=Token)
async def login_to_get_access_token(
response: Response,
form_data: OAuth2PasswordRequestForm = Depends(),
db: Session = Depends(get_session),
settings_service=Depends(get_settings_service),
variable_service: VariableService = Depends(get_variable_service),
):
auth_settings = settings_service.auth_settings
try:
user = authenticate_user(form_data.username, form_data.password, db)
except Exception as exc:
if isinstance(exc, HTTPException):
raise exc
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=str(exc),
) from exc
if user:
tokens = create_user_tokens(user_id=user.id, db=db, update_last_login=True)
response.set_cookie(
"refresh_token_lf",
tokens["refresh_token"],
httponly=auth_settings.REFRESH_HTTPONLY,
samesite=auth_settings.REFRESH_SAME_SITE,
secure=auth_settings.REFRESH_SECURE,
expires=auth_settings.REFRESH_TOKEN_EXPIRE_SECONDS,
domain=auth_settings.COOKIE_DOMAIN,
)
response.set_cookie(
"access_token_lf",
tokens["access_token"],
httponly=auth_settings.ACCESS_HTTPONLY,
samesite=auth_settings.ACCESS_SAME_SITE,
secure=auth_settings.ACCESS_SECURE,
expires=auth_settings.ACCESS_TOKEN_EXPIRE_SECONDS,
domain=auth_settings.COOKIE_DOMAIN,
)
variable_service.initialize_user_variables(user.id, db)
create_default_folder_if_it_doesnt_exist(db, user.id)
return tokens
else:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Incorrect username or password",
headers={"WWW-Authenticate": "Bearer"},
) Additionally, you can manage the By ensuring |
Hi @konradbjk, Could you please follow up on PR #3471? This PR should resolve any issues related to login using Langflow on Docker. The fix will be included in version 1.0.16 of Langflow, so if you're using pip, I recommend waiting for the new release before updating to see if the issue persists. Alternatively, you can fork our main branch and use it locally. Thank you! |
Bug Description
Once I upgraded to v1.0.15 my docker instalaltion (with postgres16) I have been unable to login to the langflow. There was some loop of authentication, that was ending with 400 error stating, that I need to enable AUTO_LOGIN. When giving incorrect credentials, the behaviour is different, it shows right away that the credentials are wrong.
Downgrading to 1.0.14 is a workaround
Reproduction
Expected behavior
I can login with my superuser credentials
Who can help?
@anovazzi1 @Cristhianzl @lucaseduoli @igorrCarvalho
Operating System
Ubuntu 24 LTS on Azure VM
Langflow Version
1.0.15
Python Version
3.12
Screenshot
My
.env
my compose file
Flow File
No response
The text was updated successfully, but these errors were encountered: