Documentation
¶
Index ¶
Constants ¶
View Source
const (
PrefixLength = 4
)
Variables ¶
This section is empty.
Functions ¶
func GeneratePasswordFromUserId ¶
GeneratePasswordFromUserId generates a deterministic shorter password from user ID using HMAC-SHA256. This is used for third-party system integration where users are auto-created.
Parameters:
- userId: The IM system user ID (e.g., "u___42" or "ag__7")
- secret: A secret key from configuration (should be kept secure)
- nBytes: number of bytes to keep from HMAC (e.g. 12 or 16)
Returns:
- A shorter deterministic string that can be used as password
Example:
password := GeneratePasswordFromUserId("u___42", "my-secret-key", 12)
// password will always be the same for "u___42" with the same secret
Types ¶
type Actor ¶
Actor represents an external identity that maps to an IM user id.
func (*Actor) FromIMUserId ¶
FromIMUserId parses an IM user id string back into an Actor. Returns an error if the format is unrecognised.
func (*Actor) ToIMUserId ¶
ToIMUserId converts an Actor to the IM system's string user id.
Actor{ID: 42, Role: RoleUser}.ToIMUserId() => "u___42"
Actor{ID: 7, Role: RoleAgent}.ToIMUserId() => "ag__7"
Click to show internal directories.
Click to hide internal directories.