ogdc_runner.service.user module

Module containing code for managing OGDC users.

class ogdc_runner.service.user.User(*, id=None, name, password_hash)

Bases: SQLModel

Model representing the users table in the OGDC database.

Parameters:
  • id (int | None)

  • name (str)

  • password_hash (str)

id: int | None
model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
password_hash: str
ogdc_runner.service.user.create_admin_user() None

Create the admin user if it does not already exist.

Requires that the OGDC_ADMIN_PASSWORD envvar be set.

Return type:

None

ogdc_runner.service.user.create_user(*, session: Session, username: str, password: str) User

Create a user with the given username and password.

Raises OgdcUserAlreadyExists if the given username is already in use.

Parameters:
  • session (Session)

  • username (str)

  • password (str)

Return type:

User

ogdc_runner.service.user.get_user(*, session: Session, name: str) User | None
Parameters:
  • session (Session)

  • name (str)

Return type:

User | None

ogdc_runner.service.user.get_user_with_password(*, session: Session, name: str, password: str) None | User

Get the user record by name and password.

Returns None if no matching user is found.

Parameters:
  • session (Session)

  • name (str)

  • password (str)

Return type:

None | User

ogdc_runner.service.user.hash_password(password: str) str
Parameters:

password (str)

Return type:

str

ogdc_runner.service.user.verify_password(*, password: str, hashed_password: str) bool
Parameters:
  • password (str)

  • hashed_password (str)

Return type:

bool