github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/token/init.go (about) 1 package token 2 3 import ( 4 "time" 5 6 "github.com/cozy/cozy-stack/pkg/prefixer" 7 ) 8 9 // Service used to generate token to protect and authenticate an operation 10 // outside cozy. 11 // 12 // This service is used to protect unauthenticated operation done oustide the 13 // stack. For example when we need to validate an email with an URL link. 14 // Without this random token inside the url anyone could validate the email for 15 // anyone as user come unauthenticated. 16 type Service interface { 17 GenerateAndSave(db prefixer.Prefixer, op Operation, resource string, lifetime time.Duration) (string, error) 18 Validate(db prefixer.Prefixer, op Operation, resource, token string) error 19 }