예제 #1
0
        public ClientTestableClaimsService(
            ClaimsServiceTestTenants testTenants,
            string serviceUrl,
            JsonSerializerSettings serializerSettings)
        {
            this.testTenants        = testTenants;
            this.serializerSettings = serializerSettings;

            // When testing the Functions Host locally (and also when doing in-process testing that
            // emulates functions hosting) we can simulate authentication by passing an
            // X-MS-CLIENT-PRINCIPAL header in the same form that Azure Functions would supply.
            // (To test against a deployed instance, we would need to provide a real token, because
            // Azure will block any requests that don't. Also, it won't pass through any
            // X-MS-CLIENT-PRINCIPAL header from the outside.)
            var claimsClient = new UnauthenticatedClaimsService(new Uri(serviceUrl));
            var appServiceClientPrincipal = new JObject(
                new JProperty(
                    "claims",
                    new JArray(
                        new JObject(
                            new JProperty("typ", "http://schemas.microsoft.com/identity/claims/objectidentifier"),
                            new JProperty("val", this.clientOid)))));

            claimsClient.HttpClient.DefaultRequestHeaders.Add(
                "X-MS-CLIENT-PRINCIPAL",
                Convert.ToBase64String(Encoding.UTF8.GetBytes(appServiceClientPrincipal.ToString(Formatting.None))));
            this.claimsServiceClient = claimsClient;
        }
예제 #2
0
 public DirectTestableClaimsService(
     ClaimsServiceTestTenants testTenants,
     ClaimPermissionsService claimsService,
     ResourceAccessRuleSetService ruleSetService)
 {
     this.testTenants    = testTenants;
     this.claimsService  = claimsService;
     this.ruleSetService = ruleSetService;
 }