GithubHelp home page GithubHelp logo

nurole / sinatra_warden Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wardencommunity/sinatra_warden

0.0 0.0 0.0 88 KB

Authentication module for sinatra and some auth helpers

Home Page: https://github.com/wardencommunity/sinatra_warden

License: MIT License

Ruby 100.00%

sinatra_warden's Introduction

Sinatra::Warden

A Sinatra module that provides authentication for your Sinatra application through Warden.

Usage

  require 'sinatra'
  require 'sinatra_warden'

  class Application < Sinatra::Base
    register Sinatra::Warden

    get '/admin' do
      authorize!('/login') # require session, redirect to '/login' instead of work
      haml :admin
    end

    get '/dashboard' do
      authorize! # require a session for this action
      haml :dashboard
    end
  end

Options

Sinatra::Warden lets you override options to customize functionality. You can place them anywhere after executing register Sinatra::Warden in your application.

Configurations are set using the set action: set :setting_name, value

Configuration Settings

Setting Name Type Description
:auth_success_path String/Proc The path you want to redirect to on authentication success. Defaults to "/".
:auth_failure_path String/Proc The path you want to redirect to on authentication failure. (e.g. "/error") Defaults to lambda { back }.
:auth_success_message String The flash[:success] message to display (requires Rack::Flash). Defaults to "You have logged in successfully."
:auth_error_message String The flash[:error] message to display (requires Rack::Flash). Defaults to "Could not log you in."
:auth_template_renderer String Template renderer to use. Defaults to haml, can also use erb
:auth_login_template Symbol The path to the login form you want to use with Sinatra::Warden. Defaults to :login.

OAuth Configuration Settings

Available since sinatra_warden >= 1.6.x

Setting Name Type Description
:auth_use_oauth Boolean Use OAuth authorization for the "/login" route. Defaults to false.
:auth_oauth_authorization_url Proc/String The path you want to redirect to for OAuth authorization (e.g. lambda { consumer.get_request_token.authorize_url }.

Note on Patches/Pull Requests

  $ git clone git://github.com/wardencommunity/sinatra_warden.git
  $ cd sinatra_warden
  $ bundle install
  $ bundle exec rake
  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history.
  • Send me a pull request. Bonus points for topic branches.

Contributors

Copyright

Copyright (c) 2009-2017 Justin Smestad. See LICENSE for details.

sinatra_warden's People

Contributors

jsmestad avatar shanna avatar olleolleolle avatar ifunam-mirror avatar dlundqvist avatar x1ddos avatar panasyuk avatar bobbywilson0 avatar dereke avatar martinos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.