Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package authcontrol

type ServiceConfig struct {
URL string `toml:"url"`
// Base URL of the service.
URL string `toml:"url"`
// JWTSecret is used to create dynamic JWT tokens for S2S auth.
JWTSecret string `toml:"jwt_secret"`
AccessKey string `toml:"access_key"`
// JWTToken is a static JWT token for S2S auth.
JWTToken string `toml:"jwt_token"`
}
17 changes: 6 additions & 11 deletions s2s.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import (
)

type S2SClientConfig struct {
// JWTToken is the static JWT token used for authentication.
JWTToken string
// JWTSecret is the secret key used to dynamically create JWT BEARER token for authorization.
JWTSecret string
// Service is used in the service claim of the JWT token.
// Service defines the "service" claim in the JWT token.
Service string
// AccessKey is an optional access key used for authentication.
AccessKey string
// DebugRequests enables logging of HTTP requests.
// JWTSecret is used to create dynamic JWT tokens for S2S auth.
JWTSecret string
// JWTToken is a static JWT token for S2S auth.
JWTToken string
// DebugRequests enables HTTP request logging.
DebugRequests bool
}

Expand All @@ -44,9 +42,6 @@ func S2SClient(cfg *S2SClientConfig) *http.Client {
transport.If(cfg.JWTToken != "",
transport.SetHeader("Authorization", "BEARER "+cfg.JWTToken),
),
transport.If(cfg.AccessKey != "",
transport.SetHeader("X-Access-Key", cfg.AccessKey),
),
transport.If(cfg.DebugRequests,
transport.LogRequests(transport.LogOptions{Concise: true, CURL: true}),
),
Expand Down