Question: I have the following list comprehension:

```
dirs = [dir for dir in dirs if 'XXX_' in dir]

```

where the list comprehension is filtering out directories returned by an os.walk() that do not have 'XXX\_' as part of the directory name. I have then been appending 'Supervisor' as a directory because I know that it will be included in any project that this script runs against.

This feels very hacky and I'm sure that there is a better way to include 'Supervisor' along with 'XXX\_' in my filtering rather than filtering it out and then re-appending it.

The original segment of code is:

```
dirs = [os.path.basename(dir[0]) for dir in os.walk(os.getcwd())]
dirs = [dir for dir in dirs if 'XXX_' in dir]
dirs.append('Supervisor')

```

Can anyone recommend a cleaner solution?

Answer: 
You can't decode the authorization code that is issued to `/oauth2/callback` because it is encrypted.

[oauth2\_proxy's Azure AD provider](https://github.com/bitly/oauth2_proxy/blob/a94b0a8b25e553f7333f7b84aeb89d9d18ec259b/providers/azure.go#L86) expects a **mail** or **otherMails** claim to be issued. Azure AD issues this but Azure AD B2C doesn't issue it. Azure AD B2C issues the **emails** claim.

You might have to modify this Azure AD provider to match the **emails** claim.
No idea if this is still relevant to you, Azure AD B2C essentially uses standard OpenID Connect, however with the addition that you need to supply a policy as additional parameter.

We also had the need to use Azure AD B2C with oauth2\_proxy, so we modified the oauth2\_proxy generic oidc provider so it can take a B2C policy as additional config option.

If you want, give it a try: <https://github.com/karrieretutor/oauth2_proxy#microsoft-azure-ad-b2c>

If you're building from source, be aware that you also need to use our forked 'go-oidc' package (on which oauth2\_proxy relies, but has part of the issuer URL hardcoded, so we had to change this, too, for including the B2C policy). Take a look at the Dockerfile, this can properly build it.