Skip to content

Conversation

@OlegDokuka
Copy link
Member

This PR provides the implementation of the Authentication CompositeMetadata. For more information see - > https://github.com/rsocket/rsocket/blob/master/Extensions/Security/Authentication.md

@OlegDokuka OlegDokuka force-pushed the feature/auth-metadata branch 2 times, most recently from 1979b63 to 8e6b560 Compare December 18, 2019 21:08
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
right now it supports encoding only

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka OlegDokuka force-pushed the feature/auth-metadata branch from 8e6b560 to df5bb22 Compare December 20, 2019 14:11
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
/**
* Encode a Authentication CompositeMetadata payload using custom authentication type
*
* @throws IllegalArgumentException if customAuthType is non US_ASCII string if customAuthType is
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

@yschimke yschimke Dec 29, 2019

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
Copy link
Member

@yschimke yschimke Dec 29, 2019

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?

Copy link
Member Author

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

ByteBufAllocator allocator, char[] username, char[] password) {

int usernameLength = CharByteBufUtil.utf8Bytes(username);
if (usernameLength > 256) {
Copy link
Member

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);
Copy link
Member

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 <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka OlegDokuka merged commit 7f76f0a into develop Jan 27, 2020
@OlegDokuka OlegDokuka deleted the feature/auth-metadata branch January 27, 2020 20:23
OlegDokuka added a commit that referenced this pull request Mar 2, 2020
* fixes tuples bytebufs

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* provides first draft implementation of AuthMetadataFlyweight

right now it supports encoding only

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* provides full implementation of AuthMetadataFlyweight

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* provides draft of AuthMetadata

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* fixes allowed username max length

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* removes eager release

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* fixes formating

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>

* provides minor fixes

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants