refactoring swagger login
This commit is contained in:
parent
2ef7828fb0
commit
f80b90a1a6
|
@ -20,8 +20,8 @@ def verify_token_admin(token: str = Depends(api_key_header)):
|
|||
|
||||
def verify_user_pwd(credentials: HTTPBasicCredentials = Depends(security)):
|
||||
if (
|
||||
credentials.username != conf.admin_user.login
|
||||
or credentials.password != conf.admin_user.pwd
|
||||
credentials.username != conf.swagger.login
|
||||
or credentials.password != conf.swagger.pwd
|
||||
):
|
||||
log.warning("Invalid credentials")
|
||||
raise HTTPException(
|
||||
|
|
|
@ -6,8 +6,8 @@ OAA_CFG__LOG__LEVEL=20
|
|||
OAA_CFG__TOKEN__ADMIN=pE0ULNppBtQOOxRuVw1tdiXTG5dZTaSx
|
||||
OAA_CFG__TOKEN__USER=A3mojtenQqYwJAgrSiiFaVHX6fRoVW15
|
||||
|
||||
OAA_CFG__ADMIN_USER__LOGIN=admin
|
||||
OAA_CFG__ADMIN_USER__PWD=P@ssw0rd!
|
||||
OAA_CFG__SWAGGER__LOGIN=admin
|
||||
OAA_CFG__SWAGGER__PWD=P@ssw0rd!
|
||||
|
||||
OAA_CFG__REDIS__HOST=localhost
|
||||
OAA_CFG__REDIS__PORT=6379
|
||||
|
|
|
@ -39,11 +39,6 @@ class TokenConfig(BaseModel):
|
|||
user: str
|
||||
|
||||
|
||||
class AdminUser(BaseModel):
|
||||
login: str
|
||||
pwd: str
|
||||
|
||||
|
||||
class RedisConfig(BaseModel):
|
||||
host: str = "localhost"
|
||||
port: int = 6379
|
||||
|
@ -59,6 +54,8 @@ class SwaggerConfig(BaseModel):
|
|||
swagger_js_url: str = "/static/swagger/swagger-ui-bundle.js"
|
||||
swagger_css_url: str = "/static/swagger/swagger-ui.css"
|
||||
swagger_favicon_url: str = "/static/swagger/favicon.png"
|
||||
login: str
|
||||
pwd: str
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
|
@ -76,7 +73,6 @@ class Settings(BaseSettings):
|
|||
log: LogConfig = LogConfig()
|
||||
prefix: PrefixConfig = PrefixConfig()
|
||||
token: TokenConfig
|
||||
admin_user: AdminUser
|
||||
redis: RedisConfig
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue