-
Notifications
You must be signed in to change notification settings - Fork 15
session: add a new session token v2 #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
End-rey
wants to merge
1
commit into
master
Choose a base branch
from
new-session-token-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,48 @@ import "status/types.proto"; | |
| option csharp_namespace = "Neo.FileStorage.API.Session"; | ||
| option go_package = "github.com/nspcc-dev/neofs-sdk-go/proto/session"; | ||
|
|
||
| // Verb represents all possible operations in NeoFS that can be authorized | ||
| // via session tokens or delegation chains. This enum covers both object and | ||
| // container service operations. | ||
| enum Verb { | ||
| // Unknown verb | ||
| VERB_UNSPECIFIED = 0; | ||
|
|
||
| // Object operations | ||
|
|
||
| // Refers to object.Put RPC call | ||
| OBJECT_PUT = 1; | ||
|
|
||
| // Refers to object.Get RPC call | ||
| OBJECT_GET = 2; | ||
|
|
||
| // Refers to object.Head RPC call | ||
| OBJECT_HEAD = 3; | ||
|
|
||
| // Refers to object.Search RPC call | ||
| OBJECT_SEARCH = 4; | ||
|
|
||
| // Refers to object.Delete RPC call | ||
| OBJECT_DELETE = 5; | ||
|
|
||
| // Refers to object.GetRange RPC call | ||
| OBJECT_RANGE = 6; | ||
|
|
||
| // Refers to object.GetRangeHash RPC call | ||
| OBJECT_RANGEHASH = 7; | ||
|
|
||
| // Container operations | ||
|
|
||
| // Refers to container.Put RPC call | ||
| CONTAINER_PUT = 8; | ||
|
|
||
| // Refers to container.Delete RPC call | ||
| CONTAINER_DELETE = 9; | ||
|
|
||
| // Refers to container.SetExtendedACL RPC call | ||
| CONTAINER_SETEACL = 10; | ||
| } | ||
|
|
||
| // Context information for Session Tokens related to ObjectService requests | ||
| message ObjectSessionContext { | ||
| // Object request verbs | ||
|
|
@@ -85,6 +127,21 @@ message ContainerSessionContext { | |
| refs.ContainerID container_id = 3 [json_name = "containerID"]; | ||
| } | ||
|
|
||
| // Lifetime parameters of the token. Field names taken from rfc7519. | ||
| message TokenLifetime { | ||
| // Expiration epoch, the last epoch when token is valid. | ||
| // For SessionTokenV2 this is the last valid Unix timestamp. | ||
| uint64 exp = 1 [json_name = "exp"]; | ||
|
|
||
| // Not valid before epoch, the first epoch when token is valid. | ||
| // For SessionTokenV2 this is the first valid Unix timestamp. | ||
| uint64 nbf = 2 [json_name = "nbf"]; | ||
|
|
||
| // Issued at epoch. | ||
| // For SessionTokenV2 this is the Unix timestamp when the token was issued. | ||
| uint64 iat = 3 [json_name = "iat"]; | ||
| } | ||
|
|
||
| // NeoFS Session Token. | ||
| message SessionToken { | ||
| // Session Token body | ||
|
|
@@ -95,17 +152,6 @@ message SessionToken { | |
| // Identifier of the session initiator | ||
| neo.fs.v2.refs.OwnerID owner_id = 2 [json_name = "ownerID"]; | ||
|
|
||
| // Lifetime parameters of the token. Field names taken from rfc7519. | ||
| message TokenLifetime { | ||
| // Expiration epoch, the last epoch when token is valid. | ||
| uint64 exp = 1 [json_name = "exp"]; | ||
|
|
||
| // Not valid before epoch, the first epoch when token is valid. | ||
| uint64 nbf = 2 [json_name = "nbf"]; | ||
|
|
||
| // Issued at Epoch | ||
| uint64 iat = 3 [json_name = "iat"]; | ||
| } | ||
| // Lifetime of the session | ||
| TokenLifetime lifetime = 3 [json_name = "lifetime"]; | ||
|
|
||
|
|
@@ -175,6 +221,10 @@ message RequestMetaHeader { | |
| // Session token within which the request is sent | ||
| SessionToken session_token = 5 [json_name = "sessionToken"]; | ||
|
|
||
| // Session token v2 with delegation chain support. | ||
| // If both session_token and session_token_v2 are set, session_token_v2 takes precedence. | ||
| SessionTokenV2 session_token_v2 = 9 [json_name = "sessionTokenV2"]; | ||
|
|
||
| // `BearerToken` with eACL overrides for the request | ||
| neo.fs.v2.acl.BearerToken bearer_token = 6 [json_name = "bearerToken"]; | ||
|
|
||
|
|
@@ -232,3 +282,96 @@ message ResponseVerificationHeader { | |
| // Chain of previous hops signatures | ||
| ResponseVerificationHeader origin = 4 [json_name = "origin"]; | ||
| } | ||
|
|
||
| // Session Token v2 | ||
|
|
||
| // Target account for SessionTokenV2. | ||
| // It can be either direct (OwnerID) or indirect (NNS domain). | ||
| message Target { | ||
| // Account identifier. | ||
| oneof identifier { | ||
| // Direct account reference via OwnerID (hash of verification script). | ||
| neo.fs.v2.refs.OwnerID owner_id = 1 [json_name = "ownerID"]; | ||
|
|
||
| // Indirect account reference via NeoFS Name Service. | ||
| // NNS name is a domain name that resolves to an OwnerID through the | ||
| // NeoFS Name Service. The name must be a valid DNS-like domain name | ||
| // (e.g., "example.neofs") that is registered in the NNS contract on | ||
| // the Neo blockchain. The NNS record should contain a string record with | ||
| // the corresponding OwnerID value. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mention NEP-18? |
||
| string nns_name = 2 [json_name = "nnsName"]; | ||
| } | ||
| } | ||
|
|
||
| // DelegationInfo represents a single delegation in a chain of trust. | ||
| message DelegationInfo { | ||
| // Account that performed this delegation. | ||
| Target issuer = 1 [json_name = "issuer"]; | ||
|
|
||
| // Accounts that received the delegation. | ||
| repeated Target subjects = 2 [json_name = "subjects"]; | ||
|
|
||
| // Lifetime of this delegation. | ||
| // Allows each delegation in the chain to have its own validity window. | ||
| TokenLifetime lifetime = 3 [json_name = "lifetime"]; | ||
|
|
||
| // List of verbs authorized by this delegation. | ||
| repeated Verb verbs = 4 [json_name = "verbs"]; | ||
|
|
||
| // Signature of the issuer confirming this delegation record. | ||
| // The signature is created over the deterministic serialization | ||
| // of this DelegationInfo message excluding this field. | ||
| neo.fs.v2.refs.Signature signature = 5 [json_name = "signature"]; | ||
| } | ||
|
|
||
| // SessionContextV2 carries unified context for both ObjectService and ContainerService requests. | ||
| message SessionContextV2 { | ||
| // Container where operation is allowed. | ||
| // For container operations, this is the container being operated on. | ||
| // For object operations, this is the container holding the objects. | ||
| neo.fs.v2.refs.ContainerID container = 1 [json_name = "container"]; | ||
|
|
||
| // Specific objects where operation is allowed. | ||
| // Only relevant for object operations. | ||
| // Empty list means all objects in the container. | ||
| repeated neo.fs.v2.refs.ObjectID objects = 2 [json_name = "objects"]; | ||
|
|
||
| // Operations authorized for this context. | ||
| repeated Verb verbs = 3 [json_name = "verbs"]; | ||
| } | ||
|
|
||
| // SessionTokenV2 represents NeoFS Session Token with delegation support. | ||
| message SessionTokenV2 { | ||
| // Session Token body. | ||
| message Body { | ||
| // Token version. | ||
| uint32 version = 1 [json_name = "version"]; | ||
|
|
||
| // Token identifier (UUIDv4 in binary form). | ||
| bytes id = 2 [json_name = "id"]; | ||
|
|
||
| // Account that issued this token (who signed it). | ||
| Target issuer = 3 [json_name = "issuer"]; | ||
|
|
||
| // Accounts authorized by this token (who can use it). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need some limits for all repeated fields. |
||
| repeated Target subjects = 4 [json_name = "subjects"]; | ||
|
|
||
| // Lifetime of this token. | ||
| TokenLifetime lifetime = 5 [json_name = "lifetime"]; | ||
|
|
||
| // Unified session contexts for both object and container operations. | ||
| // Multiple contexts allow authorization for different combinations. | ||
| repeated SessionContextV2 contexts = 6 [json_name = "contexts"]; | ||
| } | ||
|
|
||
| // Session token body. | ||
| Body body = 1 [json_name = "body"]; | ||
|
|
||
| // Signature of the body by the issuer. | ||
| neo.fs.v2.refs.Signature signature = 2 [json_name = "signature"]; | ||
|
|
||
| // DelegationInfo is a full history of authority delegation (chain of trust). | ||
| // Similar to X.509 certificate chains, each delegation entry | ||
| // is independently signed by its issuer. | ||
| repeated DelegationInfo delegation_chain = 3 [json_name = "delegationChain"]; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TokenLifetime, so we can keep it as is and add this new one for v2.