Arch Leaders
Restrict register endpoint using ASP.NET Core Identity
I'm using ASP.NET Core Identity as my authentication flow in a simple Web API. However, because the register/login/etc endpoints are automatically created, I can't restrict any of the endpoints like I usually would.
Is there a way to configure the default requirements (claims) for any one of the auto-generated endpoints?
For example, I don't want
/register
to be public, I would like it to require an Admin
claim. Is this possible?14 replies
Best way to uniquely hash an array of undefined length?
I need to recursively hash a tree of arrays/dicts, is there a preferred/best way to hash the values quickly?
Essentially I need to cache equality, the idea being to hash every array in the tree once and lookup the object pointer, otherwise I'd have to generate the hash many times when comparing the arrays.
If there's a better way to achieve that entirely, I'm open to that too.
7 replies
Load DLL at runtime with shared dependency
Hello,
I'm currently attempting to make an extension loader for my application, however I'm having issues loading the assembly at runtime because a dependency is already loaded in the running assembly.
This is my current setup:
-
ExtensionManager.Core
- this is a class library that contains the interfaces for the extension and service manager class.
- ExtensionManager
- this is a CLI project that loads the extension DLL and registers it to a common interface (from ExtensionManager.Core
).
- SampleExtension
- this is a class library the implements the extension interfaces in ExtensionManager.Core
and is loaded at runtime.
Inside the ExtensionManager
I attempt to load the SampleExtension.dll
and get the type that implements IServiceExtension
from ExtensionManager.Core
, however doing so throws the following exception:
Is there a way to tell the SampleExtension DLL to use the loaded ExtensionManager.Core
instead of loading a new one?
I'm fairly new to this sort of thing, so any help is appreciated.2 replies
❔ ✅ AES - Padding is invalid and cannot be removed
I am attempting to quickly encrypt a set of files using AES, but I'm getting the above error when decrypting.
I'm not sure if it's encryption or decryption that's wrong, but I've tried and googled everything I can think of, but nothing seems to works.
Can anyone tell me what's wrong with this code:
(also tried reading one-byte at a time, but with the same results)
28 replies
❔ Embed and Self-Extract C++ DLL in a CSharp Library
Hello,
I'm trying to embed a C++ DLL into my C# library to allow for single file publishing without distributing the C++ DLL along side the final application. (That is, any application using this library)
I also don't want to require an initialize function to extract the C++ DLL, which could be forgotten and is a bit annoying for users.
Is there a way either extract the DLLs when the parent application starts or else, a way to have them self-extract automatically at runtime?
2 replies
Use static functions in runtime code (rosyln)
Hello,
I'm trying to import a static class (
using static namespace.class
) into rosyln executing code (await CSharpScript.EvaluateAsync(code)
).
In this example, the function Query is a static function in the running assembly.
Currently I'm setting the default code options in the startup function:
But this doesn't seem to work. The function isn't recognized, and importing the namespace in the executing code fails in the same way (namespace/assembly not found).
Is there a way to import a static class into the memory-runtime?2 replies
byte[] does not equal a matching byte[], but the hex values match.
I have two byte arrays, one is 4 bytes long containing a known sequence, the other is file data. I am attempting to locate the 4-byte sequence in the file data by checking every four bytes in the file data, and using indexing to get the four bytes.
Here's the code:
Can anyone explain this behavior? And suggest how I can fix it?
Thanks
21 replies
Custom Class Serialization
Is it possible to use a custom JSON serializer on a class?
For example, I have a class with a few properties (Member), and another class with the class "Member" as a child property. I want the JSON serializer (Microsoft's version,
System.Texts.Json
) to serialize the entire Member class as just a string.
Anyone know how this is done/if it can be done?
Thanks.
5 replies