The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dancer2::Plugin::Auth::OAuth::Provider::AzureAD - Provider for Microsoft/AzureAD

SYNOPSIS

View the documentation for Dancer2::Plugin::Auth::OAuth

Default values; change these in your YML config if needed:

plugins:
  "Auth::OAuth":
    providers:
      AzureAD:
        urls:
          authorize_url: "https://login.microsoftonline.com/common/oauth2/authorize"
          access_token_url: "https://login.microsoftonline.com/common/oauth2/token"
          user_info: "https://graph.microsoft.com/v1.0/me/"
        tokens:
          client_id: your_client_id
          client_secret: your_client_secret
        query_params:
          authorize:
            scope: 'User.Read',
            resource: 'https://graph.microsoft.com/',

DESCRIPTION

Generic provider for Microsoft OAuth2.

Note that you will undoubtably need to change some or all of the options above.

After login, the following session key will have contents: {oauth}{azuread}

The token will probably be in {id_token}

When log in has occured, the provider attempts to decode the resulting token for information about the user. All of the decoded information can be found in the session key: {oauth}{azuread}{login_info}

The login email address, for example, will probably be in a key called {unique_name}

If the user_info option is defined (which it is by default!), a corresponding call is made to that URL to find out more information about the user. This is stashed in the session key {oauth}{azuread}{user_info}

ADDING TENANT ID

If you need to add a tenant ID to your calls, this should be done by replacing "common" in the authorize_url and access_token_url.

PREVENTING USER LOOKUP WITH GRAPH

By default this provider requests scope and resource to perform a request on Microsoft's Graph API to return the logged in user details. This is not strictly necessary, as part of the token returned on authentication is the email address used to log in.

To prevent this lookup, set "user_info" to a blank string.

AUTHOR

Pero Moretti <pero@cpan.org>

COPYRIGHT

Copyright 2022- Pero Moretti

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.