mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 07:37:33 +02:00
internal/logs: make non error conditions less scary in logs
internal/metrics: simplified struct definition with fmt -s. internal/metrics: added full path to package name.
This commit is contained in:
parent
2172d64205
commit
4d4293fc46
6 changed files with 18 additions and 23 deletions
|
@ -8,22 +8,22 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/internal/metrics"
|
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/authenticate"
|
"github.com/pomerium/pomerium/authenticate"
|
||||||
"github.com/pomerium/pomerium/authorize"
|
"github.com/pomerium/pomerium/authorize"
|
||||||
"github.com/pomerium/pomerium/internal/config"
|
"github.com/pomerium/pomerium/internal/config"
|
||||||
"github.com/pomerium/pomerium/internal/https"
|
"github.com/pomerium/pomerium/internal/https"
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
|
"github.com/pomerium/pomerium/internal/metrics"
|
||||||
"github.com/pomerium/pomerium/internal/middleware"
|
"github.com/pomerium/pomerium/internal/middleware"
|
||||||
"github.com/pomerium/pomerium/internal/urlutil"
|
"github.com/pomerium/pomerium/internal/urlutil"
|
||||||
"github.com/pomerium/pomerium/internal/version"
|
"github.com/pomerium/pomerium/internal/version"
|
||||||
pbAuthenticate "github.com/pomerium/pomerium/proto/authenticate"
|
pbAuthenticate "github.com/pomerium/pomerium/proto/authenticate"
|
||||||
pbAuthorize "github.com/pomerium/pomerium/proto/authorize"
|
pbAuthorize "github.com/pomerium/pomerium/proto/authorize"
|
||||||
"github.com/pomerium/pomerium/proxy"
|
"github.com/pomerium/pomerium/proxy"
|
||||||
"github.com/spf13/viper"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var versionFlag = flag.Bool("version", false, "prints the version")
|
var versionFlag = flag.Bool("version", false, "prints the version")
|
||||||
|
@ -90,7 +90,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if srv, err := startRedirectServer(opt.HTTPRedirectAddr); err != nil {
|
if srv, err := startRedirectServer(opt.HTTPRedirectAddr); err != nil {
|
||||||
log.Debug().Err(err).Msg("cmd/pomerium: http redirect server not started")
|
log.Debug().Str("cause", err.Error()).Msg("cmd/pomerium: http redirect server not started")
|
||||||
} else {
|
} else {
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package metrics
|
package metrics // import "github.com/pomerium/pomerium/internal/metrics"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package metrics
|
package metrics // import "github.com/pomerium/pomerium/internal/metrics"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package metrics
|
package metrics // import "github.com/pomerium/pomerium/internal/metrics"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -6,13 +6,11 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/internal/middleware/responsewriter"
|
"go.opencensus.io/stats"
|
||||||
|
"go.opencensus.io/stats/view"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
|
|
||||||
"go.opencensus.io/stats/view"
|
"github.com/pomerium/pomerium/internal/middleware/responsewriter"
|
||||||
|
|
||||||
"go.opencensus.io/stats"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -26,14 +24,14 @@ var (
|
||||||
httpRequestDuration = stats.Int64("http_server_request_duration_ms", "HTTP Request duration in ms", "ms")
|
httpRequestDuration = stats.Int64("http_server_request_duration_ms", "HTTP Request duration in ms", "ms")
|
||||||
|
|
||||||
views = []*view.View{
|
views = []*view.View{
|
||||||
&view.View{
|
{
|
||||||
Name: httpRequestCount.Name(),
|
Name: httpRequestCount.Name(),
|
||||||
Measure: httpRequestCount,
|
Measure: httpRequestCount,
|
||||||
Description: httpRequestCount.Description(),
|
Description: httpRequestCount.Description(),
|
||||||
TagKeys: []tag.Key{keyService, keyHost, keyMethod, keyStatus},
|
TagKeys: []tag.Key{keyService, keyHost, keyMethod, keyStatus},
|
||||||
Aggregation: view.Count(),
|
Aggregation: view.Count(),
|
||||||
},
|
},
|
||||||
&view.View{
|
{
|
||||||
Name: httpRequestDuration.Name(),
|
Name: httpRequestDuration.Name(),
|
||||||
Measure: httpRequestDuration,
|
Measure: httpRequestDuration,
|
||||||
Description: httpRequestDuration.Description(),
|
Description: httpRequestDuration.Description(),
|
||||||
|
@ -46,7 +44,7 @@ var (
|
||||||
100000,
|
100000,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
&view.View{
|
{
|
||||||
Name: httpResponseSize.Name(),
|
Name: httpResponseSize.Name(),
|
||||||
Measure: httpResponseSize,
|
Measure: httpResponseSize,
|
||||||
Description: httpResponseSize.Description(),
|
Description: httpResponseSize.Description(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package metrics
|
package metrics // import "github.com/pomerium/pomerium/internal/metrics"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
|
@ -229,16 +229,13 @@ func isCORSPreflight(r *http.Request) bool {
|
||||||
func (p *Proxy) Proxy(w http.ResponseWriter, r *http.Request) {
|
func (p *Proxy) Proxy(w http.ResponseWriter, r *http.Request) {
|
||||||
if !p.shouldSkipAuthentication(r) {
|
if !p.shouldSkipAuthentication(r) {
|
||||||
s, err := p.restStore.LoadSession(r)
|
s, err := p.restStore.LoadSession(r)
|
||||||
if err != nil {
|
// if authorization bearer token does not exist or fails, use cookie store
|
||||||
log.FromRequest(r).Debug().Err(err).Msg("proxy: no bearer auth token found")
|
if err != nil || s == nil {
|
||||||
}
|
|
||||||
|
|
||||||
if s == nil {
|
|
||||||
s, err = p.sessionStore.LoadSession(r)
|
s, err = p.sessionStore.LoadSession(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err {
|
switch err {
|
||||||
case http.ErrNoCookie, sessions.ErrLifetimeExpired, sessions.ErrInvalidSession:
|
case http.ErrNoCookie, sessions.ErrLifetimeExpired, sessions.ErrInvalidSession:
|
||||||
log.FromRequest(r).Debug().Err(err).Msg("proxy: invalid session")
|
log.FromRequest(r).Debug().Str("cause", err.Error()).Msg("proxy: invalid session, start auth process")
|
||||||
p.sessionStore.ClearSession(w, r)
|
p.sessionStore.ClearSession(w, r)
|
||||||
p.OAuthStart(w, r)
|
p.OAuthStart(w, r)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue