arr2036 / omnigollum

Omniauth authentication for gollum
MIT License
147 stars 61 forks source link

Authorised Users Check #39

Closed fbritoferreira closed 8 years ago

fbritoferreira commented 8 years ago

In the

options[:authorized_users] = ["example0@example.org", "example1@example.org", "example2@example.org"]

Is there a option to have all user of a specific domain? For example do all users in @github.com can access the wiki while users with @example.org will not be able to do so.

Filipe

BriceShatzer commented 8 years ago

The ability to provide a Regex in lieu of an array was added with this pull request.

This commit happened after the most recent version was released, so you'll have to clone and build the gem locally (demonstrated in Readme) in addition to including it in your gem file.

arr2036 commented 8 years ago

Just pushed a new gem.

fbritoferreira commented 8 years ago

@BriceShatzer Could you show a config example for a regex that take in everyone in a domain?

BriceShatzer commented 8 years ago

We use google as our provider, so the options object we use looks roughly like:

options = {
  # OmniAuth::Builder block is passed as a proc
  :providers => Proc.new do
    provider :google_oauth2, "CONSUMER_KEY", "CONSUMER_SECRET"
  end,
  :authorized_users => /@bizname.com$/,
  :protected_routes => ['/*'],
  :dummy_auth => false
}

Precious::App.set(:omnigollum, options)

this prevents access to all pages unless the user authenticates with an email address that ends with the string "@bizname.com"

fbritoferreira commented 8 years ago

@BriceShatzer Thank you that actually worked.

fbritoferreira commented 8 years ago

@BriceShatzer Is there a way to have two domains?

BriceShatzer commented 8 years ago

you should be able to do:

:authorized_users => /@bizname.com$|@company.com$/,
fbritoferreira commented 8 years ago

@BriceShatzer Thank you