-
Notifications
You must be signed in to change notification settings - Fork 356
Authentication Metadata Extension support #731
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
Conversation
1979b63
to
8e6b560
Compare
Signed-off-by: Oleh Dokuka <[email protected]>
right now it supports encoding only Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
8e6b560
to
df5bb22
Compare
Signed-off-by: Oleh Dokuka <[email protected]>
/** | ||
* Encode a Authentication CompositeMetadata payload using custom authentication type | ||
* | ||
* @throws IllegalArgumentException if customAuthType is non US_ASCII string if customAuthType is |
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.
nit, the sentence is awkward with ifs.
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.
fixed
metadata.release(); | ||
throw new IllegalArgumentException("custom auth type must be US_ASCII characters only"); | ||
} | ||
if (actualASCIILength < 1 || actualASCIILength > 128) { |
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.
should this be 127?
n.m. see code below.
|
||
int capacity = 1 + actualASCIILength; | ||
ByteBuf headerBuffer = allocator.buffer(capacity, capacity); | ||
// encoded length is one less than actual length, since 0 is never a valid length, which gives |
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.
Is this worthwhile doing? Complexity+Debuggability vs one extra value?
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.
Kind of pattern used in composite metadata impl. Since spec mentions that max length is 128 then it is the only way to make it. If we are not going to encode it in such a way it will not be possible to distinguish size from encoded wellknownauth type. (0-127 for auth types masked with 0x80 1000 0000
which means that value overflows) so if one is going to use 128 length for encoded custom auth type then it will be identified as -1&0x7F == 0 well-known mime type
rsocket-core/src/main/java/io/rsocket/metadata/security/AuthMetadataFlyweight.java
Outdated
Show resolved
Hide resolved
ByteBufAllocator allocator, char[] username, char[] password) { | ||
|
||
int usernameLength = CharByteBufUtil.utf8Bytes(username); | ||
if (usernameLength > 256) { |
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.
Isn't 256 an overflow in the writeByte below?
TYPES_BY_AUTH_ID = new WellKnownAuthType[128]; // 0-127 inclusive | ||
Arrays.fill(TYPES_BY_AUTH_ID, UNKNOWN_RESERVED_AUTH_TYPE); | ||
// also prepare a Map of the types by auth string | ||
TYPES_BY_AUTH_STRING = new HashMap<>(128); |
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.
TIOLI: favour LinkedHashMap for predictability and debuggability.
Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
* fixes tuples bytebufs Signed-off-by: Oleh Dokuka <[email protected]> * provides first draft implementation of AuthMetadataFlyweight right now it supports encoding only Signed-off-by: Oleh Dokuka <[email protected]> * provides full implementation of AuthMetadataFlyweight Signed-off-by: Oleh Dokuka <[email protected]> * provides draft of AuthMetadata Signed-off-by: Oleh Dokuka <[email protected]> * fixes allowed username max length Signed-off-by: Oleh Dokuka <[email protected]> * removes eager release Signed-off-by: Oleh Dokuka <[email protected]> * fixes formating Signed-off-by: Oleh Dokuka <[email protected]> * provides minor fixes Signed-off-by: Oleh Dokuka <[email protected]>
This PR provides the implementation of the Authentication CompositeMetadata. For more information see - > https://github.com/rsocket/rsocket/blob/master/Extensions/Security/Authentication.md