-
Notifications
You must be signed in to change notification settings - Fork 164
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
Refactor IWebSocketAuthenticationService #1177
Comments
@gao-artur lmk if you have any comments about this proposal. For reference, see the current interface definition below. (I'm going to implement this for my own code now, but since it's a breaking change, won't be merging it in here until v9.) /// <summary>
/// Authenticates an incoming GraphQL over WebSockets request with the
/// connection initialization message. A typical implementation will
/// set the <see cref="HttpContext.User"/> property after reading the
/// authorization token. This service must be registered as a singleton
/// in the dependency injection framework.
/// </summary>
public interface IWebSocketAuthenticationService
{
/// <summary>
/// Authenticates an incoming GraphQL over WebSockets request with the connection initialization message. The implementation should
/// set the <paramref name="connection"/>.<see cref="IWebSocketConnection.HttpContext">HttpContext</see>.<see cref="HttpContext.User">User</see>
/// property after validating the provided credentials.
/// <br/><br/>
/// After calling this method to authenticate the request, the infrastructure will authorize the incoming request via the
/// <see cref="GraphQLHttpMiddlewareOptions.AuthorizationRequired"/>, <see cref="GraphQLHttpMiddlewareOptions.AuthorizedRoles"/> and
/// <see cref="GraphQLHttpMiddlewareOptions.AuthorizedPolicy"/> properties.
/// </summary>
Task AuthenticateAsync(IWebSocketConnection connection, string subProtocol, OperationMessage operationMessage);
} |
LGTM. You can use the default interface implementation feature to forward the new overload calls to the old one. I'm not a big fan of default interfaces because they are harder to discover, but they can be used during v8 and changed to the regular interface methods in v9. |
I would except they (default interface implementations) are not supported by .NET Framework so still a breaking change for what is officially a supported framework. (And people do use it for certain needs; I have a GraphQL.NET app built on it.) |
I will port this PR over for v9 at the appropriate time: Feel free to comment on it if you like. I don't think there's any rush, per se, but just on the v9 todo list. |
In short it will add another package for a standardized way of handling JWT bearer tokens in the gql init call, fully linking into ASP.Net Core's JWT bearer handling, including the way you can have it completely auto-configure itself by only setting the authority and audience. (It uses OIDC to pull the JWKs to verify tokens with.) I might consider adding a full sample of using MS authentication, except it needs a client ID and a bunch of setup instructions within the Azure Portal for a operable sample. |
We can of course review that additional package, and decide whether it is appropriate to release or not -- maybe we just update the sample instead. |
Suggest changing method
AuthenticateAsync
to have anAuthenticationRequest
class that includesAuthenticationSchemes
, as follows:This allows for the authentication handler to attempt each scheme specified by the middleware options.
The text was updated successfully, but these errors were encountered: