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

password support? #42

Closed
loeken opened this issue Sep 8, 2017 · 3 comments
Closed

password support? #42

loeken opened this issue Sep 8, 2017 · 3 comments
Labels

Comments

@loeken
Copy link

loeken commented Sep 8, 2017

First off love the dashboard :). It's not really a bug more a question. What is the easiest way to add a simple username/password protection to the dashing board?

@odrino14
Copy link

odrino14 commented Sep 8, 2017

hi @loeken,
U have to edit your config.ru

require 'dashing'

configure do
  set :auth_token, 'YOUR_AUTH_TOKEN'
  set :default_dashboard, 'icinga2' 

  set :protection, :except => :frame_options

  helpers do

  def protected!
    unless authorized?
      response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
      throw(:halt, [401, "Not authorized\n"])
    end
  end

  def authorized?
    @auth ||=  Rack::Auth::Basic::Request.new(request.env)
    @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == ['Username', 'Password']
  end

end
 end

map Sinatra::Application.assets_prefix do
  run Sinatra::Application.sprockets
end
run Sinatra::Application

i did i like this.

@loeken
Copy link
Author

loeken commented Sep 8, 2017

thanks for the quick reply @odrino14

and what values define my actual username/password? is the 'YOUR_AUTH_TOKEN' my password? where do i set the user?

@loeken
Copy link
Author

loeken commented Sep 8, 2017

Oh nevermind i didnt see the 'username' 'password' at the bottom, case closed :)

@loeken loeken closed this as completed Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants