Change connection limit to -1 for unlimited so it works with TF (#383)

* Migrate connection limit unlimited value to -1

* Fix authorization check
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-20 15:53:49 -04:00
1 parent 5214f14105
commit edffc7863d
18 files changed
+152 -124

No files matched your search

+2 -2
View File
@@ -65,9 +65,9 @@ with active_session as (
where
-- check that the session hasn't expired.
s.expiration_time > now() and
-- check that there are still connections available. connection_limit of 0 equals unlimited connections
-- check that there are still connections available. connection_limit of -1 equals unlimited connections
(
s.connection_limit = 0
s.connection_limit = -1
or
s.connection_limit > (select count(*) from session_connection sc where sc.session_id = $1)
) and
+1 -1
View File
@@ -335,7 +335,7 @@ func (r *Repository) AuthorizeConnection(ctx context.Context, sessionId string)
type ConnectionAuthzSummary struct {
ExpirationTime *timestamp.Timestamp
ConnectionLimit uint32
ConnectionLimit int32
CurrentConnectionCount uint32
}
+2 -2
View File
@@ -43,7 +43,7 @@ type ComposedOf struct {
// Expiration time for the session
ExpirationTime *timestamp.Timestamp
// Max connections for the session
ConnectionLimit uint32
ConnectionLimit int32
}
// Session contains information about a user's session with a target
@@ -87,7 +87,7 @@ type Session struct {
// Endpoint
Endpoint string `json:"-" gorm:"default:null"`
// Maximum number of connections in a session
ConnectionLimit uint32 `json:"connection_limit,omitempty" gorm:"default:null"`
ConnectionLimit int32 `json:"connection_limit,omitempty" gorm:"default:null"`
// key_id is the key ID that was used for the encryption operation. It can be
// used to identify a specific version of the key needed to decrypt the value,