Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
public class Person | |
{ | |
public string FirstName { get; } | |
public string LastName { get; } | |
} | |
[ExtendObjectType(typeof(Person))] | |
public class PersonExtension | |
{ |
public class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
IHost? host = CreateHostBuilder(args).Build(); | |
if (args.Contains("--generate-schema")) | |
{ | |
IRequestExecutor executor = await host.Services | |
.GetRequiredService<IRequestExecutorResolver>() | |
.GetRequestExecutorAsync(); |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Net; | |
using System.Text; | |
using System.Text.Json; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Newtonsoft.Json; |
{ | |
"before": ["<tab>"], | |
"commands": ["editor.action.indentLines"] | |
}, | |
{ | |
"before": ["<S-Tab>"], | |
"commands": ["editor.action.outdentLines"] | |
}, | |
{ | |
"before": [","], |
// Place your key bindings in this file to overwrite the defaults | |
[ | |
{ | |
"key": "shift+alt+q", | |
"command": "tslint.fixAllProblems" | |
}, | |
{ | |
"key": "shift+alt+u", | |
"command": "-extension.updateSettings" | |
}, |
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] | |
public abstract class DataLoaderAttribute : ObjectFieldDescriptorAttribute | |
{ | |
public static MethodInfo ConfigureMethod = typeof(DataLoaderAttribute) | |
.GetMethod(nameof(DataLoaderAttribute.Configure)); | |
public DataLoaderAttribute(Type dataloaderType) | |
{ | |
DataloaderType = dataloaderType; | |
} | |
public Type DataloaderType { get; } |
The problem with authentication of web sockets is that you can only authenticate a http request once against a authentication scheme. After that the authentication is cached and will always yield the same result.
A web socket connection starts over HTTP. A HTTP request with the Upgrade header is send to the back end. This request is then "upgraded" into a web socket that runs over the web socket pipeline. The main issue with web sockets is that you cannot set additional headers with this initial HTTP header. Therefore the authentication will fail and the request will be unauthenticated. The HTTP context of the initial request will last as long as the web socket connection is running.
The trick we do is that we add a stub authentication scheme:
services.AddAuthentication(options => | |
{ | |
options.DefaultScheme = "YOURSCHEMANAME"; | |
options.DefaultAuthenticateScheme = "YOURSCHEMANAME"; | |
}) | |
.AddJwtBearer("Websockets", ctx => { }) | |
.AddIdentityServerAuthentication("YOURSCHEMANAME", options => | |
{ | |
options.ForwardDefaultSelector = context => | |
{ |
namespace ApolloClient.Examples | |
{ | |
public class AuthenticationSocketInterceptor : ISocketConnectionInterceptor<HttpContext> | |
{ | |
// This is the key to the auth token in the HTTP Context | |
public static readonly string HTTP_CONTEXT_WEBSOCKET_AUTH_KEY = "websocket-auth-token"; | |
// This is the key that apollo uses in the connection init request | |
public static readonly string WEBOCKET_PAYLOAD_AUTH_KEY = "authToken"; | |
private readonly IAuthenticationSchemeProvider _schemes; |