write readme and add license

This commit is contained in:
Milo Schwartz 2024-12-26 12:40:52 -05:00
parent bf764c2b17
commit 64f366556a
No known key found for this signature in database
4 changed files with 60 additions and 11 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Fossorial LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,3 +1,35 @@
# badger
# Badger Plugin for Traefik with Pangolin Integration
Middleware auth bouncer for Pangolin
Badger is a middleware plugin designed to work with the Traefik reverse proxy in conjunction with [Pangolin](https://github.com/fosrl/pangolin), a multi-tenant tunneled reverse proxy server and management interface with identity and access management. Badger acts as an authentication bouncer, ensuring only authenticated and authorized requests are allowed through the proxy.
This plugin is **required** to be configured alongside [Pangolin](https://github.com/fosrl/pangolin) to enforce secure authentication and session management.
## Installation
Learn how to set up [Pangolin](https://github.com/fosrl/pangolin) and Badger in the [Pangolin Documentation](https://github.com/fosrl/pangolin).
---
## Configuration
Badger requires the following configuration parameters to be specified in your [Traefik configuration file](https://doc.traefik.io/traefik/getting-started/configuration-overview/). These coincide with the separate [Pangolin](https://github.com/fosrl/pangolin) configuration file.
### Configuration Options
```yaml
apiBaseUrl: "http://localhost:3001/api/v1"
userSessionCookieName: "session"
resourceSessionCookieName: "resource_session"
```
---
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
## Contact
Please contact us at [support@fossorial.io](mailto:support@fossorial.io).

2
go.mod
View file

@ -1,3 +1,3 @@
module github.com/fosrl/badger
go 1.21.5
go 1.23.1

12
main.go
View file

@ -32,10 +32,6 @@ type VerifyResponse struct {
} `json:"data"`
}
func CreateConfig() *Config {
return &Config{}
}
type Badger struct {
next http.Handler
name string
@ -44,6 +40,10 @@ type Badger struct {
resourceSessionCookieName string
}
func CreateConfig() *Config {
return &Config{}
}
func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
return &Badger{
next: next,
@ -76,8 +76,6 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return
}
fmt.Println("verify request", string(jsonData))
resp, err := http.Post(verifyURL, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
http.Error(rw, "Internal Server Error", http.StatusInternalServerError)
@ -107,8 +105,6 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return
}
fmt.Println("authorized")
p.next.ServeHTTP(rw, req)
}