Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 2.24 KB

Class_FileRepository.md

File metadata and controls

60 lines (42 loc) · 2.24 KB

FileRepository Class

A client key repository based on a htpasswd-style file.

See KeyRepository interface.

The constructor takes a filename and ensures it's not a directory's name.

The constructor does however not check the filename for existence, readability, or format. This is done once on the first actual usage of the repository (offsetExists/offsetGet). If you want to force these checks and the file read early, call the forceRead() method.

The file will not be re-read on multiple offsetGet calls.

The expected file format is that of htpasswd files:

  • One clientId:clientKey pair per line.
  • clientId must be non-empty and cannot contain colons.
  • clientKey must be non-empty.
  • Leading and trailing whitespace will be removed.
  • Empty lines, whitespace-only lines and lines starting with a "#" will be ignored.

Real htpasswd files usually contain password hashes instead of plaintext passwords, making them useless for our BasicAuthenticationMethod (which works with plaintext client keys only). Use the BasicHashAuthenticationMethod instead, it understands most hash methods traditionally used in htpasswd files.

You may of course also store public keys in a htpasswd-style key repository files to use with a class like PublicKeyMethod.

Class Details

Constructor

  • __construct (string $filename)

Other Methods

  • forceRead (): self
    Forces the source file to be read immediately.
    (This only has an effect once and only prior to the first offsetExists/offsetGet call.)