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
public class BasicAuthenticationFilterTests | |
{ | |
private Func<string, string, Task<IPrincipal>> _validator = (username, password) => | |
{ | |
var princ = username == password ? new ClaimsPrincipal(new GenericIdentity(username)) : null; | |
return Task.FromResult(princ as IPrincipal); | |
}; | |
[Fact] | |
public async Task Correctly_authenticated_request_has_a_valid_User() |
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
[Fact] | |
public async Task Fact() | |
{ | |
var res = await Tester.Run( | |
config => | |
{ | |
config.Filters.Add(new BasicAuthenticationFilter("myrealm", _validator)); | |
}, | |
() => | |
{ |
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
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.ServiceModel; |
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
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.ServiceModel; |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DownloadSslCert | |
{ |
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
[Fact] | |
public void First() | |
{ | |
var tokenHandler = new JWTSecurityTokenHandler(); | |
var symmetricKey = GetRandomBytes(256/8); | |
var now = DateTime.UtcNow; | |
var tokenDescriptor = new SecurityTokenDescriptor | |
{ | |
Subject = new ClaimsIdentity(new Claim[] |
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
(function(){ | |
var querystring = require('querystring'); | |
var url = require('url'); | |
var request = require('request'); | |
var http = require('http'); | |
var util = require('util'); | |
var child_process = require('child_process'); | |
var config = { |
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
private static string[] GetCanonicalizedHeaders(HttpRequestHeaders headers) | |
{ | |
return headers | |
.Where(p => p.Key.StartsWith("x-ms-", StringComparison.InvariantCultureIgnoreCase)) | |
.Select(p => new { Name = p.Key.ToLower(), Value = p.Value.First() }) | |
.OrderBy(p => p.Name) | |
.Select(p => string.Format("{0}:{1}", p.Name, p.Value)) | |
.ToArray(); | |
} |
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
[Fact] | |
public void Fact1() | |
{ | |
var namedAlice = new UserNameClaim("Alice"); | |
var teacher = new RoleClaim("Teacher"); | |
var student = new RoleClaim("Student"); | |
var alice = Claims.Identity(new UserNameClaim("Alice"), student); | |
var bob = Claims.Identity(new UserNameClaim("Bob"), teacher); | |
var anotherAlice = Claims.Identity(new UserNameClaim("Alice")); |
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
[ServiceContract] | |
internal class TheService | |
{ | |
[WebInvoke(UriTemplate = "*", Method = "*")] | |
public void TheOperation(Stream s) | |
{ | |
byte[] buf = new byte[4*1024]; | |
int blen; | |
int len = 0; | |
while ((blen = s.Read(buf, 0, buf.Length))>0) |