lomas_server.administration.scripts package
Submodules
lomas_server.administration.scripts.keycloak_setup module
- class lomas_server.administration.scripts.keycloak_setup.Config(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, *, keycloak_url: HttpUrl, keycloak_authentication_realm: str, keycloak_admin_client_id: str, keycloak_admin_user: str, keycloak_admin_pwd: str, lomas_realm: str = 'lomas', lomas_gateway_url: HttpUrl, lomas_gateway_client_id: str = 'lomas_oauth_proxy', lomas_gateway_client_secret: str, lomas_admin_client_id: str = 'lomas_admin', lomas_admin_client_secret: str, lomas_api_client_id: str = 'lomas_api', lomas_api_client_secret: str, lomas_admin_users: dict[int, User], overwrite_realm: bool = True)[source]
Bases:
BaseSettingsConfig model for keycloak setup script.
- keycloak_admin_client_id: str
- keycloak_admin_pwd: str
- keycloak_admin_user: str
- keycloak_authentication_realm: str
- keycloak_url: HttpUrl
- property keycloak_use_tls: bool
Using TLS ?
- lomas_admin_client_id: str
- lomas_admin_client_secret: str
- lomas_api_client_id: str
- lomas_api_client_secret: str
- lomas_gateway_client_id: str
- lomas_gateway_client_secret: str
- lomas_gateway_url: HttpUrl
- lomas_realm: str
- model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env.lomas_kc_setup', 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': '__', 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': 'lomas_kc_setup_', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- overwrite_realm: bool
- class lomas_server.administration.scripts.keycloak_setup.User(*, username: str, email: str, temp_password: str, first_name: str, last_name: str)[source]
Bases:
BaseModelBaseModel for informations of a keycloak user.
- email: str
- first_name: str
- last_name: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- temp_password: str
- username: str
- lomas_server.administration.scripts.keycloak_setup.create_confidential_client(kc_admin: KeycloakAdmin, client_id: str, client_secret: str, roles: dict[str, list[str]] = {}) None[source]
Creates a confidential client with an associated service account.
Allows only for the client credentials flow and assigns the roles listed in the provided dictionary.
Only creates the account if it does not already exist.
- Parameters:
kc_admin (KeycloakAdmin) – A KeycloakAdmin session.
client_id (str) – The client id to use.
client_secret (str) – The client secret to use.
roles (Dict[str, List[str]]) – A dictionary mapping of (realm, list of roles) pairs to assign to the associated service account.
- lomas_server.administration.scripts.keycloak_setup.create_gateway_client(kc_admin: KeycloakAdmin, client_id: str, client_secret: str, gateway_hostname: HttpUrl) None[source]
Create a confidential client for the gateway.
This client will handle auth of the admin users to the various dashboards.
- Parameters:
kc_admin (KeycloakAdmin) – The KeycloakAdmin instance.
client_id (str) – The client id.
client_secret (str) – The client secret.
gateway_hostname (HttpUrl) – The hostname (url) of the gateway.
- lomas_server.administration.scripts.keycloak_setup.create_lomas_admin_users(config: Config, kc_admin: KeycloakAdmin) None[source]
Creates standard User.
- lomas_server.administration.scripts.keycloak_setup.create_lomas_clients(config: Config, kc_admin: KeycloakAdmin) None[source]
Creates clients for the lomas application:
lomas_admin
lomas_api
- Parameters:
config (Config) – Config for creating the clients.
kc_admin (KeycloakAdmin) – A KeycloakAdmin session.
- lomas_server.administration.scripts.keycloak_setup.create_realm(config: Config, kc_admin: KeycloakAdmin) None[source]
Creates the application realm if it does not already exist.
This removes any existing realms with the same name if they already exist!
This does not reset the application realm!
- Parameters:
config (Config) – Config for creating the realm.
kc_admin (KeycloakAdmin) – A KeycloakAdmin session.
- lomas_server.administration.scripts.keycloak_setup.get_admin_session(config: Config) KeycloakAdmin[source]
Returns a keycloak admin session using the.
- Parameters:
config (Config) – The config to create the connection.
- Returns:
KeycloakAdmin session.
- Return type:
KeycloakAdmin
lomas_server.administration.scripts.lomas_demo_setup module
- class lomas_server.administration.scripts.lomas_demo_setup.DemoAdminConfig(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, *, server_url: str, server_service: str, mg_config: MongoDBConfig, kc_config: KeycloakClientConfig | None = None, path_prefix: str = '', user_yaml: str = '/data/collections/user_collection.yaml', dataset_yaml: str = '/data/collections/dataset_collection.yaml')[source]
Bases:
AdminConfigExtension of Admin config for demo setup.
- dataset_yaml: str
- model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env.lomas_admin', 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': '__', 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': 'lomas_admin_', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path_prefix: str
- user_yaml: str
- lomas_server.administration.scripts.lomas_demo_setup.add_lomas_demo_data(config: DemoAdminConfig) None[source]
Adds the demo data to the mongodb admindb as well as the keycloak instance if required.
Meant to be used in the develop mode of the service or for testing
- Parameters:
config (AdminConfig) – The administration config.