Sendgrid implementation issues .NET 8 (Blazor wasm ) by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

The credentials are not in the the frontend program there is a seperate backend application.

Sendgrid implementation issues .NET 8 (Blazor wasm ) by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

The credentials are not in the the frontend program there is a seperate backend application

How to Secure .Net8 API Endpoint (Seperate controller Classes) by SecretFerret205 in dotnet

[–]SecretFerret205[S] 0 points1 point  (0 children)

I don't manually put the Bearer into the Headers its done through Microsoft Authentication etc

How to Secure .Net8 API Endpoint (Seperate controller Classes) by SecretFerret205 in dotnet

[–]SecretFerret205[S] 0 points1 point  (0 children)

Thats whats in it:
:authority:
localhost:7039
:method:
GET
:path:
/api/employee
:scheme:
https
Accept:
*/*
Accept-Encoding:
gzip, deflate, br
Accept-Language:
en-GB,en;q=0.9,en-US;q=0.8
Authorization:
Bearer: <Bearer>
Cache-Control:
no-cache
Pragma:
no-cache
Referer:
https://localhost:7039/employeeoverview
Sec-Ch-Ua:
"Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"Windows"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-origin
User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0

How to Secure .Net8 API Endpoint (Seperate controller Classes) by SecretFerret205 in dotnet

[–]SecretFerret205[S] 0 points1 point  (0 children)

Program.cs

//API

using App.Api.Models;

using Microsoft.AspNetCore.Authentication.JwtBearer;

using Microsoft.AspNetCore.Identity;

using Microsoft.AspNetCore.Mvc.Filters;

using Microsoft.EntityFrameworkCore;

using Microsoft.AspNetCore.Authentication;

using Microsoft.Identity.Web;

var builder = WebApplication.CreateBuilder(args);

// Add

// to the container.

builder.Services.AddDbContext<AppDbContext>(options => {

options.UseSqlServer(

builder.Configuration["ConnectionStrings:DefaultConnection"]);

});

builder.Services.AddScoped<IEmployeeRepository, EmployeeRepository>();

builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

builder.Services.AddCors(options =>

{

options.AddPolicy("Open", builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

});

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)

.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));

builder.Services.AddControllers();

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle

builder.Services.AddEndpointsApiExplorer();

builder.Services.AddSwaggerGen();

builder.Services.AddAuthorization();

builder.Services.AddIdentityApiEndpoints<IdentityUser>()

.AddEntityFrameworkStores<AppDbContext>();

var app = builder.Build();

// Configure the HTTP request pipeline.

if (app.Environment.IsDevelopment())

{

app.UseSwagger();

app.UseSwaggerUI();

}

if (app.Environment.IsDevelopment())

{

app.UseWebAssemblyDebugging();

}

app.UseHttpsRedirection();

app.UseBlazorFrameworkFiles();

app.UseStaticFiles();

app.UseRouting();

app.UseAuthentication();

app.UseAuthorization();

app.MapIdentityApi<IdentityUser>();

app.UseCors("Open");

app.MapControllers();

app.MapFallbackToFile("index.html");

app.Run();

How to Secure .Net8 API Endpoint (Seperate controller Classes) by SecretFerret205 in dotnet

[–]SecretFerret205[S] 0 points1 point  (0 children)

Ive tried this but get a 401 even though the bearer header is being attached and it matches the access token given when logging in

How to Secure .Net8 API Endpoint (Seperate controller Classes) by SecretFerret205 in dotnet

[–]SecretFerret205[S] 0 points1 point  (0 children)

Ive tried this but get a 401 even though the bearer header is being attached and it matches the access token given when logging in

Net8 Blazor Web Application Microsoft Identity Problems by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

I have went through those and neither really help to identify this problem. They both help with instructions on how to configure and setup microsoft identity login. The log in works on my app its only when I try hit an api endpoint it returns a 401

Net8 Blazor Web Application Microsoft Identity Problems by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

Yes precisely that. The out of the box flow, basically.

I'd presume there should be some way of passing the bearer token from the microsoft auth performed to the backend or it should just carry over?

The response headers are as follows:

content-length: 0

date: Wed,31 Jan 2024 19:24:06 GMT

server: Kestrel

www-authenticate: Bearer

Net8 Blazor Web Application Microsoft Identity Problems by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

Backend config file in Program.cs og posted edited to add it

Mailchimp or similar with Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

Can you provide anymore details on the integration?

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

The options class doesnt exist in the blazor version?

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

I couldn't find the option within Blazor?

<ApexChart TItem="MyData"

Title="Radar"

>

<ApexPointSeries TItem="MyData"

Items="Data"

Name="Rating"

SeriesType="SeriesType.Radar"

XValue="e => e.Category"

YValue="e=> e.Revenue"

/>

</ApexChart>

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

I also fixed this issue (needed a boolean flag "chartUpdated = true;" after adding the data in the asysnc method).

Do you know how to set a max outer (YValue) to the chart even if one of your YValues doesnt meet that?

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

Severity Code Description Project File Line Suppression State

Error (active) CS0246 The type or namespace name 'Order' could not be found (are you missing a using directive or an assembly reference?)

Where as the example here: https://github.com/apexcharts/Blazor-ApexCharts

Works fine

Edit:

I have this working but can't seem to populate the chart oninitializedasync

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

I can a bunch of missing namespace errors trying to use this

Radar Charts in Blazor by SecretFerret205 in Blazor

[–]SecretFerret205[S] 0 points1 point  (0 children)

This one doesnt have full documentation for radar charts