Coverage for benefits/core/models/claims.py: 100%
19 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-29 21:21 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-29 21:21 +0000
1from django.db import models
3from .common import SecretNameField
6class ClaimsProvider(models.Model):
7 """An entity that provides claims for eligibility verification."""
9 id = models.AutoField(primary_key=True)
10 sign_out_button_template = models.TextField(default="", blank=True, help_text="Template that renders sign-out button")
11 sign_out_link_template = models.TextField(default="", blank=True, help_text="Template that renders sign-out link")
12 client_name = models.TextField(help_text="Unique identifier used to register this claims provider with Authlib registry")
13 client_id_secret_name = SecretNameField(
14 help_text="The name of the secret containing the client ID for this claims provider"
15 )
16 authority = models.TextField(help_text="The fully qualified HTTPS domain name for an OAuth authority server")
17 scheme = models.TextField(help_text="The authentication scheme to use")
19 @property
20 def supports_sign_out(self):
21 return bool(self.sign_out_button_template) or bool(self.sign_out_link_template)
23 @property
24 def client_id(self):
25 secret_name_field = self._meta.get_field("client_id_secret_name")
26 return secret_name_field.secret_value(self)
28 def __str__(self) -> str:
29 return self.client_name