diff --git a/auth.go b/auth.go index fd8f133..ea57dd4 100644 --- a/auth.go +++ b/auth.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "crypto/tls" diff --git a/auth_test.go b/auth_test.go index f327704..529589a 100644 --- a/auth_test.go +++ b/auth_test.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "context" diff --git a/config.go b/config.go index 43defa0..b18ee1b 100644 --- a/config.go +++ b/config.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "fmt" diff --git a/config_test.go b/config_test.go index f85b4c8..f863ef5 100644 --- a/config_test.go +++ b/config_test.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "bytes" diff --git a/doc.go b/doc.go index fc4062e..ea1aab8 100644 --- a/doc.go +++ b/doc.go @@ -4,5 +4,5 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -// Package auth provides high-level helpers and basic objects for authN/authZ. -package auth +// Package authkit provides high-level helpers and basic objects for authN/authZ. +package authkit diff --git a/example_test.go b/example_test.go index f4e7405..b97fcbe 100644 --- a/example_test.go +++ b/example_test.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "context" diff --git a/middleware.go b/middleware.go index d6e6f72..4eab051 100644 --- a/middleware.go +++ b/middleware.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "context" @@ -94,6 +94,11 @@ func WithJWTAuthMiddlewareTokenIntrospector(tokenIntrospector TokenIntrospector) // JWTAuthMiddleware is a middleware that does authentication // by Access Token from the "Authorization" HTTP header of incoming request. +// errorDomain is used for error responses. It is usually the name of the service that uses the middleware, +// and its goal is distinguishing errors from different services. +// It helps to understand where the error occurred and what service caused it. For example, if the "Authorization" HTTP header is missing, the middleware will return 401 with the following response body: +// +// {"error": {"domain": "MyService", "code": "bearerTokenMissing", "message": "Authorization bearer token is missing."}} func JWTAuthMiddleware(errorDomain string, jwtParser JWTParser, opts ...JWTAuthMiddlewareOption) func(next http.Handler) http.Handler { var options jwtAuthMiddlewareOpts for _, opt := range opts { diff --git a/middleware_test.go b/middleware_test.go index 45c58c5..0998e58 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -4,7 +4,7 @@ Copyright © 2024 Acronis International GmbH. Released under MIT license. */ -package auth +package authkit import ( "context"