Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ stringData:
PLUGIN_INDEX_PATH: '{{ .Values.config.PLUGIN_INDEX_PATH | default "/opt/hoop/sessions/indexes" }}'
WEBAPP_USERS_MANAGEMENT: '{{ .Values.config.WEBAPP_USERS_MANAGEMENT }}'
ANALYTICS_TRACKING: '{{ .Values.config.ANALYTICS_TRACKING | default "enabled" }}'
MAX_ACCESS_DURATION_HOURS: '{{ .Values.config.MAX_ACCESS_DURATION_HOURS | default "48" }}'
1 change: 1 addition & 0 deletions deploy/helm-chart/chart/gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ config:
# GOOGLE_APPLICATION_CREDENTIALS_JSON: ''
# PLUGIN_AUDIT_PATH: ''
# PLUGIN_INDEX_PATH: ''
# MAX_ACCESS_DURATION_HOURS: '48'

mainService:
# -- Annotations to add in the main service
Expand Down
18 changes: 15 additions & 3 deletions gateway/transport/plugins/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"database/sql"
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -98,10 +100,11 @@ func (p *reviewPlugin) OnReceive(pctx plugintypes.Context, pkt *pb.Packet) (*plu
reviewType = models.ReviewTypeJit
accessDuration, err = time.ParseDuration(string(durationStr))
if err != nil {
return nil, plugintypes.InvalidArgument("invalid access time duration, got=%v", string(durationStr))
return nil, plugintypes.InvalidArgument("invalid access session duration, got=%v", string(durationStr))
}
if accessDuration.Hours() > 48 {
return nil, plugintypes.InvalidArgument("jit access input must not be greater than 48 hours")
maxAccessDurationHours := getMaxAccessDurationHours()
if accessDuration.Hours() > float64(maxAccessDurationHours) {
return nil, plugintypes.InvalidArgument("access session duration must not be greater than %d hours", maxAccessDurationHours)
}
}

Expand Down Expand Up @@ -205,3 +208,12 @@ func validateJit(jit *models.ReviewJit, t time.Time) error {
}
return nil
}

func getMaxAccessDurationHours() int64 {
if v := os.Getenv("MAX_ACCESS_DURATION_HOURS"); v != "" {
if n, err := strconv.ParseInt(v, 10, 64); err == nil && n > 0 {
return n
}
}
return 48
}
Loading