Compare commits
3 Commits
v2.0.0-rc3
...
v2.0.0
Author | SHA1 | Date | |
---|---|---|---|
2c148d3a23 | |||
d33ecc0654 | |||
41a3f2a5a9 |
16
README.md
16
README.md
@ -4,7 +4,6 @@
|
||||
|
||||
A minimal forward authentication service that provides Google oauth based login and authentication for the [traefik](https://github.com/containous/traefik) reverse proxy/load balancer.
|
||||
|
||||
|
||||
## Why?
|
||||
|
||||
- Seamlessly overlays any http service with a single endpoint (see: `url-path` in [Configuration](#configuration))
|
||||
@ -16,6 +15,7 @@ A minimal forward authentication service that provides Google oauth based login
|
||||
|
||||
# Contents
|
||||
|
||||
- [Releases](#releases)
|
||||
- [Usage](#usage)
|
||||
- [Simple](#simple)
|
||||
- [Advanced](#advanced)
|
||||
@ -32,6 +32,16 @@ A minimal forward authentication service that provides Google oauth based login
|
||||
- [Copyright](#copyright)
|
||||
- [License](#license)
|
||||
|
||||
## Releases
|
||||
|
||||
We recommend using the `2` tag on docker hub.
|
||||
|
||||
You can also use the latest incremental releases found on [docker hub](https://hub.docker.com/r/thomseddon/traefik-forward-auth/tags) and [github](https://github.com/thomseddon/traefik-forward-auth/releases).
|
||||
|
||||
#### Upgrade Guide
|
||||
|
||||
v2 was released in June 2019, whilst this is fully backwards compatible, a number of configuration options were modified, please see the [upgrade guide](https://github.com/thomseddon/traefik-forward-auth/wiki/v2-Upgrade-Guide) to prevent warnings on startup and ensure you are using the current configuration.
|
||||
|
||||
## Usage
|
||||
|
||||
#### Simple:
|
||||
@ -96,10 +106,6 @@ Create a new project then search for and select "Credentials" in the search bar.
|
||||
|
||||
Click "Create Credentials" > "OAuth client ID". Select "Web Application", fill in the name of your app, skip "Authorized JavaScript origins" and fill "Authorized redirect URIs" with all the domains you will allow authentication from, appended with the `url-path` (e.g. https://app.test.com/_oauth)
|
||||
|
||||
#### Upgrade Guide
|
||||
|
||||
v2 was released in April 2019, whilst this is fully backwards compatible, a number of configuration options were modified, please see the [upgrade guide](https://github.com/thomseddon/traefik-forward-auth/wiki/v2-Upgrade-Guide) to prevent warnings on startup and ensure you are using the current configuration.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Overview
|
||||
|
@ -176,16 +176,15 @@ func (c *Config) parseUnknownFlag(option string, arg flags.SplitArgument, args [
|
||||
// Parse rules in the format "rule.<name>.<param>"
|
||||
parts := strings.Split(option, ".")
|
||||
if len(parts) == 3 && parts[0] == "rule" {
|
||||
// Get or create rule
|
||||
rule, ok := c.Rules[parts[1]]
|
||||
if !ok {
|
||||
rule = NewRule()
|
||||
c.Rules[parts[1]] = rule
|
||||
// Ensure there is a name
|
||||
name := parts[1]
|
||||
if len(name) == 0 {
|
||||
return args, errors.New("route name is required")
|
||||
}
|
||||
|
||||
// Get value, or pop the next arg
|
||||
val, ok := arg.Value()
|
||||
if !ok {
|
||||
if !ok && len(args) > 1 {
|
||||
val = args[0]
|
||||
args = args[1:]
|
||||
}
|
||||
@ -204,6 +203,13 @@ func (c *Config) parseUnknownFlag(option string, arg flags.SplitArgument, args [
|
||||
}
|
||||
}
|
||||
|
||||
// Get or create rule
|
||||
rule, ok := c.Rules[name]
|
||||
if !ok {
|
||||
rule = NewRule()
|
||||
c.Rules[name] = rule
|
||||
}
|
||||
|
||||
// Add param value to rule
|
||||
switch parts[2] {
|
||||
case "action":
|
||||
@ -250,7 +256,7 @@ func (c *Config) Validate() {
|
||||
}
|
||||
|
||||
if c.Providers.Google.ClientId == "" || c.Providers.Google.ClientSecret == "" {
|
||||
log.Fatal("google.providers.client-id, google.providers.client-secret must be set")
|
||||
log.Fatal("providers.google.client-id, providers.google.client-secret must be set")
|
||||
}
|
||||
|
||||
// Check rules
|
||||
|
@ -98,6 +98,29 @@ func TestConfigParseUnknownFlags(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigParseRuleError(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
// Rule without name
|
||||
_, err := NewConfig([]string{
|
||||
"--rule..action=auth",
|
||||
})
|
||||
if assert.Error(err) {
|
||||
assert.Equal("route name is required", err.Error())
|
||||
}
|
||||
|
||||
// Rule without value
|
||||
c, err := NewConfig([]string{
|
||||
"--rule.one.action=",
|
||||
})
|
||||
if assert.Error(err) {
|
||||
assert.Equal("route param value is required", err.Error())
|
||||
}
|
||||
// Check rules
|
||||
assert.Equal(map[string]*Rule{}, c.Rules)
|
||||
}
|
||||
|
||||
|
||||
func TestConfigFlagBackwardsCompatability(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
c, err := NewConfig([]string{
|
||||
|
Reference in New Issue
Block a user