GithubHelp home page GithubHelp logo

piizei / azure-aad-username-password-to-token-function Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 12 KB

Hack that logs in with username and password and returns a JWT token.

License: MIT License

C# 100.00%

azure-aad-username-password-to-token-function's Introduction

azure-aad-username-password-to-token-function

Hack that logs in with username and password and returns a JWT token.

Notes:

It does not (yet) have a JWT authentication but its planned. Currently you would need to protect it with function-key.

It excepts few env variables:

  • TenantId: AAD tenant id of the AAD where the username-password is logged into.
  • ClientId: App Registration client-id in the AAD where the username-password is logged into. This AppReg needs to be configured to allow this type of login.
  • Scopes: Not mandatory as defaults to "User.Read".

The function excepts 2 query parameters

  • username
  • password and returns a JWT token for that user.

You can use it together with APIM using this policy (Logs in with the function and forwards JWT token as Bearer) Note: You would put the function url into Named Values of the gateway (as a secret, as it contains password...). Here the names value is called 'url'

<policies>
    <inbound>
        <send-request mode="new" response-variable-name="jwttoken" timeout="20" ignore-error="true">
            <set-url>{{url}}</set-url>
            <set-method>GET</set-method>
        </send-request>
        <set-header name="Authorization" exists-action="override">
            <value>@("Bearer "+((IResponse)context.Variables["jwttoken"]).Body.As<string>())</value>
        </set-header>
        <base />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

azure-aad-username-password-to-token-function's People

Contributors

piizei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.