Documentation
¶
Index ¶
- Variables
- type SignedToken
- func (t *SignedToken) Equal(o *SignedToken) bool
- func (t *SignedToken) MarshalBinary() (out []byte, err error)
- func (t *SignedToken) Scan(value interface{}) error
- func (t *SignedToken) Signature() []byte
- func (t *SignedToken) UnmarshalBinary(data []byte) (err error)
- func (t *SignedToken) Validate() (err error)
- func (t *SignedToken) Value() (_ driver.Value, err error)
- func (t *SignedToken) Verify(token VerificationToken) (secure bool, err error)
- type Token
- type VerificationToken
Constants ¶
This section is empty.
Variables ¶
var ( ErrDecode = errors.New("sunrise: could not decode token") ErrSize = errors.New("sunrise: invalid size for token") ErrInvalidSunriseID = errors.New("invalid sunrise token: no sunrise id") ErrInvalidExpiration = errors.New("invalid sunrise token: no expiration timestamp") ErrInvalidNonce = errors.New("invalid sunrise token: incorrect nonce") ErrInvalidSignature = errors.New("invalid sunrise token: incorrect hmac signature") ErrUnexpectedType = errors.New("sunrise: could not scan non-bytes type") )
Functions ¶
This section is empty.
Types ¶
type SignedToken ¶
type SignedToken struct {
Token
// contains filtered or unexported fields
}
A signed token contains a signature that can be stored in the local database in order to verify an incoming verification token from a client.
func (*SignedToken) Equal ¶
func (t *SignedToken) Equal(o *SignedToken) bool
func (*SignedToken) MarshalBinary ¶
func (t *SignedToken) MarshalBinary() (out []byte, err error)
func (*SignedToken) Scan ¶
func (t *SignedToken) Scan(value interface{}) error
Scan the signed token from a database query.
func (*SignedToken) Signature ¶
func (t *SignedToken) Signature() []byte
Retrieve the signature from the signed token.
func (*SignedToken) UnmarshalBinary ¶
func (t *SignedToken) UnmarshalBinary(data []byte) (err error)
func (*SignedToken) Validate ¶
func (t *SignedToken) Validate() (err error)
func (*SignedToken) Value ¶
func (t *SignedToken) Value() (_ driver.Value, err error)
Produce a database value from the signed token for inserts/updates to database.
func (*SignedToken) Verify ¶
func (t *SignedToken) Verify(token VerificationToken) (secure bool, err error)
Verify that a signed token belongs with the associated verification token.
type Token ¶
type Token struct {
SunriseID ulid.ULID // ID of the sunrise record in the database
Expiration time.Time // Expiration date of the token (not after)
// contains filtered or unexported fields
}
A Token is a data representation of the information needed to create a secure sunrise verification token to send to the compliance officer of the counterparty. Tokens can be used to generate SignedTokens and SignedTokens can be used to send a secure verification token and to verify that tokens belong to the specified user.
func NewToken ¶
Create a new token with the specified ID and expiration timestamp. If the timestamp is zero valued, then a timestamp in the future will be generated with the default expiration deadline.
func (*Token) MarshalBinary ¶
func (*Token) Sign ¶
func (t *Token) Sign() (token VerificationToken, signature *SignedToken, err error)
Sign a token creating a verification token that should be sent as a string to the counterparty and a signed token that should be stored in the database.
func (*Token) UnmarshalBinary ¶
type VerificationToken ¶
type VerificationToken []byte
A verification token is sent to the client and contains the information needed to lookup a signed token in the database and to verify that the message is authentic.
func ParseVerification ¶
func ParseVerification(tks string) (_ VerificationToken, err error)
func (VerificationToken) Secret ¶
func (v VerificationToken) Secret() []byte
func (VerificationToken) String ¶
func (v VerificationToken) String() string
func (VerificationToken) SunriseID ¶
func (v VerificationToken) SunriseID() ulid.ULID