Documentation
¶
Index ¶
- func GetUserIdFromContext(ctx context.Context) uuid.UUID
- func SetUserInContext(ctx context.Context, userId uuid.UUID) context.Context
- type AccessToken
- type AccessTokenCacheDs
- type AccessTokenDatabaseDs
- type AccessTokenRepository
- type CustomClaims
- type HashDatasource
- type JWTMetadata
- type JwtDatasource
- type Note
- type NoteCacheDs
- type NoteDatabaseDs
- type NoteRepository
- type RefreshToken
- type RefreshTokenCacheDs
- type RefreshTokenDatabaseDs
- type RefreshTokenRepository
- type User
- type UserCacheDs
- type UserDatabaseDs
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserIdFromContext ¶
Get user from context
Types ¶
type AccessToken ¶
type AccessToken struct { Id uuid.UUID `json:"id"` UserId uuid.UUID `json:"user_id"` RefreshTokenId uuid.UUID `json:"refresh_token_id"` CreateTime time.Time `json:"create_time"` UpdateTime time.Time `json:"update_time"` }
func NewAccessToken ¶
func NewAccessToken(userId uuid.UUID, refreshTokenId uuid.UUID) *AccessToken
NewAccessToken creates a new AccessToken instance
type AccessTokenCacheDs ¶
type AccessTokenDatabaseDs ¶
type AccessTokenRepository ¶
type AccessTokenRepository interface { GetAccessToken(ctx context.Context, id uuid.UUID) (*AccessToken, error) CreateAccessToken(ctx context.Context, userId uuid.UUID, refreshTokenId uuid.UUID) (*AccessToken, error) DeleteAccessTokenByUserId(ctx context.Context, userId uuid.UUID) error }
func NewAccessTokenRepository ¶
func NewAccessTokenRepository(accessTokenCacheDs AccessTokenCacheDs, accessTokenDatabaseDs AccessTokenDatabaseDs) AccessTokenRepository
type CustomClaims ¶
type CustomClaims struct { UserID string `json:"user_id"` jwt.StandardClaims }
CustomClaims defines the structure of the JWT claims
type HashDatasource ¶
type HashDatasource interface { // Hash takes a string value and returns its hash representation. // It returns an error if the hashing operation fails. Hash(value string) (string, error) // CheckHash verifies if the given hash matches the hash of the provided value. // It returns true if the hash matches, false otherwise. CheckHash(value, hash string) (bool, error) }
HashDatasource defines the methods for hashing values and checking hashes. Implementations of this interface should provide mechanisms to hash values and verify if a given hash matches a hashed value.
type JwtDatasource ¶
type JwtDatasource interface { CreateJWT(tokenMetadata *JWTMetadata, expirationTime time.Time) (*string, error) ParseJWT(tokenMetadata *JWTMetadata) error }
func NewJWTDatasource ¶
func NewJWTDatasource(cfg *config.Configuration) JwtDatasource
type NoteCacheDs ¶
type NoteDatabaseDs ¶
type NoteDatabaseDs interface { ListNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error) ListTrashNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error) GetNote(ctx context.Context, id uuid.UUID) (*Note, error) CreateNote(ctx context.Context, note *Note) (*Note, error) UpdateNote(ctx context.Context, note *Note) (*Note, error) RestoreNote(ctx context.Context, id uuid.UUID) (*Note, error) HardDeleteNote(ctx context.Context, id uuid.UUID) error SoftDeleteNote(ctx context.Context, id uuid.UUID) error }
type NoteRepository ¶
type NoteRepository interface { ListNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error) ListTrashNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error) // GetNote(ctx context.Context, id uuid.UUID) (*Note, error) CreateNote(ctx context.Context, note *Note) (*Note, error) RestoreNote(ctx context.Context, id uuid.UUID) (*Note, error) UpdateNote(ctx context.Context, note *Note) (*Note, error) DeleteNote(ctx context.Context, id uuid.UUID, isHard bool) error }
func NewNoteRepository ¶
func NewNoteRepository(noteCacheDs *NoteCacheDs, noteDatabaseDs *NoteDatabaseDs) NoteRepository
type RefreshToken ¶
type RefreshTokenCacheDs ¶
type RefreshTokenDatabaseDs ¶
type RefreshTokenRepository ¶
type RefreshTokenRepository interface { GetRefreshToken(ctx context.Context, id uuid.UUID) (*RefreshToken, error) CreateRefreshToken(ctx context.Context, refreshToken *RefreshToken) (*RefreshToken, error) DeleteRefreshTokenByUserId(ctx context.Context, userId uuid.UUID) error }
func NewRefreshTokenRepository ¶
func NewRefreshTokenRepository(refreshTokenCacheDs *RefreshTokenCacheDs, refreshTokenDatabaseDs *RefreshTokenDatabaseDs) RefreshTokenRepository
type UserCacheDs ¶
type UserCacheDs interface { GetUserByEmail(ctx context.Context, email string) (*User, error) GetUserById(ctx context.Context, id uuid.UUID) (*User, error) CreateUser(ctx context.Context, user *User) error UpdateUser(ctx context.Context, user *User) error DeleteUser(ctx context.Context, id uuid.UUID) error }
type UserDatabaseDs ¶
type UserRepository ¶
type UserRepository interface { CreateUser(ctx context.Context, user *User) (*User, error) GetUserById(ctx context.Context, id uuid.UUID) (*User, error) GetUserByEmail(ctx context.Context, email string) (*User, error) }
func NewUserRepository ¶
func NewUserRepository(userCacheDs *UserCacheDs, userDatabaseDs *UserDatabaseDs) UserRepository
Source Files
¶
- access_token.go
- access_token_cache_ds.go
- access_token_database_ds.go
- access_token_repository.go
- hash_datasource.go
- jwt_ds.go
- note.go
- note_cache_ds.go
- note_database_ds.go
- note_repository.go
- refresh_token.go
- refresh_token_cache_ds.go
- refresh_token_database_ds.go
- refresh_token_repository.go
- user.go
- user_cache_ds.go
- user_database_ds.go
- user_repository.go
- utils.go
Click to show internal directories.
Click to hide internal directories.