struct

KemalIdentity::Secret

Inherits Struct < Value < Object

A string that must never be printed.

Wrapping a raw credential in this type means a crash report, a Log call or an accidental interpolation prints #<KemalIdentity::Secret [REDACTED]> instead of the password, the session token or the cookie signing key. docs/02-security-model.md requires that every type holding a secret redacts itself, the configuration object included.

This is a safety net, not a licence to log. Nothing on the authentication path should be logging a Secret at all.

Constructors

new(value : String)
Source

Instance methods

==(other : Secret) : Bool

Constant-time equality.

== on String short-circuits at the first differing byte, which leaks the length of the matching prefix. Secrets are compared here and nowhere else.

Source
==(other : String) : Bool
Source
bytesize

Length of the underlying value. Safe to log; used by the shape checks that run before any hashing or I/O.

Source
digest

SHA-256 of the value, as raw bytes.

Raw bytes rather than hex: BYTEA is half the storage of a hex CHAR(64) and there is no encoding for two adapters to disagree about (docs/03-data-model.md).

Source
empty?
Source
inspect(io : IO) : Nil

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Source
reveal

The raw value. Every call site is a place a secret can escape, so keep them few and obvious: hashing, digesting, and constant-time comparison.

Source
size

Length in characters, for a policy that counts what a person typed. Distinct from #bytesize, which is what an algorithm's limit is measured in.

Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source