# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        google google-authenticator-libpam 1.11
github.tarball_from archive
name                pam-google-authenticator
categories          security
maintainers         {eborisch @eborisch} openmaintainer
license             apache-2 

description         Pluggable Authentication Module for Google Authenticator

long_description    The Google Authenticator PAM module provides an easy way \
                    use Google's 2FA (via Google Authenticator app) to your \
                    existing user authentication infrastructure.

checksums \
    rmd160  8a679ea8a758383f9a4ae8f1b7434aec714d50a7 \
    sha256  3ee08a6dd46aace7dba1c88cf47e9cd267447ccd1cd8be1d5a05fd0e6816062d \
    size    64634

depends_run-append      port:qrencode

# While this isn't needed to compile, the application (setup) portion uses
# dlopen to opportunistically load libqrencode. This dependency is recorded
# above, but application needs the prefix/lib directory in the search path to
# find it.
configure.ldflags-append    -Wl,-rpath -Wl,${prefix}/lib

patch {
    # Match pam-u2f's location for consistency
    reinplace "s|/security|/pam|" Makefile.am
}

use_autoreconf          yes
autoreconf.args         --install

post-destroot {
    xinstall -m 0644 ${worksrcpath}/LICENSE \
        ${destroot}${prefix}/share/doc/google-authenticator/
}

notes "
Create a file for a new service in /etc/pam.d/ or edit
an already existing one by adding a line similar to this:

auth required ${prefix}/lib/pam/pam_google_authenticator.so

See man google-authenticator and pam_google_authenticator or
https://github.com/google/google-authenticator-libpam for details
"