StilauGamer
StilauGamer
Explore posts from servers
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
Yeah, its just that you use the same db context over the whole user request.. In Blazor, 1 scoped service last from when he starts viewing till he closes / refreshes, etc.. So in theory, when using a db context, you have it alive for the whole time, if its not disposed at some point tho ofc.. But then I don't need to do it in my web apis :sunglas: Another mystery solved for today! 🫡
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
From my understanding, the DB Context Factory is more widely used within Blazor applications where the scope is more wide... The scope is per user request and not just a HTTP request like in a Web API.. So its more recommended to manually create the db context, etc in Blazor. But in a Web API, you are good enough with just injecting the DB Context directly as its scoped to that request only.. Thats from what I understood. Reference to the article
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
I don't remember exactly where, but I read that you should use the factory part of EF, or smth
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
I was using this implementation: builder.Services.AddPooledDbContextFactory<ApplicationDbContext>(optionsBuilder => { });
15 replies
CC#
Created by StilauGamer on 11/13/2024 in #help
Inject IDbContextFactory or DbContext directly?
So I should just inject the DB Context directly, and not use the IDbContextFactory part 🤓 I was confused myself, but I found it somewhere and it told me that I should use that for pooling, etc
15 replies
NNuxt
Created by StilauGamer on 5/14/2024 in #❓・help
Cookie not set when returning from OAuth callback
🤔
2 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
I find server sided a lot more secure and I feel more secure as a user when its not stored on my pc... Thats why I thought about my way of doing it. It gives the user more flexibility on what devices and what IPs might access their account.. Aswell as you can show a last active time on the cookie to show that some people might've been on it recently.. I find that this way is a little more secure and gives you both encryption on client side with storing it all in a JWT token and on the server side its all encrypted so I can't as a host go and look at it in plain text
15 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
So you think this would work pretty decently? Your smarter than me in this area, so just seeking some advice 😂 I personally find this most interesting if you encrypt all of it well on the server side
15 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
This would somewhat protect u against cookie theft, aswell as XSS attacks, it would also have more functionality when it comes to storing the access token, etc on server lets me have more functionality at my hands. And revoking would also work as it would be done through the unique cookies? But then I would remove both the advantages getting from only having it client sided 🤔
15 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
Okay.. So there are a few issues that might happen.. So how about this. On the server side I would store: - A unique ID for the user, discord id. - Refresh Token - Time of expiry - Access Token - Other data I want Inside another DB table. - Discord ID of user - A unique cookie - The IP that the cookie was authenticated on And on the client I would have a JWT that would have: - Discord ID - The cookie ( This is used to make sure that your cookie can be authenticated with. ) So what it does when you log in is that it cross checks the cookie and discord id to make sure its acceptable. This way its both encrypted in a JWT with a secret key, aswell as each cookie is IP whitelisted and I can setup a system of every cookie that has been authenticated on different ips. And then remember to active HttpOnly and HTTPS How would this be?
15 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
Yeah, I will read through and think about it deeply... What I've currently done is: - You log in with discord. - You get redirected back to the website and it gets the OAuth code. - It grabs the access_token, refresh_token, etc from discord. - Stores it in a JWT - Saves the JWT to a cookie - Gets the cookie and verifyes the JWT when accessing pages, etc through middleware. This way I don't store any of the data on the server, and its all locally.. And then I would say store the discord id in a database for a more thorough perm checking... Is this a bad way of doing it? Only worry I am having is with cookie stealing, etc? If someone steals the JWT and tries using it? Then that would work right?
15 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
I am not using any, fully custom 😅
15 replies
CC#
Created by StilauGamer on 1/21/2024 in #help
Is Inside a polygon algorithm..
I believe it has something to do with how I am sorting the vertices based on the centroid.
3 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So I should make [LoggerMessage] for each logging I do?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
ahhh, went training so didn't see the last messsages. Basically waht it does is that the source generator detects this [LoggerMessage(.........)] and then creates the code inside the method automatically. Right?
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So basically like this: Log.BotStarted(_logger, _client.CurrentUser.Username);
public partial class Log
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "{Username} has been started!")]
public static partial void BotStarted(ILogger logger, string username);
}
public partial class Log
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "{Username} has been started!")]
public static partial void BotStarted(ILogger logger, string username);
}
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
🥹
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
So instead of doing _logger.LogInformation("{Username} has hit an error", _client.CurrentUser.UserName), I should do this.
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
CustomEventName 🤔
137 replies
CC#
Created by StilauGamer on 11/20/2023 in #help
Discord.Net + MagicOnion, heheh
Ahh, and this is the most official and recommended way of doing logging ig?
137 replies