Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AuthModules and AuthOrigins params to stack config #242

Merged
merged 3 commits into from
Aug 10, 2023
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
10 changes: 10 additions & 0 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ type Config struct {
// for the authenticated api. This is by default {'localhost'}.
AuthVirtualHosts []string `toml:",omitempty"`

// AuthModules is a list of API modules to expose via the Auth RPC interface.
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
AuthModules []string

// AuthOrigins is the list of domain to accept websocket requests from. Please be
// aware that the server can only act upon the HTTP request the client sends and
// cannot verify the validity of the request header.
AuthOrigins []string `toml:",omitempty"`

// WSHost is the host interface on which to start the websocket RPC server. If
// this field is empty, no websocket API endpoint will be started.
WSHost string
Expand Down
2 changes: 2 additions & 0 deletions node/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ var DefaultConfig = Config{
AuthAddr: DefaultAuthHost,
AuthPort: DefaultAuthPort,
AuthVirtualHosts: DefaultAuthVhosts,
AuthModules: DefaultAuthModules,
AuthOrigins: DefaultAuthOrigins,
HTTPModules: []string{"net", "web3"},
HTTPVirtualHosts: []string{"localhost"},
HTTPTimeouts: rpc.DefaultHTTPTimeouts,
Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (n *Node) startRPC() error {
if err := server.enableRPC(allAPIs, httpConfig{
CorsAllowedOrigins: DefaultAuthCors,
Vhosts: n.config.AuthVirtualHosts,
Modules: DefaultAuthModules,
Modules: n.config.AuthModules,
prefix: DefaultAuthPrefix,
jwtSecret: secret,
}); err != nil {
Expand All @@ -463,8 +463,8 @@ func (n *Node) startRPC() error {
return err
}
if err := server.enableWS(allAPIs, wsConfig{
Modules: DefaultAuthModules,
Origins: DefaultAuthOrigins,
Modules: n.config.AuthModules,
Origins: n.config.AuthOrigins,
prefix: DefaultAuthPrefix,
jwtSecret: secret,
}); err != nil {
Expand Down