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

257 user model refactor the config handling #433

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

michalkrzem
Copy link
Collaborator

@michalkrzem michalkrzem commented Oct 30, 2024

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running mquery, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the current behaviour?
db.get_mquery_config_key("default_role) when called returns different types

What is the new behaviour?
I created UserModelConfig with properties like auth_default_roles, openid_client_id, query_allow_slow etc. and now i call db.config.default_role

Test plan

Closing issues

fixes #257

@michalkrzem michalkrzem linked an issue Oct 30, 2024 that may be closed by this pull request
src/db.py Outdated
Comment on lines 90 to 93
auth_enabled = self.db.get_mquery_config_key("auth_enabled")
if not auth_enabled or auth_enabled == "false":
return False
return True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auth_enabled = self.db.get_mquery_config_key("auth_enabled")
if not auth_enabled or auth_enabled == "false":
return False
return True
return self.db.get_mquery_config_key("auth_enabled") == "true"

Tiny chance in behaviour, but consistent with query_allow_slow (and works the same way for "true" and "false")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brilliant :)

src/db.py Outdated
]

@property
def openid_client_id(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def openid_client_id(self) -> str:
def openid_client_id(self) -> str | None:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(if this causes type errors somewhere else, callers should be fixed to handle the situation where this is null)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/db.py Outdated
return True

@property
def openid_url(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def openid_url(self) -> str:
def openid_url(self) -> str | None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/schema.py Outdated
@@ -101,7 +101,7 @@ class BackendStatusDatasetsSchema(BaseModel):

class ServerSchema(BaseModel):
version: str
auth_enabled: Optional[str]
auth_enabled: Optional[bool]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this will cause issues on the frontend (but you can check). Unfortunately, you should probably cast to str when creating ServerSchema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User model: Refactor the config handling
2 participants