# Discourse Azure AD Plugin not working

**URL:** https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249
**Category:** Support
**Created:** [28.Июнь.2017 06:05:32 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249 "2017-06-28T06:05:32Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Chanka\_Dod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chanka_dod/32/69649_2.png) [@Chanka\_Dod](https://meta.discourse.org/u/Chanka_Dod)
#### Post date: [28.Июнь.2017 06:05:32 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/1 "2017-06-28T06:05:32Z")

</div>

I couldn’t make the Azure AD plugin configured.  
[https://github.com/discourse/discourse-azure-ad](https://github.com/discourse/discourse-azure-ad)  
After adding to app.yml, rebuilding doesn’t work.

Is the plugin obsolete?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [28.Июнь.2017 07:06:46 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/2 "2017-06-28T07:06:46Z")

</div>

> [@Chanka\_Dod](#):
>
> Is the plugin obsolete?

Why would you leap straight to the plugin being obsolete?

> [@Chanka\_Dod](#):
>
> After adding to app.yml, rebuilding doesn’t work.

Define “doesn’t work”. The full console output from the rebuild run would be preferred.

---

<div class="post-metadata">

### Author: ![Chanka\_Dod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chanka_dod/32/69649_2.png) [@Chanka\_Dod](https://meta.discourse.org/u/Chanka_Dod)
#### Post date: [28.Июнь.2017 08:39:25 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/3 "2017-06-28T08:39:25Z")

</div>

> [@mpalmer](#):
>
> Why would you leap straight to the plugin being obsolete?

As I couldn’t find the plugin in the meta, I assumed it to be obsolete. 🙂

I added the plugin to app.yml like below

```
 hooks:
  after_code:
- exec:
    cd: $home/plugins
    cmd:
      - git clone https://github.com/discourse/docker_manager.git
      - git clone https://github.com/discourse/discourse-azure-ad.git

```

During the rebuild it fails at the below point.

```
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 16835 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
4c8dc9092f38bca99f21fac1c7e417f07d979e48f466259088937d1f02345087
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [28.Июнь.2017 21:42:14 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/4 "2017-06-28T21:42:14Z")

</div>

> [@Chanka\_Dod](#):
>
> please scroll up and look for earlier error messages

Yeah… we are going to need that 😉

---

<div class="post-metadata">

### Author: ![Chanka\_Dod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chanka_dod/32/69649_2.png) [@Chanka\_Dod](https://meta.discourse.org/u/Chanka_Dod)
#### Post date: [13.Июль.2017 08:44:25 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/5 "2017-07-13T08:44:25Z")

</div>

Sorry for being late to reply. It’s Yesterday that I was look into the discourse configuration again.

Finally I was able to configure it successfully. Seems like I have done a silly mistake when configuring the plugin. I have not properly added the environment variables to app.yml.

Everything seems to be working smoothly now. 😃

May I know why it’s not published in the meta as a plugin yet?

Cheers

---

<div class="post-metadata">

### Author: ![Ryan\_Nix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_nix/32/78712_2.png) [@Ryan\_Nix](https://meta.discourse.org/u/Ryan_Nix)
#### Post date: [17.Август.2017 12:48:12 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/6 "2017-08-17T12:48:12Z")

</div>

Hi Chanka

Can you please explain a little more what you did to get it to compile? I can’t get Discourse rebuilt with the plugin in my app.yml file.

```
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/discourse/discourse-azure-ad.git

```

Thanks!

- Ryan

---

<div class="post-metadata">

### Author: ![Chanka\_Dod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chanka_dod/32/69649_2.png) [@Chanka\_Dod](https://meta.discourse.org/u/Chanka_Dod)
#### Post date: [25.Август.2017 06:30:13 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/7 "2017-08-25T06:30:13Z")

</div>

Hi Ryan  
Before rebuilding you need to

> If you’re running Discourse from the Docker container, add these environment variables to your container’s yml file:  
> DISCOURSE\_AZURE\_CLIENT\_ID  
> DISCOURSE\_AZURE\_CLIENT\_SECRET  
> (optional) DISCOURSE\_AZURE\_TITLE

Cheers  
Chanka

---

<div class="post-metadata">

### Author: ![Ryan\_Nix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_nix/32/78712_2.png) [@Ryan\_Nix](https://meta.discourse.org/u/Ryan_Nix)
#### Post date: [26.Август.2017 13:57:53 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/8 "2017-08-26T13:57:53Z")

</div>

Thanks, Chanka! Can’t believe it’s that easy. 🙂

---

<div class="post-metadata">

### Author: ![Ryan\_Nix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_nix/32/78712_2.png) [@Ryan\_Nix](https://meta.discourse.org/u/Ryan_Nix)
#### Post date: [14.Сентябрь.2017 11:36:04 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/9 "2017-09-14T11:36:04Z")

</div>

Followup question for @Chanka_Dod and @sam: The oAuth plug-in is working great, except one thing: The user’s email address is incorrect. The plug-in is populating the email address as the short name and the Active Directory domain, neither of which are correct. Example my email address is [r-nix@mycollege.edu](mailto:r-nix@mycollege.edu) but the oAuth plugin is making the email address [rtn456@ad.mycollege.edu](mailto:rtn456@ad.mycollege.edu). Is there a way to add something to the code that populates the user account as the ‘mail’ attribute in LDAP or Active Directory.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [20.Сентябрь.2017 01:56:49 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/10 "2017-09-20T01:56:49Z")

</div>

I am not sure exactly what changes are needed would appreciate some help:

The implementation now is all here:

> <https://github.com/discourse/discourse-azure-ad/blob/main/plugin.rb>

The gem itself that implement the bridge is here:

[https://github.com/KonaTeam/omniauth-azure-oauth2](https://github.com/KonaTeam/omniauth-azure-oauth2)

So you need to figure out first if the change is required in the library we are leaning on vs the library we control.

---

<div class="post-metadata">

### Author: ![marknadig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marknadig/32/79120_2.png) [@marknadig](https://meta.discourse.org/u/marknadig)
#### Post date: [20.Сентябрь.2017 16:05:21 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/11 "2017-09-20T16:05:21Z")

</div>

Crosspoting from gitub. I’m not in a position to test this out at the moment, however it appears that we’re just grabbing the ‘email’ attribute returned from Azure.  
line 52 of

> <https://github.com/marknadig/omniauth-azure-oauth2/blob/master/lib/omniauth/strategies/azure_oauth2.rb>

---

<div class="post-metadata">

### Author: ![Ryan\_Nix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryan_nix/32/78712_2.png) [@Ryan\_Nix](https://meta.discourse.org/u/Ryan_Nix)
#### Post date: [21.Сентябрь.2017 20:15:40 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/12 "2017-09-21T20:15:40Z")

</div>

Looks like the UPN or UserPrincipalName is the attribute being used as the email address in Discourse. I’ll log a ticket with Azure support to see how this can be fixed. @sam @marknadig

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [13.Октябрь.2019 04:55:19 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/13 "2019-10-13T04:55:19Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [17.Июнь.2023 15:55:54 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/14 "2023-06-17T15:55:54Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [17.Июнь.2023 16:29:54 UTC](https://meta.discourse.org/t/discourse-azure-ad-plugin-not-working/65249/15 "2023-06-17T16:29:54Z")

</div>


