codemation / easyauth

Create a centralized Authentication and Authorization token server. Easily secure FastAPI endpoints based on Users, Groups, Roles or Permissions with very little database usage.
https://easyauth.readthedocs.io/en/latest/
MIT License
553 stars 52 forks source link

404 Not found #101

Closed greg12579 closed 1 year ago

greg12579 commented 1 year ago

Was able to launch the server, but when I try to connect to it using a browser to http://0.0.0.0:8330/docs, I receive {"detail":"Not authenticated"}.

On the command line stderr you see. INFO: 127.0.0.1:50650 - "GET / HTTP/1.1" 404 Not Found

If i go to the root http://0.0.0.0:8330/ I get {"detail":"Not Found"}

Any idea why?

http://0.0.0.0:8330/docs returns fine. Meaning I see the docs

greg12579 commented 1 year ago

I ended up getting this to work. I upgraded to the latest FASTAPI. Then created the server file without "await"

from fastapi import FastAPI
from easyauth.server import EasyAuthServer

server = FastAPI()

server.auth = EasyAuthServer.create(
    server,
    '/auth/token',
    auth_secret='abcd1234',
    admin_title='EasyAuth - Company',
    admin_prefix='/admin',
    env_from_file='server_sqlite.json'
)

uvicorn --host 0.0.0.0 --port 8330 myfile:server

codemation commented 1 year ago

Hi @greg12579, glad you were able to get it working. Need to update medium articles to reflect. Indeed when FastAPI version changed, so did some middleware startup components requiring an adjustment in EasyAuth server creation.