2022-11-22 22:47:17 +01:00
|
|
|
package reqcontext
|
|
|
|
|
|
|
|
import "github.com/notherealmarco/WASAPhoto/service/database"
|
|
|
|
|
|
|
|
type AuthStatus int
|
|
|
|
|
|
|
|
const (
|
|
|
|
AUTHORIZED = 0
|
|
|
|
UNAUTHORIZED = 1
|
|
|
|
FORBIDDEN = 2
|
|
|
|
USER_NOT_FOUND = 3
|
|
|
|
)
|
|
|
|
|
2023-01-10 01:21:53 +01:00
|
|
|
// Authorization is the interface for an authorization provider
|
2022-11-22 22:47:17 +01:00
|
|
|
type Authorization interface {
|
2023-01-10 01:21:53 +01:00
|
|
|
// Returns the type of the authorization provider
|
2022-11-22 22:47:17 +01:00
|
|
|
GetType() string
|
2023-01-10 01:21:53 +01:00
|
|
|
|
|
|
|
// Returns the ID of the currently logged in user
|
2022-11-22 22:47:17 +01:00
|
|
|
GetUserID() string
|
2023-01-10 01:21:53 +01:00
|
|
|
|
|
|
|
// Checks if the token is valid
|
2022-11-22 22:47:17 +01:00
|
|
|
Authorized(db database.AppDatabase) (AuthStatus, error)
|
2023-01-10 01:21:53 +01:00
|
|
|
|
|
|
|
// Checks if the given user and the currently logged in user are the same user
|
2022-11-22 22:47:17 +01:00
|
|
|
UserAuthorized(db database.AppDatabase, uid string) (AuthStatus, error)
|
|
|
|
}
|