[docs]classCSLApplication(AbstractApplication):"""Extends the default OAuth Application model to add CSL-specific information about an OAuth application. Disables the implicit, password, and OpenID connect hybrid grant types. Disables use of an OIDC algorithm. Attributes: sanctioned (bool): Whether the application is sanctioned by the tjCSL. sanctioned_but_do_not_skip_authorization (bool): Whether to not skip the authorization page for this application even if it is sanctioned. user_has_oauth_and_api_access (bool): Whether the user associated with the CSLApplication has OAuth and API access. """CLIENT_CONFIDENTIAL="confidential"CLIENT_PUBLIC="public"CLIENT_TYPES=((CLIENT_CONFIDENTIAL,_("Confidential")),(CLIENT_PUBLIC,_("Public")),)GRANT_AUTHORIZATION_CODE="authorization-code"GRANT_IMPLICIT="implicit"GRANT_PASSWORD="password"GRANT_CLIENT_CREDENTIALS="client-credentials"GRANT_OPENID_HYBRID="openid-hybrid"GRANT_TYPES=((GRANT_AUTHORIZATION_CODE,_("Authorization code")),# Disabled for security reasons# (GRANT_IMPLICIT, _("Implicit")),# (GRANT_PASSWORD, _("Resource owner password-based")),(GRANT_CLIENT_CREDENTIALS,_("Client credentials")),# Disabled because we don't support OIDC# (GRANT_OPENID_HYBRID, _("OpenID connect hybrid")),)NO_ALGORITHM=""RS256_ALGORITHM="RS256"HS256_ALGORITHM="HS256"ALGORITHM_TYPES=((NO_ALGORITHM,_("No OIDC support")),# Disabled because we don't support OIDC# (RS256_ALGORITHM, _("RSA with SHA-2 256")),# (HS256_ALGORITHM, _("HMAC with SHA-2 256")),)name=models.CharField(max_length=255,blank=False)# make name requiredauthorization_grant_type=models.CharField(max_length=32,choices=GRANT_TYPES)algorithm=models.CharField(max_length=5,choices=ALGORITHM_TYPES,default=NO_ALGORITHM,blank=True)sanctioned=models.BooleanField(default=False,help_text="Whether this application is sanctioned by the tjCSL.")skip_authorization=models.BooleanField(default=False,help_text=("Skip the authorization page for this application. This will automatically be set to true upon save ""if this application is marked as sanctioned by the CSL."),)sanctioned_but_do_not_skip_authorization=models.BooleanField(default=False,help_text=("Set to true if this application is sanctioned but you do NOT want to skip the authorization page for this application. ""Overrides automatically skipping authorization for sanctioned applications."),)@propertydefuser_has_oauth_and_api_access(self):returnself.user.oauth_and_api_accessdefsave(self,*args,**kwargs):self.skip_authorization=self.sanctionedorself.skip_authorizationself.sanctioned_but_do_not_skip_authorization=self.sanctionedandself.sanctioned_but_do_not_skip_authorizationifself.sanctioned_but_do_not_skip_authorization:self.skip_authorization=Falsesuper().save(*args,**kwargs)