C
C#

Dynamically enable/disable a route in ASP.NET 7?

Dynamically enable/disable a route in ASP.NET 7?

VVortac11/20/2023
Is there a way to dynamically enable/disable a route in ASP.NET 7? I'd like to be able to enable/disable a registration endpoint of an API depending on whether or not an admin selects.
SSossenbinder11/20/2023
You can probably create a custom action filter and evaluate whatever condition in there And then handle it accordingly Besides that, probably something like configuring a route is not very dynamic, as well as disabling by attribute
Xx0rld11/20/2023
you can map the action filter to a feature flag system šŸ¤”
VVortac11/20/2023
I currently have JWT authentication setup, so once a user registers and then logs in they get a bearer token to make API calls to protected endpoints for example, users have to provide a token to POST to a certain endpoint but the issue is, they can still access the register endpoint to create an account, if I make that authorized only, then someone who wants to enable public signups can't
Xx0rld11/20/2023
what ? just don't show tu signup button if they are connected
VVortac11/20/2023
I want to be able to have a toggle for an admin to enable or disable new users signups, and if its disabled then I don't want anyone except admins being able to make a call to the registration endpoint
Xx0rld11/20/2023
create a system to do feature flag like a database table for example with a ServiceFilter attribute on top of your controller and in the filter check if the flag "createUser" is enabled or whatever and f it's not check if the user role https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0 there is example for servicefilter
PPixxelKick11/21/2023
I'd also separate this into 2 endpoints, since one is a registration and the other is create, which may prove useful to have as 2 separate flows (which can just call the same service for now) Then you can feature flag toggle just the register endpoint but leave the admin create endpoint always on and put role filter on it.
VVortac11/21/2023
What do you mean registration and create?
PPixxelKick11/21/2023
I'm not sure how else to word it I'd split your logic into 2 distinct api endpoints, 1 for admins to create users amd 1 for users to self register And just feature flag the latter

Looking for more? Join the community!

C
C#

Dynamically enable/disable a route in ASP.NET 7?

Join Server
Want results from more Discord servers?
Add your server
Recommended Posts
āœ… I keep getting Error CS5001 and CS0028, how do i get rid of themin CS5001 it says Program does not contain a static "Main" method suitable for an entry point and inStruct with explicit layoutHi, I am using Wintab and I am trying to make packet struct, but I have some problem. In some situatExtending custom WPF controlWhat are my options to extend this TimePicker list element to full height that shows all items? I'm Discord.Net + MagicOnion, hehehHey! So I am working on a discord bot that I want to intergrate into a server using websockets, I fA question for my c# winforms projecthello guys, i have a question about my c# winforms project. So : I have 2 Projects the first ProjecYO I NEED HELP writing a code need advice not for u to write it for mewrite me a c# program that get 3 latters and tell if they are by the order like abc if they are backBlazor ServicesI dont know too much blazor, but I have a .cs file in a /Settings folder, in which I would like to aHow to optimize this?I have following: ```cs using System; namespace SquareCalculus { internal class FigureTriangle In VSCode, SDK not Recognized on ChromeOSHi. I just installed the .NET SDK and the Runtime by following the instructions for Ubuntu on the MiNito.AsyncEx vs DotNext.ThreadingWe're currently searching for a nice AsyncAutoResetEvent implementation. We found two suitable impleSequential BlinkersHello everyone! I bought these sequential blinkers that run off an stm32 blue pill board. the only pTrying to use Microsoft.Kiota namespace but not found when importingI am trying to use this method from the Microsoft.Kiota.Abstractions.Extensions namespace: ToFirstChWinUI3 Scheduler CalendarViewhello im trying to make a winui3 calendarview interactive calendar where I can predefine dates in myThe call is ambiguous between the following methods or properties: 'Thread.Thread(ThreadStart)' andi have to upload by filesHelp a noobie out with a simple hangmanHi! New to coding and I need some help to solve this problem. Shall I save the words to a list? AnyC# Image Resizing on Visual Studio CodeI've tried both ``newPic.SizeMode = PictureBoxSizeMode.StretchImage;`` and ``newPic.SizeMode = PictuI'm stuck,visual studio 22, I need help making my invaders/enemies move left to right then downIā€™m trying to get my invaders/enemies to move left to right then down like in the game space invaderāœ… Where should I store all the sensitive file on .NET project?Hello everyone, May I know where should I store all the credential files that needs to be used by .Unity CodeI have been trying to get my C# code to work in unity for about a week and I am officially lost. I'vHelp! Reporting service in dotnet Core?please don't mind my english, it is not that good. i have created 2 projects one is server -dotnet