All Projects → bkuhlmann → auther

bkuhlmann / auther

Licence: other
Enhances Rails with multi-account, form-based, database-less, application-wide authentication.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
SCSS
7915 projects
Slim
82 projects
CSS
56736 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to auther

Sharpen
(Demo) A v-dom "diff" engine based on WebAssembly, aim to build efficient and fluent web apps.
Stars: ✭ 20 (-9.09%)
Mutual labels:  engine
core
🔥 Antares Core Implemenation. Most important project layer, this is the heart for your app. ACL, notifiter, console, geoip, areas, utils and many more...
Stars: ✭ 24 (+9.09%)
Mutual labels:  authorization
jdbc-adapter
JDBC adapter for Casbin
Stars: ✭ 26 (+18.18%)
Mutual labels:  authorization
opa-spring-security
Open Policy Agent for Spring Security
Stars: ✭ 19 (-13.64%)
Mutual labels:  authorization
casbin-aspnetcore
Casbin.NET integration and extension for ASP.NET Core
Stars: ✭ 39 (+77.27%)
Mutual labels:  authorization
desktop
Extendable calculator for the 21st Century ⚡
Stars: ✭ 85 (+286.36%)
Mutual labels:  engine
Kade-Engine
Kade Engine is a Competitive Rhythm Game engine rewrite for FNF with Quality of Life features included.
Stars: ✭ 400 (+1718.18%)
Mutual labels:  engine
MonoGame.Forms
MonoGame.Forms is the easiest way of integrating a MonoGame render window into your Windows Forms project. It should make your life much easier, when you want to create your own editor environment.
Stars: ✭ 183 (+731.82%)
Mutual labels:  engine
Fyrox
3D and 2D game engine written in Rust
Stars: ✭ 3,539 (+15986.36%)
Mutual labels:  engine
uSource
uSource is a plugin for importing MDL / BSP / VMT / VTF and etc... resources to Unity!
Stars: ✭ 44 (+100%)
Mutual labels:  engine
keyonic-v2
A Keycloak Mobile Implementation using Angular v4 and Ionic v3
Stars: ✭ 23 (+4.55%)
Mutual labels:  authorization
hadoop-data-ingestion-tool
OLAP and ETL of Big Data
Stars: ✭ 17 (-22.73%)
Mutual labels:  engine
OpenAM
OpenAM is an open access management solution that includes Authentication, SSO, Authorization, Federation, Entitlements and Web Services Security.
Stars: ✭ 476 (+2063.64%)
Mutual labels:  authorization
powerauth-crypto
PowerAuth - Open-source solution for authentication, secure data storage and transport security in mobile banking.
Stars: ✭ 48 (+118.18%)
Mutual labels:  authorization
ure
the unRogueEngine
Stars: ✭ 111 (+404.55%)
Mutual labels:  engine
authz0
🔑 Authz0 is an automated authorization test tool. Unauthorized access can be identified based on URLs and Roles & Credentials.
Stars: ✭ 248 (+1027.27%)
Mutual labels:  authorization
spica
Spica is a development engine to build fast & efficient applications.
Stars: ✭ 77 (+250%)
Mutual labels:  engine
xamboo
The CMS Framework and web server to build full applications and APIs for Go
Stars: ✭ 14 (-36.36%)
Mutual labels:  engine
jitterphysics
A cross-platform, realtime physics engine for all .NET apps.
Stars: ✭ 327 (+1386.36%)
Mutual labels:  engine
graphql-auth-directives
Add authorization to your GraphQL API using schema directives.
Stars: ✭ 110 (+400%)
Mutual labels:  authorization

Auther

Auther provides simple, form-based authentication for apps that need security but don’t want to deal with the clunky HTTP Basic Authentication user interface or as heavyweight as Devise. Auther doesn’t require a database and is compatible with password managers which makes for a pleasant user experience.

Auther is useful in situations — like minimal viable products or applications with a small user base — where you need to a security layer up and running quickly before adding more robust user management.

Features

  • Supports form-based authentication compatible with password managers like 1Password.

Form Without Errors Screenshot
Form With Errors Screenshot
  • Uses CSS Flexbox for lightweight styling.

  • Uses encrypted account credentials to keep sensitive information secure.

  • Supports multiple accounts with optional path exclude lists.

  • Supports customizable routes, models, presenters, views, controllers, and loggers.

  • Provides a generator for easy install and setup within an existing project.

  • Provides auto-redirection to requested path for verified credentials.

Requirements

Setup

To install, run:

gem install auther

Add the following to your Gemfile:

gem "auther"

Run the install generator to configure and initialize your application:

rails generate auther:install

Run the credentials generator to generate credentials for your application:

rails generate auther:credentials

If using direnv, for example, you can copy and paste the generated credentials into your .envrc file. Example:

Credentials Generator Screenshot

Usage

Launch your Rails application and visit the following: http://localhost:3000/login. Enter your login and password as used for the rails generate auther:credentials generator and you’ll be logged in.

Initializer

The initializer (installed during setup) can be found here: config/initializers/auther.rb. The initializer comes installed with the following settings:

Rails.application.config.auther_settings = {
  accounts: [
    {
      name: "admin",
      encrypted_login: ENV["AUTHER_ADMIN_LOGIN"],
      encrypted_password: ENV["AUTHER_ADMIN_PASSWORD"],
      paths: ["/admin"]
    }
  ],
  secret: ENV["AUTHER_SECRET"]
}

To encrypt/decrypt account credentials, launch a rails console and run the following:

# The secret as defined in `auther_settings` and/or produced by the credentials generator.
secret = SecureRandom.hex 16 # "426a7f46548a1a4518676a8e246517d8"

# The cipher for encrypting/decrypting values.
cipher = Auther::Cipher.new secret

# Use the following to encrypt an unencrypted value.
cipher.encrypt "[email protected]"

# Use the following to decrypt an encrypted value.
cipher.decrypt "hWToltdpl+uZJBPELKNC7Ij++jPkTuo=--nEdbOYL9fIRh14hY--fU+VSCd4+DDOhOmG1gzRfQ=="

The initializer can be customized as follows:

  • title - Optional. The HTML page title (as rendered within a browser tab). Default: "Authorization".

  • label - Optional. The page label (what would appear above the form). Default: "Authorization".

  • secret - Required. The secret passphrase used to encrypt/decrypt account credentials.

  • accounts - Required. The array of accounts with different or similar access to the application.

    • name - Required. The account name that uniquely identifies the account.

    • encrypted_login - Required. The encrypted account login.

    • encrypted_password - Required. The encrypted account password.

    • paths - Required. The array of excluded paths for which only this account has access to.

    • authorized_url - Optional. The URL to redirect to upon successful authorization. Authorized redirection works in the order defined:

      • The excluded path (if requested prior to authorization but now authorized).

      • The authorized URL (if defined and the excluded path wasn’t requested).

      • The root path (if none of the above).

    • deauthorized_url - Optional. The URL to redirect to upon successful deauthorization (i.e. logout). Deauthorized redirections works as follows (in the order defined):

      • The deauthorized URL (if defined).

      • The auth URL.

  • url - Optional. The URL to redirect to when enforcing authentication. Default: "/login".

  • logger - Optional. The logger used to log path/account authorization messages. Default: Auther::NullLogger.

Routes

The routes can be customized as follows (installed, by default, via the install generator):

Rails.application.routes.draw do
  mount Auther::Engine => "/auther"
  get "/login", to: "auther/session#new", as: "login"
  delete "/logout", to: "auther/session#destroy", as: "logout"
end

Model

The Auther::Account is a struct that uses ActiveModel validations to aid in attribute validation. This model could potentially be replaced with a database-backed object (would require controller customization)…​but you should question if you have outgrown the use of this gem and need a different solution altogether if it comes to that.

Presenter

The Auther::Presenter::Account is a plain old Ruby object that uses ActiveModel validations to aid in form validation. This presenter makes it easy to construct form data for input and validation.

View

The view can be customized by creating the following file within your Rails application (assumes that the default Auther::SessionController implementation is sufficient): app/views/auther/session/new.html.

The form uses the @account instance variable which is an instance of the Auther::Presenter::Account presenter (as mentioned above). The form can be stylized by modifying the styles found in the auther.scss stylesheet.

Controller

The Auther::SessionController inherits from the Auther::BaseController. To customize, it is recommended that you add a controller to your app that inherits from the Auther::BaseController. Example:

# Example Path:  app/controllers/session_controller.rb
class SessionController < Auther::BaseController
  layout "example"
end

This allows customization of session controller behavior to serve any special business needs. See the Auther::BaseController for additional details or the Auther::SessionController for default implementation.

Logging

As mentioned in the setup above, the logger can be customized as follows:

# This is the default logger silences all logging attempts.
Auther::NullLogger.new

# Can be used to log to the environment log.
ActiveSupport::Logger.new "log/#{Rails.env}.log"

# Can be used to log to standard output.
Logger.new STDOUT

When logging is enabled, you’ll be able to see the following information in the server logs to help debug custom Auther settings:

  • Requested path and excluded path detection.

  • Finding (or not finding) of account.

  • Account authentication pass/fail.

  • Account and path authorization pass/fail.

Troubleshooting

  • If upgrading Rails, changing the cookie/session settings, generating a new secret base key, etc. this might cause Auther authentication to fail. Make sure to clear your browser cookies in this situation or use Google Chrome (incognito mode) to verify.

  • If the authentication view/form looks broken (stylewise) this could be due to custom ActionView::Base.field_error_proc settings defined by your app (usually via an initializer). Auther uses this configuration ActionView::Base.field_error_proc = proc { |html_tag, _| html_tag.html_safe } so that no additional markup is added to the DOM when errors are raised. If you have customized this to something else, you might want to read the usage documentation (mentioned above) to rebuild the authentication view/form for your specific business needs.

Development

To contribute, run:

git clone https://github.com/bkuhlmann/auther.git
cd auther
bin/setup

You can also use the IRB console for direct access to all objects:

bin/console

Tests

To test, run:

bundle exec rake

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].