-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
33 lines (26 loc) · 899 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Text;
using GraphQL_Test2;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddGraphQLServer()
.AddAuthorization()
.AddQueryType<Query>();
var signingKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("15129322381076306817"));
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = "http://localhost:4000/",
ValidAudience = "http://localhost:4000/",
ValidateIssuerSigningKey = true,
IssuerSigningKey = signingKey
};
});
var app = builder.Build();
app.UseAuthentication();
app.MapGet("/", () => "Hello Docker!");
app.MapGraphQL();
app.Run();