{"id":37036312,"url":"https://github.com/dark-loop/webjobs-authorize","last_synced_at":"2026-01-14T04:18:46.140Z","repository":{"id":53055504,"uuid":"177856118","full_name":"dark-loop/webjobs-authorize","owner":"dark-loop","description":"Bringing AuthorizeAttribute Behavior to Azure Functions","archived":false,"fork":false,"pushed_at":"2021-04-08T14:54:34.000Z","size":38,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T07:24:40.146Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dark-loop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-26T19:33:00.000Z","updated_at":"2022-03-02T13:57:10.000Z","dependencies_parsed_at":"2022-08-23T21:11:00.338Z","dependency_job_id":null,"html_url":"https://github.com/dark-loop/webjobs-authorize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dark-loop/webjobs-authorize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dark-loop%2Fwebjobs-authorize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dark-loop%2Fwebjobs-authorize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dark-loop%2Fwebjobs-authorize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dark-loop%2Fwebjobs-authorize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dark-loop","download_url":"https://codeload.github.com/dark-loop/webjobs-authorize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dark-loop%2Fwebjobs-authorize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T04:18:45.384Z","updated_at":"2026-01-14T04:18:46.127Z","avatar_url":"https://github.com/dark-loop.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webjobs-authorize\nBringing AuthorizeAttribute Behavior to Azure Functions v2. For v3 compatibility use [functions-authorize](https://github.com/dark-loop/functions-authorize).\n\nIt hooks into .NET Core dependency injection container to enable authentication and authorization in the same way  ASP.NET Core does.\n\n## License\nThis projects is open source and may be redistributed under the terms of the [Apache 2.0](http://opensource.org/licenses/Apache-2.0) license.\n\n## Using the package\n### Installing the package\n`dotnet add package DarkLoop.Azure.WebJobs.Authorize`\n\n### Setting up authentication\nThe goal is to utilize the same authentication framework provided for ASP.NET Core\n```c#\nusing Microsoft.Azure.WebJobs.Hosting;\nusing MyFunctionAppNamespace;\n\n[assembly: WebJobsStartup(typeof(Startup))]\nnamespace MyFunctionAppNamespace\n{\n  class Startup : IWebJobsStartup\n  {\n    public void Configure(IWebJobsBuilder builder)\n    {\n      builder\n        .AddAuthentication(options =\u003e\n        {\n          options.DefaultAuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;\n          options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;\n        })\n        .AddOpenIdConnect(options =\u003e\n        {\n          options.ClientId = \"\u003cmy-client-id\u003e\";\n          // ... more options here\n        })\n        .AddJwtBearer(options =\u003e\n        {\n          options.Audience = \"\u003cmy-audience\u003e\";\n          // ... more options here\n        });\n\n      builder\n        .AddAuthorization(options =\u003e\n        {\n          options.AddPolicy(\"OnlyAdmins\", policyBuilder =\u003e\n          {\n            // configure my policy requirements\n          });\n        });\n    }\n  }\n}\n```\n\nNo need to register the middleware the way we do for ASP.NET Core applications.\n\n### Using the attribute\nAnd now lets use `WebJobAuthorizeAttribute` the same way we use `AuthorizeAttribute` in our ASP.NET Core applications.\n```C#\npublic class Functions\n{\n  [WebJobAuthorize]\n  [FunctionName(\"get-record\")]\n  public async Task\u003cIActionResult\u003e GetRecord(\n    [HttpTrigger(AuthorizationLevel.Anonymous, \"get\")] HttpRequest req,\n    ILogger log)\n  {\n    var user = req.HttpContext.User;\n    var record = GetUserData(user.Identity.Name);\n    return new OkObjectResult(record);\n  }\n\n  [WebJobAuthorize(Policy = \"OnlyAdmins\")]\n  [FunctionName(\"get-all-records\")]\n  public async Task\u003cIActionResult\u003e(\n    [HttpTrigger(AuthorizationLevel.Anonymous, \"get\")] HttpRequest req,\n    ILogger log)\n  {\n    var records = GetAllData();\n    return new OkObjectResult(records);\n  }\n}\n```\n##\n\n### Releases\n[![Nuget](https://img.shields.io/nuget/v/DarkLoop.Azure.WebJobs.Authorize.svg)](https://www.nuget.org/packages/DarkLoop.Azure.WebJobs.Authorize)\n\n### Builds\n![master build status](https://dev.azure.com/darkloop/DarkLoop%20Core%20Library/_apis/build/status/Open%20Source/WebJobs%20Authorize%20-%20Pack?branchName=master)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdark-loop%2Fwebjobs-authorize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdark-loop%2Fwebjobs-authorize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdark-loop%2Fwebjobs-authorize/lists"}