Skip to content

IRCV3BEARER SASL mechanism for bearer tokens #545

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

slingamn
Copy link
Contributor

This replaces #534, incorporating feedback received there:

  1. Defining a new mechanism IRCV3BEARER instead of reusing PLAIN
  2. IRCV3BEARER still overlaps with OAUTHBEARER, but it's more general, since it supports arbitrary bearer token types including JWTs

@slingamn slingamn changed the title initial draft of IRCV3BEARER IRCV3BEARER SASL mechanism for bearer tokens May 28, 2024
@KlaasT
Copy link

KlaasT commented Mar 7, 2025

Out of curiosity and because I have a project running, which could really benefit from this:

What would be needed to get this through?


IRC server implementations may wish to defer authentication to various external systems (e.g. single-sign-on systems). Some of these systems are capable of publishing bearer tokens, i.e., opaque tokens that carry authorization and authentication data, and which can be subsequently be validated by the same system or a cooperating system.

[SASL](sasl-3.1.html) is the standard authentication protocol used in IRC; it offers different mechanisms corresponding to different methods of authentication. Although some bearer tokens have associated SASL mechanisms (for example, OAuth2 has [RFC 7628](https://www.rfc-editor.org/rfc/rfc7628.html)), there is no general mechanism associated with the concept of bearer tokens. This specification defines a new mechanism `IRCV3BEARER` for processing bearer tokens in the context of IRCv3.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[SASL](sasl-3.1.html) is the standard authentication protocol used in IRC; it offers different mechanisms corresponding to different methods of authentication. Although some bearer tokens have associated SASL mechanisms (for example, OAuth2 has [RFC 7628](https://www.rfc-editor.org/rfc/rfc7628.html)), there is no general mechanism associated with the concept of bearer tokens. This specification defines a new mechanism `IRCV3BEARER` for processing bearer tokens in the context of IRCv3.
[SASL](sasl-3.1.html) is the standard authentication protocol used in IRC; it offers different mechanisms corresponding to different methods of authentication. Although some bearer tokens have associated SASL mechanisms (for example, OAuth2 has [RFC 7628](https://www.rfc-editor.org/rfc/rfc7628.html)), there is no general mechanism associated with the concept of bearer tokens. This specification defines a new mechanism `TOKENBEARER` for processing bearer tokens in the context of IRCv3.

Suggestion: SASL mechanisms are supposed to be protocol agnostic so a more generic name like this might be better?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be all for it. Either "TOKEN" or "BEARER". When considering HTTP it would be just "BEARER" under the Authorisation header. Maybe it would be an idea to align with something existing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert in the RFC process but I did some further reading today and I think RFC7628 might be doing on what was intended with JWT.

The RFC handles the authentication using bearer tokens which are being issued primarily by the OAUTH framework. JWT is one token format which is valid inside the OAUTH framework.

Given the examples and under further considerations it is pointed out that JWT is a SASL compatible container format for such a token and can be used for the authentication process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlaasT not sure if I understood you, but if you're suggesting that arbitrary tokens can be sent via the existing OAUTHBEARER mechanism defined by RFC 7628, I don't think that makes sense. And this specification effort is intended to support arbitrary tokens.

If you're saying that OAUTHBEARER is adequate for your intended use case, there is indeed prior art for integrating OAUTHBEARER into IRCv3: https://emersion.fr/blog/2022/irc-and-oauth2/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @slingamn

my intent is not to send arbitrary tokens through the OAUTHBEARER mechanics of RFC7628. My intent is to stay within the definition of the RFC. Maybe we just have a misunderstanding here :)

JWTs are a standardised format (RFC 7519) and commonly used as bearer tokens in OAuth 2.0 ecosystem.

From my understanding the OAUTHBEARER mechanism doesn’t impose strict constraints on the token’s internal structure beyond being a valid OAuth 2.0 token, which JWTs satisfy when issued by a trusted authority.

According to the RFC, OAUTHBEARER already supports JWTs as is, provided of course the server can validate them.

Furthermore a server is not forced to contact an OAUTH server for JWT validation as they are signed and self contained. The use of external resources for JWTs, even in the OAUTH process, is optional (correct me if I'm wrong), as they are able to hold all information needed for verification.

That blog post you linked is very interesting. Thanks for that one. I see it though trying to lean into the full OAUTH 2.0 handshake, while we could have it simpler, without the need to implement the entire stack.

Maybe I have missed something entirely and I am happy to discuss. But from what I see we could use this mechanism to accept JWTs as a RFC compliant token type, verify and validate them. Keeping it open for later implementations of further compatible mechanisms and protocols.

Just to add I found this over at Kafka which basically does the same thing, if I understood it right: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=75968876

So to close this wall of text (sorry for that), I don't want to invalidate your work on this extension. I think it is great and we do align in many things in that extension. Only thing I am concerned is that the mechanism we are searching for is in fact already present and called OAUTHBEARER.

Introducing a new mechanism and going through IANA, as proposed earlier, would probably take a long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlaasT I think maybe we should talk out of band, would you like to email me?


A bearer token type is a case-sensitive identifier conforming to the [message tags](message-tags.html) grammar for `<key_name>` tokens. This specification defines two bearer token types, `oauth2` and `jwt`. Additional bearer token types may be defined; they SHOULD either use a vendor prefix, or be registered with IRCv3.

A bearer token is an opaque string of bytes. Bearer tokens MUST NOT contain the NUL byte.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon further consideration this restriction doesn't seem very useful. Thoughts on either (a) allowing NUL (b) requiring non-NUL UTF8 (c) requiring printable ASCII (0x20 through 0x7e inclusive), as OAuth does?

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.

5 participants