Commit Graph

211 Commits

Author SHA1 Message Date
Sebastian Göls
fb4eb0b03a Use Madness via global usings (#2447)
* Use Madness via global usings

* Apply feedback

* Disable false positive null warning
2021-11-09 16:33:09 +01:00
Łukasz Domeradzki
0eee21360d .NET 6.0 (#2388)
* Bump non-source files to net6.0

* Correct .NET 6.0 warnings

* Correct CI

* Correct linking errors

Not much I can do about them ATM

* Remove TrimmerRoots

At least runtime is no longer needed for our STD plugin, not sure about the dictionary

* Correct cc.sh

* Revert "Remove TrimmerRoots"

This reverts commit 11f603d3d6.

* First round of cat & mice game

* Update Directory.Build.props

* Update Startup.cs

* Update Startup.cs

* Update Startup.cs

* Fix new warnings

* Update SDK

* Address netf error

* Update Directory.Packages.props
2021-11-08 23:41:02 +01:00
Archi
b516980ad7 Misc 2021-11-02 21:17:25 +01:00
Archi
e59b45e63c Bump 2021-11-02 21:10:46 +01:00
Archi
cc59875769 Fix crash on machines that do not support qps-Ploc culture
E.g. mono
2021-11-02 21:02:32 +01:00
Archi
28d0068fdb Misc 2021-10-27 13:31:48 +02:00
Sebastian Göls
785b43781a Support lol-US locale for IPC requests (#2435)
* Support lol-US locale for IPC requests

* Support sr-CS as well

* Apply feedback

* Apply feedback and Rider cleanup

* Less allocations make everyone happy

* Apply feedback

* Explain why we're doing this stupidity

* Uppercase Windows/Linux compat fix

* Go back to earlier version
2021-10-27 13:15:56 +02:00
Sebastian Göls
d894f3a830 Localize IPC (#2431)
* Localize IPC

* Keep logs in one language

* Cleanup

* Revert changes that keep strings in one locale

* Order dependencies alphabetically

* Fix formatting (Thanks, Rider -.-)
2021-10-25 20:24:56 +02:00
Archi
2db957aec4 Misc 2021-10-15 01:11:02 +02:00
Archi
df817f4ffc Cleanup and improvements after #2426 2021-10-14 23:55:35 +02:00
Sebastian Göls
f93143c133 Add ASF 2FA service endpoints (#2426)
* Add ASF 2FA service endpoints

* Misc.

* Move back to .../TwoFactorAuthentication

* Remove duplicate endpoints

* Remove now useless constructor

* Apply feedback
2021-10-14 23:41:12 +02:00
Archi
7e9e90764b Use static lambdas wherever possible
Thanks Rider
2021-09-27 21:33:52 +02:00
Archi
f2d3a2a894 Use string interpolation wherever possible
Majority of cases still need to go through string.Format() due to localization requirements
2021-09-27 19:59:00 +02:00
Archi
e90100a847 Misc 2021-09-13 15:36:41 +02:00
Archi
69e2a3590c ApiAuthenticationMiddleware performance improvements
Previously we've used one semaphore per all ongoing authentication attempts, which is suboptimal given the existence of a lot of consumers, including ongoing (D)DoS or distributed bruteforce attack. ASF should be as resistant to that as possible, therefore it makes sense to replace the global semaphore with per-IP semaphore (actually task), that can control the access just as well, without stopping other consumers from accessing the same authentication process concurrently.
2021-08-24 01:37:14 +02:00
Archi
5f5dcfbb99 Misc 2021-08-23 16:50:26 +02:00
Archi
882443711b Optimize ApiAuthenticationMiddleware for bruteforcing
We can favour bruteforcers by checking first if the client is even eligible for talking with us, this will (in a very negligible way) improve defense against common DoS.

Also rewrite Timer initialization while at it. This is internal class and we don't expect this middleware to be initialized more than once anyway.
2021-08-23 16:49:19 +02:00
Łukasz Domeradzki
9f281c6055 Embrace madness (#2394)
* Embrace madness

* Remove unused code

* Misc

* Address Abry's note

* Update for Madness 0.3.0
2021-08-07 14:03:46 +02:00
Archi
2be8a8b2a8 Avoid a potential synchronous flush when serializing api authentication middleware response
Might result in something along:

2021-07-30 16:39:43|ArchiSteamFarm-6766|ERROR|Microsoft.AspNetCore.Server.Kestrel|Connection id "0HMAJF2E5IVHB", Request id "0HMAJF2E5IVHB:00000005": An unhandled exception was thrown by the application. System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Flush()
   at Microsoft.AspNetCore.ResponseCaching.ResponseCachingStream.Flush()
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionBody.Flush()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Dispose(Boolean disposing)
   at System.IO.StreamWriter.Close()
   at Newtonsoft.Json.JsonTextWriter.CloseBufferAndWriter()
   at Newtonsoft.Json.JsonTextWriter.Close()
   at Newtonsoft.Json.JsonWriter.Dispose(Boolean disposing)
   at Newtonsoft.Json.JsonWriter.System.IDisposable.Dispose()
   at ArchiSteamFarm.IPC.WebUtilities.WriteJsonAsync[TValue](HttpResponse response, TValue value, JsonSerializerSettings jsonSerializerSettings)
   at ArchiSteamFarm.IPC.WebUtilities.WriteJsonAsync[TValue](HttpResponse response, TValue value, JsonSerializerSettings jsonSerializerSettings)
   at ArchiSteamFarm.IPC.Integration.ApiAuthenticationMiddleware.InvokeAsync(HttpContext context, IOptions`1 jsonOptions)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
2021-07-30 20:54:52 +02:00
Sebastian Göls
4b7edf388c Fix GlobalConfig update via IPC removing IPCPassword (#2379) 2021-07-23 16:54:20 +02:00
Archi
859d2d54c6 Misc 2021-07-21 09:58:09 +02:00
Archi
a92c212a69 Misc 2021-07-20 14:43:16 +02:00
Archi
1b3ef7a41d Add support for supplying additional information on 401/403 status codes
In particular permanent: true/false value indicating whether 403 comes from rate limiting or ASF block due to lack of IPCPassword
2021-07-20 14:32:53 +02:00
Archi
d479eb9f97 Address Rider EAP inspections/cleanup 2021-07-12 21:45:17 +02:00
Łukasz Domeradzki
13e9f1ac2a Closes #2371 (#2372)
* Closes #2371

* Change the default to no known networks

* Address @Vital7 note

* Handle both IPv4 and IPv6 when mapped

This follows ASP.NET Core logic

* Refactor forwarded headers usage
2021-07-12 13:40:23 +02:00
Archi
28242aa6e8 IPC: Implement ResponseCaching
This actually does two things: client caching and server caching

Client caching considers only static files, for which we instruct the web browser to revalidate each cache usage with our server to ensure that it's up-to-date.

Server caching with those settings actually doesn't work (nothing to do), but may in the future as lack of no-store means that server is technically allowed to cache I/O read files for as long as it can guarantee they didn't change on the disk.
2021-07-04 21:36:54 +02:00
Archi
f58a9be02a IPC: Add optional SRI support for ASF-ui
In theory, this is required only in specific proxy/CDN solutions accessing ASF data over http that would somehow want to transform the responses

https://github.com/JustArchiNET/ASF-ui/pull/1470
2021-07-04 18:51:35 +02:00
Archi
1d317dcb76 Misc 2021-07-01 10:30:12 +02:00
Archi
da7adbe415 Make custom swagger attributes also work with parameter info
If somebody ever uses it as such, that is
2021-06-30 23:04:36 +02:00
Archi
19bd497362 Extract custom attributes to CustomSwaggerAttribute
This also allows plugins to inherit from it and add custom attributes while utilizing the same ASF mechanism for extending the schema
2021-06-30 22:53:01 +02:00
Archi
aebf432fce Misc 2021-06-30 22:24:28 +02:00
Archi
0060e76829 Make custom swagger limitations more generic to use 2021-06-30 22:23:01 +02:00
Archi
162ecf93ac Misc 2021-06-30 20:41:55 +02:00
Archi
874eb4d3a6 Add helpful limitations on properties for https://github.com/JustArchiNET/ASF-ui/issues/1445
Monologue explaining how it works: https://ptb.discord.com/channels/267292556709068800/332735075315744768/859854787634004049

(eventually also on wiki)
2021-06-30 20:39:38 +02:00
Archi
74d3efaf4b Misc 2021-06-26 14:43:20 +02:00
Archi
f3d6f92404 Correct /Api/NLog reaction to close message
https://mcguirev10.com/2019/08/17/how-to-close-websocket-correctly.html
2021-06-25 19:49:37 +02:00
Archi
d5a10ca7eb Misc 2021-06-25 14:43:46 +02:00
Vitaliya
f316bf7b49 Add controllers as services (#2343) 2021-06-23 12:21:01 +02:00
Archi
38dc1730ab Misc 2021-06-20 13:44:04 +02:00
Archi
398c93e9b7 Closes #2337 2021-06-18 20:56:32 +02:00
Archi
4bec13b175 Use default Api route for controllers that do not declare one
We don't have any like that, but third-party plugins might
2021-05-22 21:25:20 +02:00
Archi
fe43aa6cb6 Convert UTF-8 BOM to files to UTF-8 2021-05-22 19:45:27 +02:00
JustArchi
55cd466a1e Use simplified logic also for global config 2021-05-08 22:21:50 +02:00
JustArchi
64b9aa409e Correct migration logic 2021-05-08 22:19:27 +02:00
JustArchi
d21d2473fe RuntimeCompatibility -> Compatibility 2021-05-08 01:43:08 +02:00
JustArchi
e60b54e402 Refactor EVERYTHING
Directories structure + namespaces relevant to them
2021-05-08 01:37:22 +02:00
JustArchi
cbabde1b38 Reorganize Web directory 2021-05-08 01:03:08 +02:00
JustArchi
daf37c723c Document all the pragmas, final code corrections 2021-05-07 23:56:45 +02:00
JustArchi
90ff43dc98 Resolve CA1508 2021-05-07 16:49:02 +02:00
JustArchi
04ff460d69 Resolve CA1307 2021-05-07 15:59:06 +02:00