Skip to content

Commit

Permalink
feat: --secret, --public, --noauth and --norpc options
Browse files Browse the repository at this point in the history
- Rename jwt options (drop _id)
  • Loading branch information
palkan committed Mar 6, 2024
1 parent c139e99 commit b64797f
Show file tree
Hide file tree
Showing 22 changed files with 510 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ Gemfile.lock
/k6

/coverage.out
admin/ui/build
17 changes: 15 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,23 @@ func (r *Runner) newController(metrics *metricspkg.Metrics) (node.Controller, er
return nil, errorx.Decorate(err, "!!! Failed to initialize controller !!!")
}

ids := []identity.Identifier{}

if r.config.JWT.Enabled() {
identifier := identity.NewJWTIdentifier(&r.config.JWT, r.log)
ids = append(ids, identity.NewJWTIdentifier(&r.config.JWT, r.log))
r.log.Info(fmt.Sprintf("JWT authentication is enabled (param: %s, enforced: %v)", r.config.JWT.Param, r.config.JWT.Force))
}

if r.config.SkipAuth {
ids = append(ids, identity.NewPublicIdentifier())
r.log.Info("connection authentication is disabled")
}

if len(ids) > 1 {
identifier := identity.NewIdentifierPipeline(ids...)
controller = identity.NewIdentifiableController(controller, identifier)
r.log.Info(fmt.Sprintf("JWT identification is enabled (param: %s, enforced: %v)", r.config.JWT.Param, r.config.JWT.Force))
} else if len(ids) == 1 {
controller = identity.NewIdentifiableController(controller, ids[0])
}

if !r.Router().Empty() {
Expand Down
Loading

0 comments on commit b64797f

Please sign in to comment.