[#1454] cli/util: Support container sessions in sign session-token
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ff576d125d
commit
2da8396a9f
1 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -38,8 +40,26 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
|
||||||
common.ExitOnErr(cmd, "", errors.New("missing session token flag"))
|
common.ExitOnErr(cmd, "", errors.New("missing session token flag"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var stok session.Object
|
type iTokenSession interface {
|
||||||
common.ReadSessionToken(cmd, &stok, signFromFlag)
|
json.Marshaler
|
||||||
|
json.Unmarshaler
|
||||||
|
Sign(ecdsa.PrivateKey) error
|
||||||
|
}
|
||||||
|
var errLast error
|
||||||
|
var stok iTokenSession
|
||||||
|
|
||||||
|
for _, el := range [...]iTokenSession{
|
||||||
|
new(session.Object),
|
||||||
|
new(session.Container),
|
||||||
|
} {
|
||||||
|
errLast = common.ReadSessionTokenErr(el, fPath)
|
||||||
|
if errLast == nil {
|
||||||
|
stok = el
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
common.ExitOnErr(cmd, "", errLast)
|
||||||
|
|
||||||
pk := key.GetOrGenerate(cmd)
|
pk := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue