Skip to content
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

[Bug] Authentification is required on localhost #2534

Open
ant-on-su opened this issue Mar 17, 2025 · 25 comments
Open

[Bug] Authentification is required on localhost #2534

ant-on-su opened this issue Mar 17, 2025 · 25 comments
Assignees
Labels
question Further information is requested unconfirmed bug

Comments

@ant-on-su
Copy link

I run agenta locally,
after upgrade to v36.1 (docker images and .env.oss.gh file) trying to access localhost:80 redirects to authentification page.
How to disable this?

@dosubot dosubot bot added bug Something isn't working question Further information is requested labels Mar 17, 2025
@Agenta-AI Agenta-AI deleted a comment from dosubot bot Mar 17, 2025
@mmabrouk
Copy link
Member

Hello @ant-on-su

Right now it's not possible to deactivate the authenticatio. The first time that you self-host the open source version you need to create an account using username and password. This would be the admin account of this instance. This account then can invite people to this instance.

Are there reasons that you would want to disable this?

@mmabrouk mmabrouk removed the bug Something isn't working label Mar 17, 2025
@mmabrouk mmabrouk self-assigned this Mar 17, 2025
@Aditya7879
Copy link

Hi @mmabrouk

I am currently running Agenta locally and encountered an issue when attempting to access the application. Upon opening the localhost link, I am directed to the authentication page. However, when I enter my email and password, I receive an error message stating: "Oops, something went wrong. Please try again. If the issue persists, please contact support."

Could you please assist me with this issue so that I can successfully sign in or sign up? Your help would be greatly appreciated.

@mmabrouk
Copy link
Member

Hello @Aditya7879

Can you please share the following:

  • The logs in the developer console in the browser, pertaining to the authentication request (which requests fail and what is the response)
  • The logs from the web and from the api docker containers

This would help us identify the root of the issue. Additionally if you have made any modification to the environment variable configuration, please let us know.

Thank you!

@Aditya7879
Copy link

Aditya7879 commented Mar 18, 2025

Hi @mmabrouk ,

  • logs for the browser

Image

  • logs for the docker on console

Image
Image

Added the required images for the reference. I have not changed a single thing in the env file.

Let me know if you need anything.

Thanks

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Hi @Aditya7879,

I'll be taking over this thread from @mmabrouk and working with you to debug and fix the issue. It looks like you don't have the organizations table created in your database, even though there's a migration file for it (2f0cb224a977_feature_shift_add_org_workspace_org_.py). Could you please confirm if the organizations table exists in your database? Also, do you still have the Alembic logs from when you upgraded to v0.36.1? This would help me determine what went wrong.

@Aditya7879
Copy link

Hi @aybruhm ,

These are the list of tables present in my postgres. I don't see any organizations table here.

Image

Is this the info that you want or something else?
I don't have any logs from the previous versions with me. If you want something else let me know.

Thanks.

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Is this the info that you want or something else?
I don't have any logs from the previous versions with me. If you want something else let me know.

Yes, it was useful, thank you @Aditya7879 . Can you tell me what the current revision number is in the alembic_version table? Run this command to know what it is:

SELECT * FROM alembic_version;

@Aditya7879
Copy link

Is this the info that you want or something else?
I don't have any logs from the previous versions with me. If you want something else let me know.

Yes, it was useful, thank you @Aditya7879 . Can you tell me what the current revision number is in the alembic_version table? Run this command to know what it is:

SELECT * FROM alembic_version;

Hi,

Image

version number is 0f086ebc2f83

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Ah, got it. You simply need to run the migration to create the new tables:

docker exec -e PYTHONPATH=/app -w /app/oss/databases/postgres/migrations agenta-oss-dev-api-1 alembic -c alembic.oss.ini upgrade head

If you would like migrations to be taken care of automatically for you, kindly update the value of AGENTA_AUTO_MIGRATION to true. When you run the above command, try to sign in again and let me know if the bug persists.

@ant-on-su
Copy link
Author

Thank you @aybruhm , but migration (also auto) still didn't solve the "Oops, something went wrong" issue...
Another small one, it seems to be AGENTA_AUTO_MIGRATIONS , so with an "S" at the end, looking at the code

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Can you show me the logs you received when you ran the migration command?

Another small one, it seems to be AGENTA_AUTO_MIGRATIONS , so with an "S" at the end, looking at the code

Got it. I've taken note of this and will update the documentation. Thank you.

@ant-on-su
Copy link
Author

oops, didn't save the original output, now cannot find it back...
Trying to rerun the migration command just gives this, not much useful:

Image

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Alright, can you please share the logs you get from the API container when try to sign in again?

@ant-on-su
Copy link
Author

sure, here:

Image

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Alright, can you re-check your database to see if the organizations table now exists?

@Aditya7879
Copy link

Alright, can you re-check your database to see if the organizations table now exists?

Hi,

yes now we have organizations table in agenta_oss. But their is no entry in it.

Image

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Alright, can you also show me all the tables you have in your database?

@Aditya7879
Copy link

Sure,

Image

@aybruhm
Copy link
Member

aybruhm commented Mar 18, 2025

Got it. Can you confirm how many users you have currently? The issue right now is that the system expects you to have no users in order to create a default organization and workspace for you. If you have a user already, then I'd recommend that you update the check_if_user_exists_and_create_organization function in your db_manager.py to be like this:

async def check_if_user_exists_and_create_organization(user_email: str):
    """Check if a user with the given email exists and if not, create a new organization for them."""

    async with engine.session() as session:
        user_query = await session.execute(select(UserDB).filter_by(email=user_email))
        user = user_query.scalars().first()

        # count total number of users in database
        total_users = (
            await session.scalar(select(func.count()).select_from(UserDB)) or 0
        )

        if user is None and (total_users == 0):
            organization_name = user_email.split("@")[0]
            organization_db = await create_organization(name=organization_name)
            workspace_db = await create_workspace(
                name=organization_name, organization_id=str(organization_db.id)
            )

            # update default project with organization and workspace ids
            await update_default_project(
                values_to_update={
                    "organization_id": organization_db.id,
                    "workspace_id": workspace_db.id,
                }
            )
            return organization_db

        # organizations_db = await get_organizations()
        # return organizations_db[0]
        organization_name = "choose a name"
         organization_db = await create_organization(name=organization_name)
         workspace_db = await create_workspace(
             name=organization_name, organization_id=str(organization_db.id)
         )

         # update default project with organization and workspace ids
         await update_default_project(
             values_to_update={
                 "organization_id": organization_db.id,
                 "workspace_id": workspace_db.id,
             }
         )
         return organization_db

And then try to sign in again. If everything works fine, please revert the code in the function you modified to its previous state to prevent another organization from being created.

@ant-on-su
Copy link
Author

strange, but no any difference, same error...
Did it help you, @Aditya7879 ?

@aybruhm
Copy link
Member

aybruhm commented Mar 19, 2025

strange, but no any difference, same error... Did it help you, @Aditya7879 ?

Same error as this one? How is that possible? The function no longer returns a list but now returns an object, which means it is likely that the function is not being called.

Could you please re-check the organizations table to see if an organization was created?

@ant-on-su
Copy link
Author

ahh, used wrong docker-compose yaml, it was pulling images instead of building them. Now everything works like a charm, thanks a lot!

@Aditya7879
Copy link

Aditya7879 commented Mar 20, 2025

Got it. Can you confirm how many users you have currently? The issue right now is that the system expects you to have no users in order to create a default organization and workspace for you. If you have a user already, then I'd recommend that you update the check_if_user_exists_and_create_organization function in your db_manager.py to be like this:

async def check_if_user_exists_and_create_organization(user_email: str):
"""Check if a user with the given email exists and if not, create a new organization for them."""

async with engine.session() as session:
    user_query = await session.execute(select(UserDB).filter_by(email=user_email))
    user = user_query.scalars().first()

    # count total number of users in database
    total_users = (
        await session.scalar(select(func.count()).select_from(UserDB)) or 0
    )

    if user is None and (total_users == 0):
        organization_name = user_email.split("@")[0]
        organization_db = await create_organization(name=organization_name)
        workspace_db = await create_workspace(
            name=organization_name, organization_id=str(organization_db.id)
        )

        # update default project with organization and workspace ids
        await update_default_project(
            values_to_update={
                "organization_id": organization_db.id,
                "workspace_id": workspace_db.id,
            }
        )
        return organization_db

    # organizations_db = await get_organizations()
    # return organizations_db[0]
    organization_name = "choose a name"
     organization_db = await create_organization(name=organization_name)
     workspace_db = await create_workspace(
         name=organization_name, organization_id=str(organization_db.id)
     )

     # update default project with organization and workspace ids
     await update_default_project(
         values_to_update={
             "organization_id": organization_db.id,
             "workspace_id": workspace_db.id,
         }
     )
     return organization_db

And then try to sign in again. If everything works fine, please revert the code in the function you modified to its previous state to prevent another organization from being created.

So after doing this and rebuilding my docker file. I'm getting this-
You need to be invited by the organization owner to gain access.

Image

@mmabrouk
Copy link
Member

So after doing this and rebuilding my docker file. I'm getting this-
You need to be invited by the organization owner to gain access.

@Aditya7879 this would mean that you have already created an account in this installation.
Assuming this is your first installation of agenta and you don't have data that you cannot lose. The easiest solution is to nuke the installation and start from scratch.

  • Remove the agenta containers
  • Remove the volume agenta-oss-gh_postgres-data
  • Pull the latest versions of the images and try again:
docker compose -f hosting/docker-compose/oss/docker-compose.gh.yml --env-file hosting/docker-compose/oss/.env.oss.gh  --profile with-web up -d --pull always```

Please let us know if this resolves the issue

@mmabrouk
Copy link
Member

Has this issue now been resolved? @Aditya7879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested unconfirmed bug
Projects
None yet
Development

No branches or pull requests

4 participants