From bda44e93541fa478abf3ce4b3461f026a90fa8cb Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 11 Sep 2023 05:15:20 +0200 Subject: Move the site from HTML to GSP --- src/prj/totp/basic-usage.sh.gsp | 7 ++ src/prj/totp/basic-usage.sh.html | 7 -- src/prj/totp/index.gsp | 134 +++++++++++++++++++++++++++++++++++++ src/prj/totp/index.html | 140 --------------------------------------- src/prj/totp/zbarimg.sh.gsp | 4 ++ src/prj/totp/zbarimg.sh.html | 4 -- 6 files changed, 145 insertions(+), 151 deletions(-) create mode 100644 src/prj/totp/basic-usage.sh.gsp delete mode 100644 src/prj/totp/basic-usage.sh.html create mode 100644 src/prj/totp/index.gsp delete mode 100644 src/prj/totp/index.html create mode 100644 src/prj/totp/zbarimg.sh.gsp delete mode 100644 src/prj/totp/zbarimg.sh.html (limited to 'src/prj/totp') diff --git a/src/prj/totp/basic-usage.sh.gsp b/src/prj/totp/basic-usage.sh.gsp new file mode 100644 index 0000000..f1afa3f --- /dev/null +++ b/src/prj/totp/basic-usage.sh.gsp @@ -0,0 +1,7 @@ +$ @span .sh-var {-code}=@span .sh-ex {-`mkpass A-Z0-7`} +$ @span .sh-fn {-totp} $@span .sh-var {-code} +475867 +$ @span .sh-fn {-echo} $@span .sh-var {-code} | @span .sh-fn {-totp} +475867 +$ @span .sh-fn {-totp} -d 10 $@span .sh-var {-code} +0718732338 diff --git a/src/prj/totp/basic-usage.sh.html b/src/prj/totp/basic-usage.sh.html deleted file mode 100644 index 9023218..0000000 --- a/src/prj/totp/basic-usage.sh.html +++ /dev/null @@ -1,7 +0,0 @@ -$ code=`mkpass A-Z0-7` -$ totp $code -475867 -$ echo $code | totp -475867 -$ totp -d 10 $code -0718732338 diff --git a/src/prj/totp/index.gsp b/src/prj/totp/index.gsp new file mode 100644 index 0000000..ea5637a --- /dev/null +++ b/src/prj/totp/index.gsp @@ -0,0 +1,134 @@ +html lang="en" { + head { m4_include(head.gsp) } + body { + header { + div { + h1 {-Easy Password Generation} + m4_include(nav.gsp) + } + + figure .quote { + blockquote { + p {= + The C preprocessor is worse than m4, and I would kill myself before I + had to use m4. + } + } + figcaption {-Arav K.} + } + } + + main { + p { + em {- + You can find the @code{-totp} git repository over at + @a href="https://git.sr.ht/~mango/totp" target="_blank" {-sourcehut} + or + @a href="https://github.com/Mango0x45/totp" target="_blank" {-GitHub}. + } + } + + h2 {-Table of Contents} + ul { + li {a href="#prologue" {-Prologue}} + li {a href="#terms" {-Terminology}} + li {a href="#usage" {-Basic Usage}} + li {a href="#qr" {-Working with QR Codes}} + } + + h2 #prologue {-Prologue} + p {- + m4_abbr(TOTP) codes are pretty cool, and really easay to do. They’re + also the backbone of modern two-factor authentication. With + @code{-totp} I hope to handling m4_abbr(TOTP) codes as easy and + extensible as possible + } + + h2 #terms {-Terminology} + p {- + There are a few terms that I will be using throughout this post, so it’s + good to make sure that we’re all on the same page about what I’m + referring to. + } + + dl { + dt {-Secret} + dd { + p {- + Your @em{-secret} is a + @a + href="https://en.wikipedia.org/wiki/Base32" + target="_blank" + {-base32} + encoded secret key that you should under no circumstances share with + anyone else. It is from this secret key that we can generate valid + m4_abbr(TOTP) codes. + } + } + + dt {-Digits} + dd { + p {- + Your @em {-digits} is the length of the generated m4_abbr(TOTP) in + digits. If @em{-digits} is 8, then your generated key could be + ‘01234567’. When dealing with m4_abbr(2FA) this is typically 6. + } + } + + dt {-Period} + dd { + p {- + Your @em{-period} it the duration for which the generated key is + valid in seconds. When working with m4_abbr(2FA) this is typically + 30. + } + } + } + + h2 #usage {-Basic Usage} + + p {- + @code{-totp} takes secret keys as command-line arguments, but also reads + them from the standard input if none are provided. It assumes that + @em{-digits} is 6 and @em{-period} is 30. These defaults can be changed + with the @code{--d} and @code{--p} flags. + } + + figure { + pre { m4_fmt_code(basic-usage.sh.gsp) } + } + + aside { + p {- + I’m using @code{-mkpass} to generate a random secret. You can + see my post about @code{-mkpass} @a href="/prj/mkpass" {-here}. + } + } + + h2 #qr {-Working with m4_abbr(QR) Codes} + p {- + Often times when enabling m4_abbr(2FA) on your account on some website + or platform, you will be shown a m4_abbr(QR) code you can scan with your + m4_abbr(2FA) mobile application. These m4_abbr(QR) codes contain + @em{-otpauth} m4_abbr(URI)s. We can extract these from downloaded + images using utilities such as @code{-zbarimg} and use them in + @code{-totp} using the @code{--u} flag to enable ‘m4_abbr(URI) mode’ + } + + figure { + pre { m4_fmt_code(zbarimg.sh.gsp) } + } + + p {- + …and that’s all! There’s nothing else you need. You can use secret + keys and otpauth m4_abbr(URI)s, and you can configure the @em{-digits} + and @em{-period} of the generated codes. You can generate multiple keys + at once, and all outputs are printed to the standard output. + } + } + + hr{} + + footer { m4_footer } + } +} diff --git a/src/prj/totp/index.html b/src/prj/totp/index.html deleted file mode 100644 index aa040d4..0000000 --- a/src/prj/totp/index.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - m4_include(head.html) - - -
-
-

Easy Password Generation

- m4_include(nav.html) -
- -
-
-

The C preprocessor is worse than m4, and I would kill myself - before I had to use m4.

-
-
- Arav K. -
-
-
- -
-

- - You can find the totp git repository over at - sourcehut - or GitHub. - -

- -

Table of Contents

- - - -

Prologue

-

- TOTP codes are pretty cool, and really easy to - do. They’re also the backbone of modern two-factor authentication. - With totp I hope to make - handling TOTP codes as easy and extensible as - possible. -

- -

Terminology

-

- There are a few terms that I will be using throughout this post, so it’s - good to make sure that we’re all on the same page about what I’m - referring to. -

- -
-
Secret
-
-

- Your secret is - a base32 encoded secret key that you should under - no circumstances share with anyone else. It is from this secret key - that we can generate valid TOTP codes. -

-
- -
Digits
-
-

- Your digits is the length of the generated - TOTP in digits. If digits is 8, - then your generated key could be ‘01234567’. When dealing - with 2FA this is typically 6. -

-
- -
Period
-
-

- Your period it the duration for which the generated key is - valid in seconds. When working with 2FA - this is typically 30. -

-
-
- -

Basic Usage

-

- totp takes secret keys as command-line arguments, but also - reads them from the standard input if none are provided. It assumes - that digits is 6 and period is 30. These defaults can - be changed with the -d and -p flags. -

- -
-
m4_fmt_code(basic-usage.sh.html)
-
- - - -

Working with QR Codes

-

- Often times when enabling 2FA on your account - on some website or platform, you will be shown - a QR code you can scan with - your 2FA mobile application. - These QR codes - contain otpauth URIs. We can extract - these from downloaded images using utilities such - as zbarimg and use them in totp using - the -u flag to enable ‘URI mode’ -

- -
-
m4_fmt_code(zbarimg.sh.html)
-
- - …and that’s all! There’s nothing else you need. You can use secret keys - and otpauth URIs, and you can configure - the digits and period of the generated codes. You can - generate multiple keys at once, and all outputs are printed to the - standard output. -
- -
- - - - diff --git a/src/prj/totp/zbarimg.sh.gsp b/src/prj/totp/zbarimg.sh.gsp new file mode 100644 index 0000000..cd0669b --- /dev/null +++ b/src/prj/totp/zbarimg.sh.gsp @@ -0,0 +1,4 @@ +$ @span .sh-fn {-zbarimg} -q my-qr-code.svg @span .sh-cmt {-# Also works with jpg, png, etc.} +QR-Code:otpauth://totp/GitHub:Mango0x45?secret=O1AIWMONKWVRJY4H&issuer=GitHub +$ @span .sh-fn {-zbarimg} -q my-qr-code.svg | @span .sh-fn {-sed} s/QR-Code:// | @span .sh-fn {-totp} -u +554210 diff --git a/src/prj/totp/zbarimg.sh.html b/src/prj/totp/zbarimg.sh.html deleted file mode 100644 index 862eb78..0000000 --- a/src/prj/totp/zbarimg.sh.html +++ /dev/null @@ -1,4 +0,0 @@ -$ zbarimg -q my-qr-code.svg # Also works with jpg, png, etc. -QR-Code:otpauth://totp/GitHub:Mango0x45?secret=O1AIWMONKWVRJY4H&issuer=GitHub -$ zbarimg -q my-qr-code.svg | sed s/QR-Code:// | totp -u -554210 -- cgit v1.2.3