-
Notifications
You must be signed in to change notification settings - Fork 10
Cs/http api #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Cs/http api #671
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
3e64fa0
WIP: Improve authenticator
GermanCoding 80a5196
check expiration in seconds
doxthree 9219d1e
1 test
pstadermann abc2a7c
Parse IDP error messages, add test
GermanCoding 078a836
El testo
pstadermann c8a870b
Add authenticator throttling; Add even more tests
GermanCoding e9a29c5
New api
pstadermann c0668bf
WIP: ForSha256
GermanCoding b988631
Remove websocket
pstadermann 909c804
Option defaults
pstadermann f74169f
Reorder methods like interface
pstadermann 721266b
WIP
pstadermann 34cd535
Remaining tests for For*
pstadermann 8c2167d
add forurl method
doxthree 93ad48a
add mssing urlreport
doxthree f0144b6
ForStream
pstadermann 8b7ac91
add forfile test
doxthree 10a9a27
check options
doxthree 686355d
ForFile: Check if ForSha256 returns Detection, FileType, MimeType
pstadermann 9d0e666
add options in url
doxthree 10cd163
CSharpier this!
pstadermann ba3c2c3
Rider CSharpier
pstadermann c9d4aa9
ForSha256Async_SendsOptions
pstadermann fb49257
fun with mocked httpclient
doxthree b140bdc
http mocking
ata-no-one eb13c54
WIP add more tests and error parsing for non success status codes
lennartdohmann 724ffaa
Fix parsing of Vaas errors with problem details
lennartdohmann de3cd4b
some broken test
ata-no-one fcd7ab0
WIP tests
lennartdohmann d22ffbc
add new test cases for user agent and request id
doxthree 525caca
fix client exception test
ata-no-one c6b1c38
Completed forfile tests
doxthree 8c2c44b
Finished test for forstream & forurl + bugfixes
doxthree 34bc4ca
exclude dotnet dirs
doxthree c8b75d1
fix test error
ata-no-one 1157d0e
remove handler mock
ata-no-one 7207fac
cleanup and remove unsused websocket stuff
doxthree 014267c
use https aas vaas endpoint
doxthree 1a3e1e3
Refactor:
lennartdohmann d81712d
diable examples because it expects the websocket uri
doxthree 2bcdefc
Making TokenReceiver.cs class abstract, and just implement TokenReque…
lennartdohmann 8b44766
Merge pull request #684 from GDATASoftwareAG/cs/http_api_refactor
lennartdohmann 65f6b09
Merge branch 'main' into cs/http_api
doxthree f583363
Update authenticators
lennartdohmann ce0d478
Always create a new request in while loop because 'Cannot send the sa…
lennartdohmann beb7f68
Add unit test for ForFileAsync method to verify timeout behavior
lennartdohmann 77cb82a
Fix tests
lennartdohmann 9ef333d
Refactor timeout handling to use TimeSpan instead of int for improved…
lennartdohmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ lib/ | |
|
|
||
| bin/ | ||
| obj/ | ||
| .idea/ | ||
| .mono/ | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
dotnet/Vaas/src/Vaas/Authentication/ClientCredentialsGrantAuthenticator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net.Http; | ||
|
|
||
| namespace Vaas.Authentication; | ||
|
|
||
| public class ClientCredentialsGrantAuthenticator( | ||
| string clientId, | ||
| string clientSecret, | ||
| Uri? tokenEndpoint = null, | ||
lennartdohmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| HttpClient? httpClient = null, | ||
lennartdohmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ISystemClock? systemClock = null | ||
lennartdohmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) : TokenReceiver(tokenEndpoint, httpClient, systemClock), IAuthenticator | ||
| { | ||
| private string ClientId { get; } = clientId; | ||
| private string ClientSecret { get; } = clientSecret; | ||
|
|
||
| protected override FormUrlEncodedContent TokenRequestToForm() | ||
| { | ||
| return new FormUrlEncodedContent( | ||
| new List<KeyValuePair<string, string>> | ||
| { | ||
| new("client_id", ClientId), | ||
| new("client_secret", ClientSecret ?? throw new InvalidOperationException()), | ||
| new("grant_type", "client_credentials"), | ||
| } | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Vaas.Authentication; | ||
|
|
||
| public class ErrorResponse | ||
| { | ||
| [JsonPropertyName("error")] | ||
| public required string Error { get; init; } | ||
|
|
||
| [JsonPropertyName("error_description")] | ||
| public string? ErrorDescription { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace Vaas.Authentication; | ||
|
|
||
| public enum GrantType | ||
| { | ||
| ClientCredentials, | ||
| Password, | ||
| } |
32 changes: 32 additions & 0 deletions
32
dotnet/Vaas/src/Vaas/Authentication/ResourceOwnerPasswordGrantAuthenticator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net.Http; | ||
|
|
||
| namespace Vaas.Authentication; | ||
|
|
||
| public class ResourceOwnerPasswordGrantAuthenticator( | ||
| string clientId, | ||
| string userName, | ||
| string password, | ||
| Uri? tokenEndpoint = null, | ||
lennartdohmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| HttpClient? httpClient = null, | ||
| ISystemClock? systemClock = null | ||
| ) : TokenReceiver(tokenEndpoint, httpClient, systemClock), IAuthenticator | ||
| { | ||
| private string ClientId { get; } = clientId; | ||
| private string UserName { get; } = userName; | ||
| private string Password { get; } = password; | ||
|
|
||
| protected override FormUrlEncodedContent TokenRequestToForm() | ||
| { | ||
| return new FormUrlEncodedContent( | ||
| new List<KeyValuePair<string, string>> | ||
| { | ||
| new("client_id", ClientId), | ||
| new("username", UserName ?? throw new InvalidOperationException()), | ||
| new("password", Password ?? throw new InvalidOperationException()), | ||
| new("grant_type", "password"), | ||
| } | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.