Added shortcodes, lots of improvements and content dump

This commit is contained in:
Sivert V. Sæther 2022-06-07 13:54:07 +00:00
parent 6c98fcf57a
commit 9859c9e5ba
34 changed files with 448 additions and 59 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
hugo_stats.json
node_modules/
resources/
public/
yarn.lock
public/

View File

@ -1,6 +1,6 @@
.PHONY: help build create debug clean up down
BASE := --baseURL https://1313.proxy.blacktarheroin.no/
BASE := --baseURL https://proxy.blacktarheroin.no/
help:
@echo '= Make targets:'
@ -23,7 +23,7 @@ pull:
$(DOCK) pull $(LANGTOOL)
HUGO := hugo --printI18nWarnings --printPathWarnings --printUnusedTemplates --templateMetricsHints # --templateMetrics --cleanDestinationDir --gc
SERV := server $(BASE) --bind 0.0.0.0 --liveReloadPort 80 --appendPort=false --disableFastRender --printMemoryUsage --noHTTPCache --renderToDisk --navigateToChanged
SERV := server $(BASE) --bind 0.0.0.0 --liveReloadPort 443 --appendPort=false --disableFastRender --printMemoryUsage --noHTTPCache --renderToDisk --navigateToChanged
DEV := $(HUGO) -e dev $(SERV)
build: clean_pub

12
archetypes/apprentice.md Normal file
View File

@ -0,0 +1,12 @@
---
date: {{ .Date }}
draft: true
aliases: []
categories: ['documentation']
series: ['apprentice']
tags: ['various']
chroma: false
toc: true
title: {{ replace .Name "-" " " | title }}
description:
---

View File

@ -5,6 +5,7 @@ aliases: []
categories: ['various']
series: []
tags: ['various']
chroma: false
toc: true
title: {{ replace .Name "-" " " | title }}
description:

View File

@ -4,7 +4,7 @@ draft: true
aliases: []
categories: ['meta']
series: []
tags: ['meta','meta']
tags: ['meta']
toc: true
title: {{ replace .Name "-" " " | title }}
description:

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -0,0 +1,18 @@
param([String]$tid='', [String]$app='')
if ($tid -eq '' or $app -eq '') {
$name = [Environment]::GetCommandLineArgs()[0]
Write-Host "Usage: pwsh $name -tid [tenant id] -app [app id]"
exit
}
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
if ((Get-module -ListAvailable -name 'AzureAD') -eq $null) {
Install-Module 'AzureAD' -Scope CurrentUser
}
Import-Module AzureAD
Connect-AzureAD -TenantID "$tid"
New-AzureADServicePrincipal -AppId "$app"

View File

@ -0,0 +1,62 @@
// This does mostly the same as that example from the official docs
let simple = () => {
let template = Handlebars.compile("Handlebars <b>{{doesWhat}}</b>")
let out = template({ doesWhat: "rocks!" })
console.log(out)
return out
}
let nested = () => {
}
let eval = () => {
}
// Simple helper
Handlebars.registerHelper('', (str) => {
return ''
})
// Block helper
Handlebars.registerHelper('', (items, options) => {
})
// Handlebars registered partial
Handlebars.registerPartial('', '')
inlinePartial = `
{{#*inline "inlinePartial"}}
{{/inline}}`
let advanced = () => {
}
// Run "main" after all is loaded
document.addEventListener("DOMContentLoaded", function() {
let output = document.createElement('div')
output.id = 'output'
document.getElementById('meta').append(output)
// Here we use those "triple mustaches"!
let template = Handlebars.compile(`
<br /><div>
<h4>Examples output:</h4>
<h5>Functions:</h5>
<p>Simple: {{{simple}}}</p>
<p>Nested: {{{nested}}}</p>
<p>Eval: {{{eval}}}</p></div>`)
// Render and insert the template above
document.getElementById('output').innerHTML = template({
simple: simple(), nested: nested(), eval: eval()})
})

View File

@ -1,37 +1,53 @@
.highlight pre { padding: 1rem; max-width: 75%; }
.chroma {
background-color: #ffffff;
.lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
.lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; }
.hl { display: block; width: 100%;background-color: #ffffcc }
.lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
.ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
.k { color: #0000ff }
.kc { color: #0000ff }
.kd { color: #0000ff }
.kn { color: #0000ff }
.kp { color: #0000ff }
.kr { color: #0000ff }
.kt { color: #0000ff }
.s { color: #009c00 }
.sa { color: #009c00 }
.sb { color: #009c00 }
.sc { color: #009c00 }
.dl { color: #009c00 }
.sd { color: #009c00 }
.s2 { color: #009c00 }
.se { color: #009c00 }
.sh { color: #009c00 }
.si { color: #009c00 }
.sx { color: #009c00 }
.sr { color: #009c00 }
.s1 { color: #009c00 }
.ss { color: #009c00 }
.c { color: #ff0000; font-style: italic }
.ch { color: #ff0000; font-style: italic }
.cm { color: #ff0000; font-style: italic }
.c1 { color: #ff0000; font-style: italic }
.cs { color: #ff0000; font-style: italic }
.cp { color: #ff0000; font-style: italic }
.cpf { color: #ff0000; font-style: italic }
}
.chroma { padding: .1vh 0 0; margin: 0 0 .7vh }
.chroma { padding: .1vh 0 0; margin: 0 0 .7vh }
.chroma { color: #ffffff; background-color: #111111 }
.chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0 }
.chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0 }
.chroma .hl { background-color: #ffffcc }
.chroma .lnt { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
.chroma .ln { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
.chroma .line { display: flex; }
.chroma .k { color: #fb660a; font-weight: bold }
.chroma .kc { color: #fb660a; font-weight: bold }
.chroma .kd { color: #fb660a; font-weight: bold }
.chroma .kn { color: #fb660a; font-weight: bold }
.chroma .kp { color: #fb660a }
.chroma .kr { color: #fb660a; font-weight: bold }
.chroma .kt { color: #cdcaa9; font-weight: bold }
.chroma .na { color: #ff0086; font-weight: bold }
.chroma .no { color: #0086d2 }
.chroma .nf { color: #ff0086; font-weight: bold }
.chroma .nt { color: #fb660a; font-weight: bold }
.chroma .nv { color: #fb660a }
.chroma .s { color: #0086d2 }
.chroma .sa { color: #0086d2 }
.chroma .sb { color: #0086d2 }
.chroma .sc { color: #0086d2 }
.chroma .dl { color: #0086d2 }
.chroma .sd { color: #0086d2 }
.chroma .s2 { color: #0086d2 }
.chroma .se { color: #0086d2 }
.chroma .sh { color: #0086d2 }
.chroma .si { color: #0086d2 }
.chroma .sx { color: #0086d2 }
.chroma .sr { color: #0086d2 }
.chroma .s1 { color: #0086d2 }
.chroma .ss { color: #0086d2 }
.chroma .m { color: #0086f7; font-weight: bold }
.chroma .mb { color: #0086f7; font-weight: bold }
.chroma .mf { color: #0086f7; font-weight: bold }
.chroma .mh { color: #0086f7; font-weight: bold }
.chroma .mi { color: #0086f7; font-weight: bold }
.chroma .il { color: #0086f7; font-weight: bold }
.chroma .mo { color: #0086f7; font-weight: bold }
.chroma .c { color: #008800; background-color: #0f140f; font-style: italic }
.chroma .ch { color: #008800; background-color: #0f140f; font-style: italic }
.chroma .cm { color: #008800; background-color: #0f140f; font-style: italic }
.chroma .c1 { color: #008800; background-color: #0f140f; font-style: italic }
.chroma .cs { color: #008800; background-color: #0f140f; font-style: italic }
.chroma .cp { color: #ff0007; background-color: #0f140f; font-weight: bold; font-style: italic }
.chroma .cpf { color: #ff0007; background-color: #0f140f; font-weight: bold; font-style: italic }
.chroma .gh { font-weight: bold }
.chroma .go { color: #444444; background-color: #222222 }
.chroma .gu { font-weight: bold }
.chroma .w { color: #888888 }

View File

@ -11,11 +11,23 @@ footer {
padding: 1rem 3rem;
}
figure {
figcaption {
font-style: italic;
}
img {
max-width: 100%;
}
}
#content {
main {
background-color: rgb(24, 26, 27);
margin: 3% 10%;
padding: 3%;
article {
max-width: 85%;
}
}
a:hover %headings {
text-decoration: underline;

View File

@ -1,5 +1,5 @@
defaultContentLanguage: en
# enableInlineShortcodes: true
enableInlineShortcodes: true
enableRobotsTXT: true
enableGitInfo: true
enableEmoji: true

View File

@ -4,10 +4,10 @@ draft: false
aliases: []
categories: ['meta']
series: []
tags: ['Info','Meta']
tags: ['info','meta']
toc: false
title: Siverts Tech Adventure Blog
description: Landing page for Sivers Tech Adventure Blog!
description: Landing page for Siverts Tech Adventure Blog!
---
Here you are welcome to take a look at all my blog posts! :cyclone:

View File

@ -34,6 +34,10 @@ Here are lists of stuff I'll be writing about here;
- Mikrotik :package:
- Cisco Meraki :cloud:
### Azure
- App Registration :rocket:
- Active Directory :dizzy:
### The WHM saga (shortie)
- Wordpress :eyes:
- cPanel :shit:

View File

@ -0,0 +1,11 @@
---
date: 2022-06-07T07:15:24Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Ansible
description:
---

View File

@ -0,0 +1,69 @@
---
date: 2022-05-27T15:05:05Z
draft: false
aliases: []
categories: ['documentation']
series: ['apprentice']
tags: ['javascript']
chroma: true
toc: true
title: Azure App Registration
description: How to register apps that consume the Microsoft API's in Azure
---
You can find the App Registrations in Azure under Azure AD or directly by search.
Once there you can click the "New registration" button on the top left.
Then you'll need to fill in name, account types and optionally a redirect URI.
{{< img src="apprentice/azure/app-registry.png" caption="The Azure App Registration page" >}}
The first thing to do now is "Branding & properties"... haha.
The app authenticates towards Microsoft with either a certificate or app secrets.
So the actual first thing to do is to go over the "Authentication" tab, just check that all looks good.
## Microsoft Partner Network ID
This is needed for newly created apps after 9th of November 2020 to prevent abuse.
For this you'll need to add a "verified publisher domain" to the Azure Active Directory.
This is the same as "Custom domain names" in Azure AD.
They're usually added by TXT or MX DNS records.
But may be added pretty easily with a simple .well-known/ http challenge.
Although when doing the http challenge the domain won't become a custom domain name for the Azure AD tenant.
But rather bound to the specific app in question.
After that the actual MPN ID comes from the MPN, Microsoft Partner Network.
To get it you'll need to go to the [Microsoft Partner Center](https://partner.microsoft.com/) and register your organization.
You'll get verified after a week or two and then able to find this MPN ID under Account settings > Organization profile > Identifiers in the [Microsoft Partner Center](https://partner.microsoft.com/).
If you ever need to do this then [this](https://docs.microsoft.com/en-us/azure/active-directory/develop/troubleshoot-publisher-verification) may be very useful.
## Certificates & secrets
After that go to "Certificates & secrets".
Microsoft always recommends using certificates for getting access codes.
But the normal secrets are easier to configure.
Using certificates is best if your app has good support so that all you need to do is download a cert from the server and upload that to Azure.
So either do that or add a "New client secret".
The client secrets will have both the secret and an id, both are needed for authorization.
When you create these you'll need to store them safely and put them wherever the app gets them from.
## API permissions
And the last thing we need to configure in Azure are the API permissions for the app.
When adding a permission for the app you'll first need to choose what API you need access to.
And then what permissions that are needed for that API.
For apps that integrate with Microsoft services the "Microsoft Graph" API is likely where you'll find most needed permissions.
There is also the difference of "Application" and "Delegated" permissions.
The Application permissions is for the app itself and need to be granted by the owner of the app.
Whereas Delegated permissions are the ones that add stuff to the consent form, these lets the app do API requests on behalf of the end user and need to be granted by the end user or through admin consent.
{{< img src="apprentice/azure/api-permissions.png" caption="Azure API permissions" >}}
## Service principals
Now to the hard part I guess.
You'll need a "service principal" for the app in your tenant to authenticate with it.
This will get created on first login if it's not done already.
Automatic creation happens when you get that consent thing after logging in telling the end user what permissions the app requires.
If it's a tenant admin that's logging in that person may click the check for granting the permissions "On behalf of Organization, this is "admin consent" and makes it so individual users in that tenant don't need to consent when logging in.
Small and simple powershell script for adding the "service principal" to a tenant;
{{< highlight powershell >}}{{% asset "/apprentice/azure/service-principal.ps1" %}}{{< /highlight >}}

View File

@ -0,0 +1,13 @@
---
date: 2022-05-25T09:50:13Z
draft: true
aliases: []
categories: ['apprentice', 'indices', 'meta']
series: ['apprentice']
tags: ['expose','meta']
toc: true
title: My terrible Apprentice experience!
description: Here I'm going to write about my terrible time as an IT apprentice in two different small Norwegian companies. First one does web hosting, second runs Captive Portal services.
---

View File

@ -0,0 +1,11 @@
---
date: 2022-05-25T09:54:01Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Sircon
description:
---

View File

@ -0,0 +1,11 @@
---
date: 2022-05-25T09:54:05Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Skylabs
description:
---

View File

@ -0,0 +1,11 @@
---
date: 2022-06-07T07:15:31Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Freeradius
description:
---

View File

@ -1,11 +1,77 @@
---
date: 2022-05-25T09:14:23Z
draft: true
draft: false
aliases: []
categories: ['various']
categories: ['documentation']
series: ['apprentice']
tags: ['various']
tags: ['javascript']
chroma: true
toc: true
title: Handlebars.js
description:
---
description: Handlebars.js is a (HTML) templating engine that runs mainly in the browser, but may also run on any server that has node.js installed.
docs:
- url: https://handlebarsjs.com/guide/
name: Handlebars official guide
---
Handlebars.js is a templating engine like jinja2, but entirely in JavaScript.
Personally I've only found pug templates very nice to work with as I love the minimal syntax.
What makes handlebars cool is it's ability to render templates both server and client side,
if you're running node.js on the server.
Running it in the frontend is super easy, check this example from the handlebars docs;
{{< highlight html >}}<!-- Include Handlebars from a CDN -->
<script src='https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js'></script>
<script>
// compile the template
var template = Handlebars.compile("Handlebars <b>{{doesWhat}}</b>");
// execute the compiled template and print the output to the console
console.log(template({ doesWhat: "rocks!" }));
</script>{{< /highlight >}}
## Basics
The arguments of this template function can be accessed within curly braces and supports full js objects that may be accessed with dot notation just like you'd expect.
The "evaluation context" may be switched using "{{#with something}}{{/with}}" or "{{#each something}}{{/each}}" for looping over some list.
There is also template comments using the syntax "{{! }}" or "{{!-- --}}" to allow "mustaches like }}".
Handlebars comments will be stripped when rendering, but html comments passes through.
## Helpers and Partials
Handlebars helpers enable you to register javascript functions that may run inside templates.
To register a helper run;
{{< highlight js "lineNos=false" >}}Handlebars.registerHelper('name', function (string) {return 'SomeString'}){{< /highlight >}}
This function may use the evaluation context as "this" within the function.
Or to make it a block helper, take two arguments;
{{< highlight js "lineNos=false" >}}Handlebars.registerHelper('name', function (items, options) {return 'SomeString'}){{< /highlight >}}
The normal helpers are called by "{{helpername [args...]}}".
Block helpers switch the evaluation context.
The helper function for these always take options and usually context as arguments.
You can also register partials like helpers with;
{{< highlight js "lineNos=false" >}}Handlebars.registerPartial('name', 'template string with {{blocks}}'){{< /highlight >}}
It should be noted that handlebars by default html escapes all results from these blocks/helpers.
If you want to avoid this then "triple mustaches" is what you're looking for.
Calling any helper function like "{{{helpername}}}" will bypass the html escaping.
## Examples
This script is running on this page;
{{< highlight js >}}{{% asset "apprentice/handlebars.js" %}}{{< /highlight >}}
### Output
{{< raw >}}
<div id='example-out'></div>
<!-- <script src='https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.slim.min.js'></script> -->
<script src='https://cdn.jsdelivr.net/npm/handlebars@4.7.7/dist/handlebars.js'></script>
{{< script "apprentice/handlebars.js" >}}
{{< /raw >}}

View File

@ -0,0 +1,11 @@
---
date: 2022-06-07T07:14:28Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Meraki
description:
---

View File

@ -0,0 +1,14 @@
---
date: 2022-06-07T07:15:51Z
draft: true
aliases: []
categories: ['various']
series: []
tags: ['various']
toc: true
title: Security
description:
---
Apache .htconfig fuckery, WP bug.
Ansible and intrauser ssh keys.

View File

@ -2,10 +2,12 @@
date: 2022-05-25T09:14:33Z
draft: true
aliases: []
categories: ['various']
categories: ['documentation']
series: ['apprentice']
tags: ['various']
tags: ['python']
toc: true
title: SQLAlchemy
description:
---
---
[SQLAlchemy docs](https://docs.sqlalchemy.org/en/14/orm/quickstart.html)

View File

@ -0,0 +1 @@
<a href='{{ .Destination | safeURL }}' target='_blank'>{{ .Text | safeHTML }}</a>

View File

@ -28,11 +28,11 @@
{{ end }}
{{ block "head" . }}{{ end }}
{{ if .Param "chroma" }}
{{ with resources.Get "chroma.scss" | toCSS | postCSS | minify | fingerprint | resources.PostProcess }}
{{ with resources.Get "chroma.scss" | toCSS | minify | fingerprint | resources.PostProcess }}
<link href='{{ .RelPermalink }}' integrity="{{ .Data.Integrity }}" rel='stylesheet'>
{{ end }}
{{ end }}
{{ with resources.Get "main.scss" | toCSS | postCSS | minify | fingerprint | resources.PostProcess }}
{{ with resources.Get "main.scss" | toCSS | minify | fingerprint | resources.PostProcess }}
<link href='{{ .RelPermalink }}' integrity="{{ .Data.Integrity }}" rel='stylesheet'>
{{ end }}
</head>

View File

@ -4,6 +4,9 @@
<h1>{{ .Title | humanize }}</h1>
</header>
{{ .Content }}
{{if gt (len .Pages) 0}}
<br />
<h3>Posts</h3>
<ul class='contents'>
{{ range .Pages }}
<br />
@ -12,5 +15,6 @@
</a>
{{ end }}
</ul>
{{ end }}
</article>
{{ end }}

View File

@ -1,7 +1,9 @@
<nav id='navbar'>
<ul class='top-nav'>
<li><a href='/{{ .Language.Lang }}'>{{ site.Title }}</a></li>
<li><a href='/{{ if ne .Language.Lang "en" }}{{ .Language.Lang }}{{ end }}'>{{ site.Title }}</a></li>
{{ if gt (len .AllTranslations) 1 }}
{{ partial "i18n/nav.html" . }}
{{ end }}
<div class='link-group'>
{{ $currentPage := . }}
{{ range .Site.Menus.main }}

View File

@ -1,14 +1,21 @@
<aside id='meta'>
<header>
<h4>{{ or (.Param "tit") .Title }}</h4>
<h4>{{ or (.Param "tit") .Title | humanize }}</h4>
<p>
{{ i18n "readingTime" .ReadingTime }}.
{{ i18n "wordCount" .WordCount }}.
</p>
{{ with .Param "git" }}
<p>Check out the git repo; <a href='{{ .url }}'>{{ .name }}</a>!</p>
{{ end }}
</header>
{{ if .Param "docs" }}
<h6>Documentation:</h6>
<ul>
{{ range .Param "docs" }}
<li><a href='{{ .url }}' target='_blank'>{{ .name }}</a></li>
{{ end }}</ul>{{ end }}
{{ with .Param "git" }}
<p>Check out the git repo; <a href='{{ .url }}'>{{ .name }}</a>!</p>
{{ end }}
<h6>Table of Contents:</h6>
{{ .TableOfContents }}
{{ partial "i18n/list.html" . }}
</aside>

View File

@ -0,0 +1 @@
{{ with resources.Get (.Get 0) }}{{ .Content }}{{ end }}

View File

@ -0,0 +1,5 @@
{{ $opts := slice "lineNos=table" "tabWidth=2" "noClasses=false" "style=fruity" }}
{{ if .Get 1 }}
{{ $opts = $opts | append (split (.Get 1) ",") }}
{{ end }}
{{ transform.Highlight (htmlUnescape .Inner) (.Get 0) (delimit $opts ",") }}

View File

@ -0,0 +1,20 @@
<figure {{ with .Get "class" }}class='{{.}}'{{ end }}>
{{ with resources.Get (.Get "src") | fingerprint }}
<a href='{{ with $.Get "link" }}{{ . }}{{ else }}{{ .RelPermalink }}{{ end }}' target='_blank'>
<img src='{{ .RelPermalink }}' integrity='{{ .Data.Integrity }}'
{{ if or ($.Get "alt") ($.Get "caption") }}alt='{{ with $.Get "alt" }}{{ . }}
{{ else }}{{ $.Get "caption" }}{{ end }}'{{ end }} />
</a>
{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }}
<figcaption>{{ if isset .Params "title" }}
<h4>{{ .Get "title" }}</h4>{{ end }}
{{ if or (.Get "caption") (.Get "attr") }}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink" }}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>

View File

@ -0,0 +1 @@
{{ .Inner }}

View File

@ -0,0 +1,3 @@
{{ with resources.Get (.Get 0) | fingerprint }}
<script src='{{ .RelPermalink }}' integrity='{{ .Data.Integrity }}'></script>
{{ end }}