diff --git a/docs/configuration.rst b/docs/configuration.rst index 09db608b..af539b4c 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -67,6 +67,7 @@ Base authorization settings. ``OAuth`` provider requires ``aioauth-client`` libr * ``client_secret`` - OAuth2 application client secret key, string, required in case if ``oauth`` is used. * ``cookie_secret_key`` - secret key which will be used for cookies encryption, string, optional. It must be 32 url-safe base64-encoded bytes and can be generated as following ``base64.urlsafe_b64encode(os.urandom(32)).decode("utf8")``. If not set, it will be generated automatically; note, however, that in this case, all sessions will be automatically expired during restart. * ``max_age`` - parameter which controls both cookie expiration and token expiration inside the service, integer, optional, default is 7 days. +* ``oauth_icon`` - OAuth2 login button icon, string, optional, default is ``google``. Must be valid `Bootstrap icon `_ name. * ``oauth_provider`` - OAuth2 provider class name as is in ``aioauth-client`` (e.g. ``GoogleClient``, ``GithubClient`` etc), string, required in case if ``oauth`` is used. * ``oauth_scopes`` - scopes list for OAuth2 provider, which will allow retrieving user email (which is used for checking user permissions), e.g. ``https://www.googleapis.com/auth/userinfo.email`` for ``GoogleClient`` or ``user:email`` for ``GithubClient``, space separated list of strings, required in case if ``oauth`` is used. * ``salt`` - additional password hash salt, string, optional. diff --git a/src/ahriman/core/auth/oauth.py b/src/ahriman/core/auth/oauth.py index 55ec7be4..ef7ea5d0 100644 --- a/src/ahriman/core/auth/oauth.py +++ b/src/ahriman/core/auth/oauth.py @@ -34,6 +34,7 @@ class OAuth(Mapping): Attributes: client_id(str): application client id client_secret(str): application client secret key + icon(str): icon to be used in login control provider(aioauth_client.OAuth2Client): provider class, should be one of aiohttp-client provided classes redirect_uri(str): redirect URI registered in provider scopes(str): list of scopes required by the application @@ -58,6 +59,7 @@ class OAuth(Mapping): self.provider = self.get_provider(configuration.get("auth", "oauth_provider")) # it is list, but we will have to convert to string it anyway self.scopes = configuration.get("auth", "oauth_scopes") + self.icon = configuration.get("auth", "oauth_icon", fallback="google") @property def auth_control(self) -> str: @@ -67,7 +69,7 @@ class OAuth(Mapping): Returns: str: login control as html code to insert """ - return """ login""" + return f""" login""" @staticmethod def get_provider(name: str) -> type[aioauth_client.OAuth2Client]: diff --git a/src/ahriman/core/configuration/schema.py b/src/ahriman/core/configuration/schema.py index 43e75e74..55934fe5 100644 --- a/src/ahriman/core/configuration/schema.py +++ b/src/ahriman/core/configuration/schema.py @@ -136,6 +136,10 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = { "coerce": "integer", "min": 0, }, + "oauth_icon": { + "type": "string", + "empty": False, + }, "oauth_provider": { "type": "string", "empty": False,