Simple web content/proxy server that embodies enterprise zero trust security

pswa - Protected Static Web App

Introduction

pswa is a simple web content/proxy server which is suitable for various static web apps.

Features

  • Available as a Docker image ghcr.io/yaegashi/pswa
  • User authentication with Azure Active Directory (supporting other OIDC providers is planned)
  • Flexible authorization using roles based on the groups claim in each user's ID token
  • Support rewriting, redirecting, and proxying on incoming requests
  • Support navigation fallback rewriting suitable for single page apps
  • pswa.config.json - JSON configuration file that mimics staticwebapp.config.json

Configuration

Azure AD app registration

  • Register an Azure AD application with Azure Portal.
  • Collect tenant ID and client ID for PSWA_TENANT_URI and PSWA_CLIENT_ID settings respectively.
  • Generate a client secret string for PSWA_CLIENT_SECRET settings.
  • Add <YOUR-APP-URL>/.auth/login/aad/callback to the application redirect URIs. It's also for PSWA_REDIRECT_URI settings.
  • Modify the application's manifest to set groupMembershipClaims to SecurityGroup. It's required to expose user's member groups in ID token. See the document for details.

Environment variable settings

Variable Description
PSWA_TENANT_ID Tenant ID of Azure AD
PSWA_CLIENT_ID Client ID registered in Azure AD
PSWA_CLIENT_SECRET Client secret generated in Azure AD
PSWA_REDIRECT_URI Rediect URI specifed in Azure AD
PSWA_SESSION_KEY Ramdom string to encrypt values in the cookie session store
PSWA_LISTEN Server address to listen. Default: :8080
PSWA_WWWROOT Web content root directory. Default: /home/site/wwwroot
PSWA_CONFIG Configuration file location. It's relative to PSWA_WWWROOT if not an absolute path. Default: pswa.config.json

Configuration file (pswa.config.json)

roles configuration is to define roles and its members. members are object IDs of Azure AD groups.

routes configuration is very similar to staticwebapp.config.json of Azure Static Web Apps.

{
  "routes": [
    {
      "route": "/admin/*",
      "allowedRoles": [
        "admin"
      ]
    },
    {
      "route": "/internal/*",
      "allowedRoles": [
        "authenticated"
      ]
    },
    {
      "route": "/pswa.config.json",
      "redirect": "/"
    }
  ],
  "roles": [
    {
      "role": "admin",
      "members": [
        "34a36796-6043-4dea-85e1-c6ad121a54d4",
        "06fe36df-51ab-49d9-aa3e-2b0034c2cbd1",
        "5bafeeac-804c-4ea4-95c6-11696535c8cb"
      ]
    }
  ]
}

Hacking

The following steps need docker, docker-compose, and hugo on your system.

Copy pswa-example.env to pswa.env and edit it as your environment settings:

$ cp pswa-example.env pswa.env
$ vi pswa.env

Edit pswa.config.json and run hugo to build a static web site in hugo/public:

$ vi hugo/static/pswa.config.json
$ hugo -s hugo

Build the container and run it with docker-compose:

$ docker-compose up --build
Attaching to pswa_pswa_1
pswa_1  | 2021/11/13 05:15:27 Listening on :8080

Open http://localhost:8080 with your web browser.

Owner
Similar Resources

Static file server that service content required by dan's services

Static file server that service content required by dan's services.

Jan 20, 2022

A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration

A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration

paddy 简介 paddy是一款单进程的独立运行的web server,基于golang的标准库net/http实现。 paddy提供以下功能: 直接配置http响应 目录文件服务器 proxy_pass代理 http反向代理 支持请求和响应插件 部署 编译 $ go build ./main/p

Oct 18, 2022

Fake server, Consumer Driven Contracts and help with testing performance from one configuration file with zero system dependencies and no coding whatsoever

Fake server, Consumer Driven Contracts and help with testing performance from one configuration file with zero system dependencies and no coding whatsoever

mockingjay server Mockingjay lets you define the contract between a consumer and producer and with just a configuration file you get: A fast to launch

Jan 6, 2023

An experimental Tor-Proxy serivce written in Go using Go-proxy and Go-libtor.

tor-proxy An experimental standalone tor-proxy service built with Go, using go-proxy, go-libtor and bine. This is a simple replacement to Tor's origin

Nov 9, 2022

mt-multiserver-proxy is a reverse proxy designed for linking multiple Minetest servers together

mt-multiserver-proxy mt-multiserver-proxy is a reverse proxy designed for linking multiple Minetest servers together. It is the successor to multiserv

Nov 17, 2022

Proxy - Minimalistic TCP relay proxy.

Proxy Minimalistic TCP relay proxy. Installation ensure you have go = 1.17 installed clone the repo cd proxy go install main.go Examples Listen on po

May 22, 2022

Http-logging-proxy - A HTTP Logging Proxy For Golang

http-logging-proxy HTTP Logging Proxy Description This project builds a simple r

Aug 1, 2022

Battlesnake-logging-proxy - A little proxy between the internet and your battlesnake

battlesnake-logging-proxy a little proxy between the internet and your battlesna

Feb 11, 2022
Related tags
“Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server!

Dear Port80 About The Project: “Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server! +---------------------

Jun 29, 2022
Wrapper for Lightning Network Daemon (lnd). It provides separate accounts with minimum trust for end users.

LndHub.go Wrapper for Lightning Network Daemon (lnd). It provides separate accounts with minimum trust for end users. LndHub compatible API implemente

Dec 21, 2022
Tcp-proxy - A dead simple reverse proxy server.

tcp-proxy A proxy that forwords from a host to another. Building go build -ldflags="-X 'main.Version=$(git describe --tags $(git rev-list --tags --max

Jan 2, 2022
llb - It's a very simple but quick backend for proxy servers. Can be useful for fast redirection to predefined domain with zero memory allocation and fast response.

llb What the f--k it is? It's a very simple but quick backend for proxy servers. You can setup redirect to your main domain or just show HTTP/1.1 404

Sep 27, 2022
Cert bound sts server - Certificate Bound Tokens using Security Token Exchange Server (STS)
Cert bound sts server - Certificate Bound Tokens using Security Token Exchange Server (STS)

Certificate Bound Tokens using Security Token Exchange Server (STS) Sample demonstration of Certificate Bound Tokens acquired from a Security Token Ex

Jan 2, 2022
IP2Proxy Go package allows users to query an IP address to determine if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.

IP2Proxy Go Package This package allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data

Sep 15, 2022
Brook is a cross-platform strong encryption and not detectable proxy. Zero-Configuration. Brook 是一个跨平台的强加密无特征的代理软件. 零配置.

Brook 中文 v20210401 [GUI] Block list(Ad Block) Bypass & Block rule [GUI] Forward DNS [GUI] OpenWrt GUI client [GUI] Fake DNS [CLI] $ brook tproxy Scrip

Jan 4, 2023
A simple tool to convert socket5 proxy protocol to http proxy protocol

Socket5 to HTTP 这是一个超简单的 Socket5 代理转换成 HTTP 代理的小工具。 如何安装? Golang 用户 # Required Go 1.17+ go install github.com/mritd/s2h@master Docker 用户 docker pull m

Jan 2, 2023
Use pingser to create client and server based on ICMP Protocol to send and receive custom message content.
Use pingser to create client and server based on ICMP Protocol to send and receive custom message content.

pingser Use pingser to create client and server based on ICMP Protocol to send and receive custom message content. examples source code: ./examples Us

Nov 9, 2022