authx
authx copied to clipboard
Failed to import RedisCacheBackend and JWTBackend class from authx. Version 0.4.0
First Check
- [X] I added a very descriptive title to this issue.
- [X] I already read and followed all the tutorial in the docs and didn't find an answer.
- [X] I already checked if it is not related to AuthX but to Pydantic.
- [X] I already checked if it is not related to AuthX but to FastAPI.
Example Code
from authx import RedisCacheBackend, JWTBackend, RedisBackend
from fastapi import Depends, FastAPI
from fastapi.security import HTTPBearer
from starlette.config import Config
app = FastAPI(
title="AuthX",
description="AuthX authentication system for fastapi.",
version="0.1.0",
)
config = Config(".env")
SecurityConfig = JWTBackend(
cache_backend=RedisBackend,
private_key=config("PRIVATE_KEY", default="private_key"),
public_key=config("PUBLIC_KEY", default="public_key"),
access_expiration=3600,
refresh_expiration=3600
)
oauth_token_scheme = HTTPBearer()
# app.include_router(starlette_app.router) # pygeoapi
# Set Anonymous User
@app.get("/anonym")
def anonym_test():
pass
# Set Authenticated User
@app.get("/user")
async def user_test(token=Depends(oauth_token_scheme)):
is_verified = await SecurityConfig.decode_token(token)
print(is_verified)
pass
Description
as specified in the documentation for jwt implementation https://authx.yezz.codes/configuration/security/jwt/ , from authx import RedisCacheBackend, JWTBackend should not return an error. as shown below

- i want to use JWTBackend to verify token using FastAPI dependency injection. a token should be passed to the swaggerUI docs from fastapi. and should be accessible via the oauth_token_scheme.
- is_verified should return a boolean showing the verification state of the token, returns None instead of a boolean
Suspected problem RedisCacheBackend is not an exported class from the module - not part of the module, but that is what was shown according to the documentation. using RedisBackend(this is exported from the module) instead, returns TypeError `Expected Type 'RedisBackend', got Type[RedisBackend] instead. in the JWTBackend class
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.75.1
Python Version
python 3.8.10
Additional Context
No response
could you check this https://authx.yezz.codes/configuration/cache/ cause we setup redis in this way and you need to add first the link before that
could you check this https://authx.yezz.codes/configuration/cache/ cause we setup redis in this way and you need to add first the link before that
i'm having trouble setting up openid connect, the tutorial is not well explained. can you give me directives?? please
Hello @r-scheele can you please checkout using HTTPCacheBackend https://github.com/yezz123/authx/blob/33bd6100f0f3e261de58e683e788352e1233b057/authx/cache/backend.py#L11