CityofSantaMonica / mds-provider

Python tools for working with MDS Provider data
https://github.com/openmobilityfoundation/mobility-data-specification
MIT License
18 stars 20 forks source link

Better auth implementation #75

Closed thekaveman closed 5 years ago

thekaveman commented 5 years ago

Define a simple base class interface in AuthorizationToken:

class AuthorizationToken():
    """
    Base class with simple interface
    """
    def __init__(self, provider):
        # establish the session via this implementation

    @classmethod
    def can_auth(cls, provider):
        # can this implementation be used for the provider?

Create a new subclass of AuthorizationToken with __init__ and can_auth to implement a new auth type.

No further changes are needed in ProviderClient; a provider is checked against each subclass in turn (including AuthorizationToken itself) until a supported implementation is found.