Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Pydantic, readonly, Configuration #61

@peppelinux

Description

@peppelinux

This issue collect all the stuffs related to any logic improvement of the oidc-op configuration system.

@rohe that's the PoC that I put in configuration.py Base Class to see which Configuration attribute have been overwrite during configuration initialization:

    def __setattr__(self, key, value):
        if hasattr(self, key) and \
           key not in ('endpoint',
                       'httpc_params',
                       'issuer',
                       'login_hint2acrs',
                       'sub_func',
                       'token_handler_args',
                       'template_dir') and \
           getattr(self, key) != None:
            # not first time we configure it!
            #  print(key, getattr(self, key), value)
            #  raise AttributeError(
                #  f"{key} is a ReadOnly attribute "
                #  "that can't be overwritten!"
            #  )
            print(key)
        super().__setattr__(key, value)

and I'm asking why 'endpoint', 'httpc_params', 'issuer', 'login_hint2acrs', 'sub_func', 'token_handler_args', 'template_dir' are overwritten ... Shouldn't it be better to load their values in a single step? with this adaptation there would be also trivial make the configuration readonly (once a value have been set, it won't be changed anymore ...).

once a Configuration have been built a lock attribute would be set and the setattr and setitem (all the set_thing) methods will check the lock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions