improved authentication check
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/minio/minio-go/v7"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
errors "git.kapelle.org/niklas/s3browser/internal/errors"
|
||||
types "git.kapelle.org/niklas/s3browser/internal/types"
|
||||
)
|
||||
|
||||
@@ -114,18 +113,9 @@ func GetParentDir(id string) string {
|
||||
return NomalizeID(parent)
|
||||
}
|
||||
|
||||
func IsAuth(ctx context.Context) (bool, error) {
|
||||
func IsAuthenticated(ctx context.Context) bool {
|
||||
token, ok := ctx.Value("jwt").(*jwt.Token)
|
||||
|
||||
if !ok {
|
||||
return false, errors.ExtendError("UNAUTHORIZED", "Unauthorized")
|
||||
}
|
||||
|
||||
if token.Valid {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, errors.ExtendError("UNAUTHORIZED", "Unauthorized")
|
||||
}
|
||||
return (ok && token.Valid)
|
||||
}
|
||||
|
||||
func CreateJWT(claims *types.JWTClaims) *jwt.Token {
|
||||
|
||||
Reference in New Issue
Block a user