Skip to content

Credentials App

Models

Credential

Credential(id, vc_json, issuer, holder, schema, title, description, credential_type, status, created_at, issued_at, expiration_date, revocation_reason, vc_hash, document)

Fields

  • id (UUIDField)
  • vc_json (JSONField)
  • issuer (ForeignKey)
  • holder (ForeignKey)
  • schema (ForeignKey) - nullable - blank allowed
  • title (CharField)
  • description (TextField) - nullable - blank allowed
  • credential_type (CharField)
  • status (CharField)
  • created_at (DateTimeField)
  • issued_at (DateTimeField) - nullable - blank allowed
  • expiration_date (DateField) - nullable - blank allowed
  • revocation_reason (TextField) - nullable - blank allowed
  • vc_hash (CharField) - nullable - blank allowed - SHA256 hash of the credential JSON
  • document (FileField) - nullable - blank allowed - Upload PDF, JPG, PNG, or other document formats

Methods

  • adelete(self, using=None, keep_parents=False)
  • arefresh_from_db(self, using=None, fields=None, from_queryset=None)
  • asave(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)
  • clean(self)

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

  • clean_fields(self, exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

  • date_error_message(self, lookup_type, field_name, unique_for)
  • delete(self, using=None, keep_parents=False)
  • full_clean(self, exclude=None, validate_unique=True, validate_constraints=True)

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

  • get_constraints(self)
  • get_deferred_fields(self)

Return a set containing names of deferred fields for this instance.

  • get_next_by_created_at(self, , field=, is_next=True, *kwargs)
  • get_previous_by_created_at(self, , field=, is_next=False, *kwargs)
  • get_status_display(self, *, field=)
  • issue(self)
  • prepare_database_save(self, field)
  • refresh_from_db(self, using=None, fields=None, from_queryset=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn't loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

  • revoke(self, reason='')
  • save(self, args, *kwargs)
  • save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

  • serializable_value(self, field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value.

Used to serialize a field's value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

  • unique_error_message(self, model_class, unique_check)
  • validate_constraints(self, exclude=None)
  • validate_unique(self, exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.

  • verify_document_integrity(self) Verify that the document hash matches the stored document

CredentialSchema

CredentialSchema(id, name, version, type, fields, created_by, created_at, updated_at)

Fields

  • id (UUIDField)
  • name (CharField)
  • version (CharField)
  • type (CharField)
  • fields (JSONField) - JSON structure defining the credential fields
  • created_by (ForeignKey)
  • created_at (DateTimeField)
  • updated_at (DateTimeField) - blank allowed

Methods

  • adelete(self, using=None, keep_parents=False)
  • arefresh_from_db(self, using=None, fields=None, from_queryset=None)
  • asave(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)
  • clean(self)

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

  • clean_fields(self, exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

  • date_error_message(self, lookup_type, field_name, unique_for)
  • delete(self, using=None, keep_parents=False)
  • full_clean(self, exclude=None, validate_unique=True, validate_constraints=True)

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

  • get_constraints(self)
  • get_deferred_fields(self)

Return a set containing names of deferred fields for this instance.

  • get_next_by_created_at(self, , field=, is_next=True, *kwargs)
  • get_next_by_updated_at(self, , field=, is_next=True, *kwargs)
  • get_previous_by_created_at(self, , field=, is_next=False, *kwargs)
  • get_previous_by_updated_at(self, , field=, is_next=False, *kwargs)
  • get_type_display(self, *, field=)
  • prepare_database_save(self, field)
  • refresh_from_db(self, using=None, fields=None, from_queryset=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn't loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

  • save(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)

Save the current instance. Override this in a subclass if you want to control the saving process.

The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

  • save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

  • serializable_value(self, field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value.

Used to serialize a field's value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

  • unique_error_message(self, model_class, unique_check)
  • validate_constraints(self, exclude=None)
  • validate_unique(self, exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.


VerificationRecord

Model to track verification history

Fields

  • id (UUIDField)
  • verifier (ForeignKey)
  • credential_hash (CharField) - 64-character hex hash of the credential
  • credential (ForeignKey) - nullable - blank allowed
  • verification_date (DateTimeField)
  • is_valid (BooleanField)
  • verification_details (JSONField) - Detailed verification results
  • source (CharField)

Methods

  • adelete(self, using=None, keep_parents=False)
  • arefresh_from_db(self, using=None, fields=None, from_queryset=None)
  • asave(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)
  • clean(self)

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

  • clean_fields(self, exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

  • date_error_message(self, lookup_type, field_name, unique_for)
  • delete(self, using=None, keep_parents=False)
  • full_clean(self, exclude=None, validate_unique=True, validate_constraints=True)

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

  • get_constraints(self)
  • get_deferred_fields(self)

Return a set containing names of deferred fields for this instance.

  • get_next_by_verification_date(self, , field=, is_next=True, *kwargs)
  • get_previous_by_verification_date(self, , field=, is_next=False, *kwargs)
  • get_source_display(self, *, field=)
  • prepare_database_save(self, field)
  • refresh_from_db(self, using=None, fields=None, from_queryset=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn't loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

  • save(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)

Save the current instance. Override this in a subclass if you want to control the saving process.

The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

  • save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

  • serializable_value(self, field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value.

Used to serialize a field's value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

  • unique_error_message(self, model_class, unique_check)
  • validate_constraints(self, exclude=None)
  • validate_unique(self, exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.


Views

credential_detail


delete_verification

Delete a verification record


edit_credential

Edit a credential - allowed for draft and issued credentials


execute_task_with_fallback

Execute a task with fallback mechanism.

First tries to execute via Celery (.delay()), if that fails, falls back to direct execution.

Args: task_func: The Celery task function args: Arguments to pass to the task *kwargs: Keyword arguments to pass to the task

Returns: dict: Result information with keys: - success: bool - method: 'celery' or 'direct' - result: The actual result or error message - task_id: Celery task ID (if using Celery)


generate_key_pair

Generate SECP256k1 key pair in hex format


generate_public_key_from_private

Derive public key from private key hex


get_object_or_404

Use get() to return an object, or raise an Http404 exception if the object does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more than one object is found.


get_task_status_message

Get a user-friendly message from a task execution result.

Args: result_dict: Result dictionary from execute_task_with_fallback

Returns: str: User-friendly status message


issue_credential


issue_draft_credential

Issue a draft credential


issued_credentials


login_required

Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.


redirect

Return an HttpResponseRedirect to the appropriate URL for the arguments passed.

The arguments could be:

* A model: the model's `get_absolute_url()` function will be called.

* A view name, possibly with arguments: `urls.reverse()` will be used
  to reverse-resolve the name.

* A URL, which will be used as-is for the redirect location.

Issues a temporary redirect by default. Set permanent=True to issue a permanent redirect. Set preserve_request=True to instruct the user agent to preserve the original HTTP method and body when following the redirect.


render

Return an HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments.


request_credential

Request a credential from an issuer


revoke_credential


schema_create


schema_list


shared_credentials

View shared credentials for verifiers


show_verification_result


sign_json_ld

Sign JSON-LD data using ECDSA with secp256k1 curve :param data_bytes: Bytes representation of the JSON-LD data :param private_key_hex: Private key in hex format :return: Signed JSON-LD document with proof


verification_history

View verification history for verifiers


verify_credential

Public credential verification view


verify_data

Verify ECDSA signature


verify_external_credential

Handle verification for credentials not in our database


verify_json_ld

Verify JSON-LD signature :param data_bytes: Original data in bytes :param signature_hex: Signature in hex format :param public_key_hex: Public key in hex format :return: True if valid, False otherwise


verify_json_ld_signature

Verify a JSON-LD signature


Forms

CredentialRevokeForm