Skip to content

hololinked.td.security_definitions.SecurityScheme

Bases: Schema

Represents a security scheme. schema - https://www.w3.org/TR/wot-thing-description11/#sec-security-vocabulary-definition

Source code in hololinked/hololinked/td/security_definitions.py
class SecurityScheme(Schema):
    """
    Represents a security scheme.
    schema - https://www.w3.org/TR/wot-thing-description11/#sec-security-vocabulary-definition
    """

    scheme: str = None
    description: str = None
    descriptions: Optional[dict[str, str]] = None
    proxy: Optional[str] = None

    def __init__(self):
        super().__init__()

    def build(self):
        raise NotImplementedError("Please implement specific security scheme builders")

hololinked.td.security_definitions.NoSecurityScheme

Bases: SecurityScheme

No Security Scheme

Source code in hololinked/hololinked/td/security_definitions.py
class NoSecurityScheme(SecurityScheme):
    """No Security Scheme"""

    def build(self):
        self.scheme = "nosec"
        self.description = "currently no security scheme supported"

hololinked.td.security_definitions.BasicSecurityScheme

Bases: SecurityScheme

Basic Security Scheme, username and password

Source code in hololinked/hololinked/td/security_definitions.py
class BasicSecurityScheme(SecurityScheme):
    """Basic Security Scheme, username and password"""

    in_: str = Field(default="header", alias="in")

    def build(self):
        self.scheme = "basic"
        self.description = "HTTP Basic Authentication"
        self.in_ = "header"

hololinked.td.security_definitions.APIKeySecurityScheme

Bases: SecurityScheme

API Key Security Scheme

Source code in hololinked/hololinked/td/security_definitions.py
class APIKeySecurityScheme(SecurityScheme):
    """API Key Security Scheme"""

    in_: str = Field(default="header", alias="in")

    def build(self):
        self.scheme = "apikey"
        self.description = "API Key Authentication"
        self.in_ = "header"

hololinked.td.security_definitions.OIDCSecurityScheme

Bases: SecurityScheme

OIDC Security Scheme

Source code in hololinked/hololinked/td/security_definitions.py
class OIDCSecurityScheme(SecurityScheme):
    """OIDC Security Scheme"""

    scheme: str = "oauth2"
    token: str = ""
    scopes: list[str] = Field(default_factory=list)

    def build(self, token_url: str, scopes: list[str] | None = ["openid"]):
        self.description = "OpenID Connect Authentication"
        self.token = token_url
        if scopes is not None:
            self.scopes = scopes