-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Maciejowski2006/auth
Created authorization
- Loading branch information
Showing
6 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,27 @@ | ||
using System.Net; | ||
using SAPI.Endpoints; | ||
using SAPI.Utilities; | ||
|
||
namespace Testing.Endpoints; | ||
|
||
public class ApiAuth : IEndpoint | ||
{ | ||
|
||
public string url { get; } = "auth"; | ||
public Method method { get; } = Method.GET; | ||
public void Task(ref HttpListenerRequest request, ref HttpListenerResponse response, Dictionary<string, string> parameters) | ||
{ | ||
List<BasicAuthCredentials> credentials = new () | ||
{ | ||
new BasicAuthCredentials("dub", "iel"), | ||
new BasicAuthCredentials("user", "pass"), | ||
new BasicAuthCredentials("user", "inny"), | ||
|
||
}; | ||
bool keyAuth = Utilities.CheckForKeyAuthorization(new List<string>() {"api", "bruh", "duh"}, "x-api-key", ref request); | ||
bool userPassAuth = Utilities.CheckForUserPassAuthorization(credentials, ref request); | ||
|
||
Console.WriteLine($"Key Auth: {keyAuth}"); | ||
Console.WriteLine($"User+Password Auth: {userPassAuth}"); | ||
} | ||
} |
This file contains 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