added auth service to go backend
This commit is contained in:
@@ -5,16 +5,17 @@ type ErrorCode string
|
||||
|
||||
const (
|
||||
// General errors
|
||||
InternalError ErrorCode = "internal_error"
|
||||
ValidationError ErrorCode = "validation_error"
|
||||
NotFoundError ErrorCode = "not_found"
|
||||
UnauthorizedError ErrorCode = "unauthorized"
|
||||
ForbiddenError ErrorCode = "forbidden"
|
||||
ConflictError ErrorCode = "conflict"
|
||||
DatabaseError ErrorCode = "database_error"
|
||||
InternalError ErrorCode = "internal_error"
|
||||
ValidationError ErrorCode = "validation_error"
|
||||
NotFoundError ErrorCode = "not_found"
|
||||
UnauthorizedError ErrorCode = "unauthorized"
|
||||
ForbiddenError ErrorCode = "forbidden"
|
||||
ConflictError ErrorCode = "conflict"
|
||||
DatabaseError ErrorCode = "database_error"
|
||||
ExternalServiceError ErrorCode = "external_service_error"
|
||||
AuthError ErrorCode = "auth_error"
|
||||
|
||||
// Specific errors
|
||||
UserNotFoundError ErrorCode = "user_not_found"
|
||||
UserNotFoundError ErrorCode = "user_not_found"
|
||||
ProjectNotFoundError ErrorCode = "project_not_found"
|
||||
)
|
||||
|
||||
@@ -23,3 +23,8 @@ func NewUnauthorizedError(message string) *AppError {
|
||||
func NewInternalError(err error) *AppError {
|
||||
return Wrap(err, InternalError, "An internal server error occurred", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// NewAuthError creates an authentication error.
|
||||
func NewAuthError(message string) *AppError {
|
||||
return New(AuthError, message, http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
E "github.com/IBM/fp-go/either"
|
||||
)
|
||||
|
||||
type AuthRepository interface {
|
||||
GenerateToken(ctx context.Context) func(userID string) E.Either[error, string]
|
||||
ValidateToken(ctx context.Context) func(userID string) E.Either[error, string]
|
||||
RevokeToken(ctx context.Context) func(userID string) E.Either[error, string]
|
||||
}
|
||||
Reference in New Issue
Block a user