All Projects → idandaccess → azure-functions-auth

idandaccess / azure-functions-auth

Licence: MIT License
Authentication and Authorization for Azure Functions (with OAuth 2.0 and JWT)

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to azure-functions-auth

secure-oauth2-oidc-workshop
Hands-On Workshop for OAuth 2.0 and OpenID Connect 1.0
Stars: ✭ 58 (+190%)
Mutual labels:  oauth2, authorization
Sample Spring Oauth2 Microservices
some examples that show basic and more advanced implementations of oauth2 authorization mechanism in spring-cloud microservices environment
Stars: ✭ 109 (+445%)
Mutual labels:  oauth2, authorization
Cas
Apereo CAS - Enterprise Single Sign On for all earthlings and beyond.
Stars: ✭ 9,154 (+45670%)
Mutual labels:  oauth2, authorization
Auth0.js
Auth0 headless browser sdk
Stars: ✭ 755 (+3675%)
Mutual labels:  oauth2, authorization
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+11515%)
Mutual labels:  oauth2, authorization
Sso
cas单点登录系统,其中包括cas认证服务,配置中心,监控平台,服务管理的高可用项目
Stars: ✭ 797 (+3885%)
Mutual labels:  oauth2, authorization
Ueberauth
An Elixir Authentication System for Plug-based Web Applications
Stars: ✭ 1,259 (+6195%)
Mutual labels:  oauth2, authorization
Product Is
Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
Stars: ✭ 435 (+2075%)
Mutual labels:  oauth2, authorization
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+59320%)
Mutual labels:  oauth2, authorization
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+8590%)
Mutual labels:  oauth2, authorization
Aspnet5identityserverangularimplicitflow
OpenID Connect Code / Implicit Flow with Angular and ASP.NET Core 5 IdentityServer4
Stars: ✭ 670 (+3250%)
Mutual labels:  oauth2, authorization
rabbitmq-auth-backend-oauth2-spike
See rabbitmq/rabbitmq-auth-backend-oauth2 instead.
Stars: ✭ 17 (-15%)
Mutual labels:  oauth2, authorization
Doorkeeper
Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.
Stars: ✭ 4,917 (+24485%)
Mutual labels:  oauth2, authorization
Jso
Easy to use OAuth 2.0 javascript library for use in your javascript application.
Stars: ✭ 830 (+4050%)
Mutual labels:  oauth2, authorization
Cloudfront Auth
An AWS CloudFront [email protected] function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
Stars: ✭ 471 (+2255%)
Mutual labels:  oauth2, authorization
Spring Boot Oauth2 Jwt Swagger Ui
Spring Boot , OAuth 2 , JWT (Json Web Token) and Swagger UI
Stars: ✭ 77 (+285%)
Mutual labels:  oauth2, authorization
Grant
OAuth Proxy
Stars: ✭ 3,509 (+17445%)
Mutual labels:  oauth2, authorization
Gin Oauth2
Middleware for Gin Framework users who also want to use OAuth2
Stars: ✭ 351 (+1655%)
Mutual labels:  oauth2, authorization
Yup Oauth2
An oauth2 client implementation providing the Device, Installed and Service Account flows.
Stars: ✭ 122 (+510%)
Mutual labels:  oauth2, authorization
logto
🧑‍🚀 Logto helps you build the sign-in, auth, and user identity within minutes. We provide an OIDC-based identity service and the end-user experience with username, phone number, email, and social sign-in, with extendable multi-language support.
Stars: ✭ 3,421 (+17005%)
Mutual labels:  oauth2, authorization

Build Status

azure-functions-auth

Authentication and Authorization for Azure Functions (with OAuth 2.0 and JWT)

Configuration

const validateJwt = require('azure-functions-auth')({
  clientId: '<client id>',
  clientSecret: '<client secret or IDP\'s public key / signing certificate>',
  domain: '<your IDP>',
  algorithms: ['RS256'],
});

Usage

Callback Style

module.exports = validateJwt(function(context, req) {
  if (req.user) {
    context.res = {
      body: req.user
    };
  }
  else {
    context.res = {
      status: 400,
      body: "The user property is missing"
    };
  }
  context.done();
});

In case of an invalid JWT context.res gets populated accordingly and context.done() gets called.

Async Style

const main = (context, req) => {
  context.log('token is valid. (you shouldn\'t log like that in production code)')
  
  return new Promise(resolve => {
    resolve('the function will return this exact string as body with a status code of 200')
  }).then(asyncResult =>{
    return asyncResult
  })
}
module.exports = validateJwt(main, true)

In case of an invalid JWT a specific error and status code get returned. Make sure to have your function host is configured to use function's return value.

{
  "bindings": [
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}

Regarding the http output your function.json should look like the above.

module.exports = {
  run: validateJwt(main, true),
  main
}

In order to do tests, of course you still can export your functions.

Calling your function

Now when you make a call to the Http endpoint you'll need to add an Authorization header, e.g.:

GET https://functionsad5bb49d.azurewebsites.net/api/my-http-function?...
Authorization: Bearer the-access-token

Attribution

This code is based on https://github.com/sandrinodimattia/azure-functions-auth0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].