Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇

feat(canary): Generator interface for token-type plugins

CarterPerez-dev6cc724c19f94
diff --git a/PROJECTS/beginner/canary-token-generator/backend/internal/token/generators/generator.go b/PROJECTS/beginner/canary-token-generator/backend/internal/token/generators/generator.go
new file mode 100644
index 00000000..2c91bc9d
--- /dev/null
+++ b/PROJECTS/beginner/canary-token-generator/backend/internal/token/generators/generator.go
@@ -0,0 +1,45 @@
+// ©AngelaMos | 2026
+// generator.go
+
+package generators
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/CarterPerez-dev/cybersecurity-projects/canary-token-generator/backend/internal/event"
+ "github.com/CarterPerez-dev/cybersecurity-projects/canary-token-generator/backend/internal/token"
+)
+
+type ArtifactKind string
+
+const (
+ KindURL ArtifactKind = "url"
+ KindFile ArtifactKind = "file"
+ KindText ArtifactKind = "text"
+ KindConnectionString ArtifactKind = "connection_string"
+)
+
+type Artifact struct {
+ Kind ArtifactKind
+ URL string
+ Filename string
+ Content []byte
+ ContentType string
+ ConnectionString string
+ DestinationURL string
+}
+
+type TriggerResponse struct {
+ StatusCode int
+ ContentType string
+ Body []byte
+ RedirectURL string
+ ExtraHeaders map[string]string
+}
+
+type Generator interface {
+ Type() token.Type
+ Generate(ctx context.Context, t *token.Token, baseURL string) (Artifact, error)
+ Trigger(ctx context.Context, t *token.Token, r *http.Request) (*event.Event, *TriggerResponse, error)
+}