Skip to content

Commit

Permalink
More auth fixses (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar committed Jan 8, 2021
1 parent bd1dd5e commit da99ef4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ The Service uses the following environment variables:
* `AUTH`: Sets the type of the auth service. `fake` (default) or `ticket`.
* `AUTH_KEY_TOKEN`: Key to sign the JWT auth tocken. Default `auth-dev-key`.
* `AUTH_KEY_COOKIE`: Key to sign the JWT auth cookie. Default `auth-dev-key`.
* `AUTH_SERVICE_HOST`: Host of the auth service. The default is `localhost`.
* `AUTH_SERVICE_PORT`: Port of the auth service. The default is `9004`.
* `AUTH_SERVICE_PROTOCOL`: Protocol of the auth servicer. The default is `http`.
* `AUTH_HOST`: Host of the auth service. The default is `localhost`.
* `AUTH_PORT`: Port of the auth service. The default is `9004`.
* `AUTH_PROTOCOL`: Protocol of the auth servicer. The default is `http`.
* `DEACTIVATE_PERMISSION`: Deactivate requests to the permission service. The
result is, that every user can see everything (Defaullt: `false`)
18 changes: 9 additions & 9 deletions cmd/autoupdate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func defaultEnv() map[string]string {
"MESSAGE_BUS_PORT": "6379",
"REDIS_TEST_CONN": "true",

"AUTH": "fake",
"AUTH_KEY_TOKEN": "auth-dev-key",
"AUTH_KEY_COOKIE": "auth-dev-key",
"AUTH_SERVICE_PROTOCOL": "http",
"AUTH_SERVICE_HOST": "localhost",
"AUTH_SERVICE_PORT": "9004",
"AUTH": "fake",
"AUTH_KEY_TOKEN": "auth-dev-key",
"AUTH_KEY_COOKIE": "auth-dev-key",
"AUTH_PROTOCOL": "http",
"AUTH_HOST": "localhost",
"AUTH_PORT": "9004",

"DEACTIVATE_PERMISSION": "false",
}
Expand Down Expand Up @@ -303,9 +303,9 @@ func buildAuth(env map[string]string, receiver auth.LogoutEventer, closed <-chan
fmt.Println("Auth with debug key")
}

protocol := env["AUTH_SERVICE_PROTOCOL"]
host := env["AUTH_SERVICE_HOST"]
port := env["AUTH_SERVICE_PORT"]
protocol := env["AUTH_PROTOCOL"]
host := env["AUTH_HOST"]
port := env["AUTH_PORT"]
url := protocol + "://" + host + ":" + port

fmt.Printf("Auth Service: %s\n", url)
Expand Down
4 changes: 2 additions & 2 deletions internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const pruneTime = 15 * time.Minute

const cookieName = "refreshId"
const authHeader = "Authentication"
const authPath = "/internal/auth/api/authenticate"
const authPath = "/internal/auth/authenticate"

// Auth authenticates a request against the auth service.
type Auth struct {
Expand Down Expand Up @@ -213,7 +213,7 @@ func (a *Auth) loadToken(w http.ResponseWriter, r *http.Request, payload jwt.Cla
}

func (a *Auth) refreshToken(ctx context.Context, token, cookie string) (string, error) {
req, err := http.NewRequestWithContext(ctx, "POST", a.authServiceURL, nil)
req, err := http.NewRequestWithContext(ctx, "POST", a.authServiceURL+authPath, nil)
if err != nil {
return "", fmt.Errorf("creating auth request: %w", err)
}
Expand Down

0 comments on commit da99ef4

Please sign in to comment.