From c7471a2c6d956a5d5d64d9f08c26c743f1c840d7 Mon Sep 17 00:00:00 2001 From: Vasily Tsybenko Date: Fri, 4 Oct 2024 17:20:56 +0300 Subject: [PATCH] Rename root package: auth -> authkit --- auth.go | 2 +- auth_test.go | 2 +- config.go | 2 +- config_test.go | 2 +- doc.go | 4 ++-- example_test.go | 2 +- middleware.go | 8 +++++++- middleware_test.go | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) 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..1f3ef81 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,12 @@ 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"