31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
// Package v1 composes the product's first public HTTP contract.
|
|
package v1
|
|
|
|
import (
|
|
"git.sendico.io/tech/sxchnge/product/app/api"
|
|
auth "git.sendico.io/tech/sxchnge/product/auth/http/v1"
|
|
"git.sendico.io/tech/sxchnge/product/auth/http/v1/public"
|
|
identity "git.sendico.io/tech/sxchnge/product/identity/http/v1"
|
|
paymenthttp "git.sendico.io/tech/sxchnge/product/payments/http/v1"
|
|
factors "git.sendico.io/tech/sxchnge/product/twofactor/http/v1"
|
|
"git.sendico.io/tech/sxchnge/shared/errors"
|
|
)
|
|
|
|
func Install(scope api.Scope, deps *api.Dependencies) error {
|
|
if deps == nil || deps.Stores == nil {
|
|
return merrors.InvalidArgument("v1 auth dependencies are required")
|
|
}
|
|
flows := public.Flows{Onboarding: deps.Auth}
|
|
if deps.Factors != nil {
|
|
flows.Factors = deps.Factors
|
|
}
|
|
// Signature is resolved at bootstrap, not by each version from the environment.
|
|
routes := auth.Install(scope.Logger, scope.Router, "", deps.Stores.Accounts, deps.Stores.RefreshTokens, deps.Stores.LoginAttempts, &deps.Token, deps.Signature, deps.LoginLimits, flows)
|
|
if deps.Factors != nil {
|
|
factors.Install(routes, deps.Factors, scope.Logger)
|
|
}
|
|
identity.Install(routes, deps.Identity, scope.Logger)
|
|
paymenthttp.Install(routes, deps.Payments, scope.Logger)
|
|
return nil
|
|
}
|