Answers for "azure function aad"

C#
0

azure function aad

using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Security.Claims;
using System.Linq;

namespace Auth1
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
            ClaimsPrincipal principal,
            ILogger log)
        {
            return new OkObjectResult(new
            {
                Name = principal.Identity.Name,
                IsAuthenticated = principal.Identity.IsAuthenticated,
                Claims = principal.Claims.Select(x => new { Type = x.Type, Value = x.Value }).ToArray(),
            });
        }
    }
}
Posted by: Guest on March-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language