Sha256: a9c176934127a7d5cd59a2f191dc1363eabaa0b9a46a3173e80d70de2af1d383

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

module Shamu
  # {include:file:lib/shamu/security/README.md}
  module Security
    require "shamu/security/error"
    require "shamu/security/principal"
    require "shamu/security/policy"
    require "shamu/security/policy_rule"
    require "shamu/security/no_policy"
    require "shamu/security/support"
    require "shamu/security/roles"
    require "shamu/security/roles_service"
    require "shamu/security/hashed_value"

    # See {.private_key}
    ENV_PRIVATE_KEY = "SHAMU_PRIVATE_KEY".freeze

    # @!attribute
    #
    # A strong key used to authenticate (not encrypt) input from untrusted
    # sources (such as cookies, headers, etc).
    #
    # If the key has not been {#private_key= set then shamu will look for an
    # environment variable named SHAMU_PRIVATE_KEY.
    #
    # ## To generate a strong key
    #
    # ```
    # # 1024-bit private key
    # key = SecureRandom.base64( 128 )
    # ```
    # @return [String]
    def self.private_key
      @private_key ||= ENV[ ENV_PRIVATE_KEY ] || fail( "No private key configured. Set Shamu::Security.private_key or add an the #{ ENV_PRIVATE_KEY } environment variable to the host." ) # rubocop:disable Metrics/LineLength
    end

    # @param [String] key to use.
    # @return [String]
    def self.private_key=( key )
      @private_key = key && Base64.decode64( key )
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shamu-0.0.18 lib/shamu/security.rb
shamu-0.0.17 lib/shamu/security.rb
shamu-0.0.15 lib/shamu/security.rb
shamu-0.0.14 lib/shamu/security.rb
shamu-0.0.13 lib/shamu/security.rb
shamu-0.0.11 lib/shamu/security.rb
shamu-0.0.9 lib/shamu/security.rb
shamu-0.0.8 lib/shamu/security.rb
shamu-0.0.7 lib/shamu/security.rb
shamu-0.0.5 lib/shamu/security.rb
shamu-0.0.4 lib/shamu/security.rb
shamu-0.0.3 lib/shamu/security.rb
shamu-0.0.2 lib/shamu/security.rb