GithubHelp home page GithubHelp logo

k3-simpleauth's Introduction

K3-SimpleAuth Module

A Ko3 Module by John Hobbs

Introduction

This module provides super simple role based auth for controllers. It requires the Auth module.

Installation

K3-SimpleAuth is a simple, standard module.

  1. Drop the source in your MODPATH folder.
  2. Add the module to Kohana::modules in your bootstrap.php

Usage

To use K3-SimpleAuth you need to extend your controllers from either the "Controller_Auth" or "Controller_Auth_Template" classes.

These classes will then control access to actions based on the user's roles and the $auth member.

You can block actions off as needed, rules are processed in descending order.

The character '*' is used as a wildcard.

Examples:

$auth = array(
  // Only roles 'admin' can reach this
  'one' => 'admin',
  // Only roles 'manager' _and_ 'admin' can reach this
  'two' => array( 'manager', 'admin'  ),
  // Anyone logged in can reach this
  'three' => '*',
  // Anyone can access this action, logged in or out
  'four' => false,
  // Any other action can only be reached by those with the 'view' role
  '*' => 'view',
  // This rule is never reached, because of the wildcard rule directly above
  'five' => 'admin', 
);

To change the default actions taken, simply override these two methods:

protected function _not_authorized () {
  throw new HTTP_Exception_403();
}
	
protected function _not_logged_in () {
  $this->session->set( 'return-to', Request::$current->url() );
  throw new HTTP_Exception_401();
}

k3-simpleauth's People

Contributors

jmhobbs avatar

Stargazers

 avatar

Watchers

 avatar  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.