Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard authorized emails? #9

Open
brylie opened this issue Oct 16, 2018 · 5 comments
Open

Wildcard authorized emails? #9

brylie opened this issue Oct 16, 2018 · 5 comments

Comments

@brylie
Copy link

brylie commented Oct 16, 2018

How might one allow wildcard email authorization? E.g. all emails for a Google authentication domain, such as a company's staff. Is there an approach to enable all organization users, or specific email domains?

@lchapo
Copy link
Owner

lchapo commented Oct 16, 2018

The simplest solution is to modify the auth function here to something like:
if email.endswith("@mycompany.com"):

An even better approach would be to store authorized emails in a database and have the auth function do a lookup against that database.

@joshbode
Copy link
Collaborator

I'm using this approach at the moment:

from fnmatch import fnmatch

class GlobList(list):
    """Glob list"""

    def __contains__(self, key) -> bool:
        """Check if key in list or matches patterns in list."""

        if super().__contains__(key):
            return True

        for k in self:
            if fnmatch(key, k):
                return True

        return False

and setting:

authorized_emails = GlobList(['*@example.com', 'foo@dog.com'])
auth = GoogleOAuth(app, authorized_emails)

@brylie
Copy link
Author

brylie commented Oct 26, 2018

@joshbode, this would be a really good addition to the README, or some similar documentation! :-)

@ghost
Copy link

ghost commented Nov 27, 2018

The simplest solution is to modify the auth function here to something like:
if email.endswith("@mycompany.com"):

An even better approach would be to store authorized emails in a database and have the auth function do a lookup against that database.

Your url doesn't seem to be working.

@lchapo
Copy link
Owner

lchapo commented Nov 27, 2018

@VedantRuparelia whoops, linked to a private repo. Fixed my comment above (new link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants