Module: Annex::Config
- Defined in:
- lib/annex/config.rb
Constant Summary collapse
- DEFAULT_AUTHENTICATION =
Annex is setup to try and authenticate with warden If warden is found, then it will try to authenticate
This is valid for custom warden setups, and also devise If you’re using the admin setup for devise, you should set Annex to use the admin
Proc.new do request.env['warden'].try(:authenticate!) end
- DEFAULT_AUTHORIZE =
Proc.new {}
- DEFAULT_CURRENT_USER =
Proc.new do request.env["warden"].try(:user) || respond_to?(:current_user) && current_user end
Class Method Summary collapse
-
.authenticate_with(&blk) ⇒ Object
Setup authentication to be run as a before filter This is run inside the controller instance so you can setup any authentication you need to.
-
.authorize_with(*args, &block) ⇒ Object
Setup authorization to be run as a before filter This is run inside the controller instance so you can setup any authorization you need to.
- .connect_with(adapter = :activerecord) ⇒ Object
Class Method Details
.authenticate_with(&blk) ⇒ Object
Setup authentication to be run as a before filter This is run inside the controller instance so you can setup any authentication you need to
By default, the authentication will run via warden if available and will run the default.
If you use devise, this will authenticate the same as authenticate_user!
47 48 49 50 |
# File 'lib/annex/config.rb', line 47 def authenticate_with(&blk) @authenticate = blk if blk @authenticate || DEFAULT_AUTHENTICATION end |
.authorize_with(*args, &block) ⇒ Object
Setup authorization to be run as a before filter This is run inside the controller instance so you can setup any authorization you need to.
By default, there is no authorization.
To use an authorization adapter, pass the name of the adapter. For example, to use with CanCan, pass it like this.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/annex/config.rb', line 73 def (*args, &block) extension = args.shift if(extension) = Proc.new { = Annex::AUTHORIZATION_ADAPTERS[extension].new(*([self] + args).compact) } else = block if block end || DEFAULT_AUTHORIZE end |
.connect_with(adapter = :activerecord) ⇒ Object
85 86 87 |
# File 'lib/annex/config.rb', line 85 def connect_with(adapter = :activerecord) @adapter = adapter end |