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