Implement `Exp`/`SetExp`/`Nbf`/`SetNbf`/`Iat`/`SetIat` methods on `Token`
type which provide access to the message fields of the same name.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Remove usage of deprecated of `container.ID` and `token.SessionToken` code
elements. Replace using of custom message generators with the ones provided
by packages. Replace string comparison with `Equal` method call.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Implement `Context` / `SetContext` methods on `Token` which reads / sets
token context. Support container context (`ContainerContext`).
Add helper function `GetContainerContext` for easy reading of the container
context.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define `ContainerContext` type for container sessions. Implement basic
functionality to work with its data.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Add `sessiontest.GenerateSigned` function which returns signed random token.
Clarify that `sessiontest.Generate` returns an unsigned token. Use these
functions to assert the correctness of `Sign` / `VerifySignature` methods.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Implement `Token.Sign` method which calculates signature of the data of the
`Token` and writes the signature into it. Implement `Token.VerifySignature`
which checks if `Token` signature is presented and valid. These methods
allow to abstract the external context from the details of what kind of data
is being signed and how the signature is stored.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
There is a need to add session token to `eacl.Table` structure. To do this,
we need to replace `token.SessionToken` type to another package since `eacl`
package imports `token` one (potential cross-import).
Create `pkg/session` package and replace session token implementation to it.
Related API in `container` package is deprecated from now.
Additionally implement test generator of random session tokens.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>