2020-09-16 12:02:02 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2020-09-16 12:02:02 -04:00
|
|
|
package session
|
|
|
|
|
|
|
|
|
|
import (
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
2020-09-16 12:02:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
2021-02-03 16:25:56 -08:00
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
2020-09-16 12:02:02 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// StatePrefix for state PK ids
|
|
|
|
|
StatePrefix = "ss"
|
|
|
|
|
|
|
|
|
|
// ConnectionPrefix for connection PK ids
|
|
|
|
|
ConnectionPrefix = "sc"
|
|
|
|
|
|
|
|
|
|
// ConnectionStatePrefix for connection state PK ids
|
|
|
|
|
ConnectionStatePrefix = "scs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func newId() (string, error) {
|
2021-02-03 16:25:56 -08:00
|
|
|
const op = "session.newId"
|
2023-03-10 15:06:39 -05:00
|
|
|
id, err := db.NewPublicId(globals.SessionPrefix)
|
2020-09-16 12:02:02 -04:00
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-09-16 12:02:02 -04:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newStateId() (string, error) {
|
2021-02-03 16:25:56 -08:00
|
|
|
const op = "session.newStateId"
|
2020-09-16 12:02:02 -04:00
|
|
|
id, err := db.NewPublicId(StatePrefix)
|
|
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-09-16 12:02:02 -04:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newConnectionId() (string, error) {
|
2021-02-03 16:25:56 -08:00
|
|
|
const op = "session.newConnectionId"
|
2020-09-16 12:02:02 -04:00
|
|
|
id, err := db.NewPublicId(ConnectionPrefix)
|
|
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-09-16 12:02:02 -04:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newConnectionStateId() (string, error) {
|
2021-02-03 16:25:56 -08:00
|
|
|
const op = "session.newConnectionStateId"
|
2020-09-16 12:02:02 -04:00
|
|
|
id, err := db.NewPublicId(ConnectionStatePrefix)
|
|
|
|
|
if err != nil {
|
2021-07-29 18:52:56 -06:00
|
|
|
return "", errors.WrapDeprecated(err, op)
|
2020-09-16 12:02:02 -04:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|