Skip to content

Commit

Permalink
refactor: rename private api references
Browse files Browse the repository at this point in the history
  • Loading branch information
lfleischmann committed Sep 13, 2022
1 parent 2837845 commit 6cc7c66
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ The service is now available at `localhost:8000`.

## Advanced Usage

### Start private API
### Start admin API

In the usage section above we only started the public API. Use the command below to start the private API. The default
In the usage section above we only started the public API. Use the command below to start the admin API. The default
port is `8001`, but can be [customized](./docs/Config.md) in the config.

```shell
serve private
serve admin
```

Use this command to start the public and private API together:
Use this command to start the public and admin API together:

````shell
serve all
````

> **Warning** The private API must be protected by an access management system.
> **Warning** The admin API must be protected by an access management system.

### Supported Databases

Expand Down
8 changes: 4 additions & 4 deletions backend/cmd/serve/private.go → backend/cmd/serve/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"sync"
)

func NewServePrivateCommand(config *config.Config) *cobra.Command {
func NewServeAdminCommand(config *config.Config) *cobra.Command {
return &cobra.Command{
Use: "private",
Short: "Start the private portion of the hanko server",
Use: "admin",
Short: "Start the admin portion of the hanko server",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
persister, err := persistence.New(config.Database)
Expand All @@ -26,7 +26,7 @@ func NewServePrivateCommand(config *config.Config) *cobra.Command {
var wg sync.WaitGroup
wg.Add(1)

go server.StartPrivate(config, &wg, persister)
go server.StartAdmin(config, &wg, persister)

wg.Wait()
},
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/serve/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func NewServeAllCommand(config *config.Config) *cobra.Command {
return &cobra.Command{
Use: "all",
Short: "Start the public and private portion of the hanko server",
Short: "Start the public and admin portion of the hanko server",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
persister, err := persistence.New(config.Database)
Expand All @@ -27,7 +27,7 @@ func NewServeAllCommand(config *config.Config) *cobra.Command {
wg.Add(2)

go server.StartPublic(config, &wg, persister)
go server.StartPrivate(config, &wg, persister)
go server.StartAdmin(config, &wg, persister)

wg.Wait()
},
Expand Down
2 changes: 1 addition & 1 deletion backend/cmd/serve/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func RegisterCommands(parent *cobra.Command, config *config.Config) {
cmd := NewServeCommand()
parent.AddCommand(cmd)
cmd.AddCommand(NewServePublicCommand(config))
cmd.AddCommand(NewServePrivateCommand(config))
cmd.AddCommand(NewServeAdminCommand(config))
cmd.AddCommand(NewServeAllCommand(config))
}
12 changes: 6 additions & 6 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func DefaultConfig() *Config {
Public: ServerSettings{
Address: ":8000",
},
Private: ServerSettings{
Admin: ServerSettings{
Address: ":8001",
},
},
Expand Down Expand Up @@ -125,20 +125,20 @@ func (c *Config) Validate() error {
return nil
}

// Server contains the setting for the public and private server
// Server contains the setting for the public and admin server
type Server struct {
Public ServerSettings `yaml:"public" json:"public" koanf:"public"`
Private ServerSettings `yaml:"private" json:"private" koanf:"private"`
Public ServerSettings `yaml:"public" json:"public" koanf:"public"`
Admin ServerSettings `yaml:"admin" json:"admin" koanf:"admin"`
}

func (s *Server) Validate() error {
err := s.Public.Validate()
if err != nil {
return fmt.Errorf("error validating public server settings: %w", err)
}
err = s.Private.Validate()
err = s.Admin.Validate()
if err != nil {
return fmt.Errorf("error validating private server settings: %w", err)
return fmt.Errorf("error validating admin server settings: %w", err)
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions backend/docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ server:
expose_headers:
- ""
max_age: 0
## private ##
## admin ##
#
# Configuration for the private API.
# Configuration for the admin API.
#
private:
admin:
## address ##
#
# The address the private API will listen and handle requests on.
# The address the admin API will listen and handle requests on.
#
address: ":8001"
## database ##
Expand Down
2 changes: 1 addition & 1 deletion backend/server/admin_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
hankoMiddleware "github.com/teamhanko/hanko/backend/server/middleware"
)

func NewPrivateRouter(persister persistence.Persister) *echo.Echo {
func NewAdminRouter(persister persistence.Persister) *echo.Echo {
e := echo.New()
e.HideBanner = true

Expand Down
6 changes: 3 additions & 3 deletions backend/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ func StartPublic(cfg *config.Config, wg *sync.WaitGroup, persister persistence.P
router.Logger.Fatal(router.Start(cfg.Server.Public.Address))
}

func StartPrivate(cfg *config.Config, wg *sync.WaitGroup, persister persistence.Persister) {
func StartAdmin(cfg *config.Config, wg *sync.WaitGroup, persister persistence.Persister) {
defer wg.Done()
router := NewPrivateRouter(persister)
router.Logger.Fatal(router.Start(cfg.Server.Private.Address))
router := NewAdminRouter(persister)
router.Logger.Fatal(router.Start(cfg.Server.Admin.Address))
}
2 changes: 1 addition & 1 deletion deploy/docker-compose/quickstart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
build: ../../backend
ports:
- '8000:8000' # public
- '8001:8001' # private
- '8001:8001' # admin
restart: unless-stopped
command: serve --config /etc/config/config.yaml all
volumes:
Expand Down
4 changes: 2 additions & 2 deletions deploy/k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- containerPort: 8000
name: public
- containerPort: 8001
name: private
name: admin
volumeMounts:
- mountPath: /etc/config
name: hanko-config
Expand All @@ -42,4 +42,4 @@ spec:
volumes:
- name: hanko-config
configMap:
name: hanko-config
name: hanko-config
6 changes: 3 additions & 3 deletions deploy/k8s/base/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: hanko-private
name: hanko-admin
namespace: hanko
spec:
selector:
app: hanko
ports:
- port: 80
targetPort: private
targetPort: admin
protocol: TCP
name: http
name: http

0 comments on commit 6cc7c66

Please sign in to comment.