Skip to content

Commit

Permalink
[fmt] Go reformatting due to go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisjbell committed Jul 19, 2023
1 parent 5650674 commit 6ba0f1e
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 41 deletions.
14 changes: 6 additions & 8 deletions core/auth_provider_okta.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ Mapping:
func (p *OktaAuthProvider) verifyToken(t string, category string) (*verifier.Jwt, error) {
toValidate := map[string]string{}

if category == "id" { //id_token
if category == "id" { //id_token
// toValidate["nonce"] = "{NONCE}"
toValidate["aud"] = p.ClientID
} else { //access_token
} else { //access_token
toValidate["aud"] = "api://" + p.AuthorizationServer
toValidate["cid"] = "" //p.ClientID
}
Expand All @@ -311,27 +311,25 @@ func (p *OktaAuthProvider) verifyToken(t string, category string) (*verifier.Jwt

verifier := jwtVerifierSetup.New()

if category == "id"{
if category == "id" {
token, err := verifier.VerifyIdToken(t)
if err != nil && p.TokenVerification {
return nil, fmt.Errorf("%s", err)
}

if token != nil {
return token, nil
}
}else {
} else {
token, err := verifier.VerifyAccessToken(t)
if err != nil && p.TokenVerification {
return nil, fmt.Errorf("%s", err)
}

if token != nil {
return token, nil
}
}



return nil, fmt.Errorf("%s token could not be verified: %s", category, "")
}
2 changes: 1 addition & 1 deletion core/bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (b *Bus) Register(queues []string) (chan Event, int64, error) {
return nil, -1, fmt.Errorf("too many message bus clients")
}

//Unregister causes the bus to stop routing events to the handler with the given ID.
// Unregister causes the bus to stop routing events to the handler with the given ID.
// The channel returned from the matching call to register is closed. Multiple calls
// to Unregister with the same id are idempotent.
func (b *Bus) Unregister(id int64) {
Expand Down
4 changes: 2 additions & 2 deletions db/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (db *DB) GetAllJobs(filter *JobFilter) ([]*Job, error) {
return l, nil
}

//Adding separate V6 functions to support Schema6 and Schema12's getAllJobs() call
//Schema V13 onwards has job.retries
// Adding separate V6 functions to support Schema6 and Schema12's getAllJobs() call
// Schema V13 onwards has job.retries
func (f *JobFilter) QueryV6() (string, []interface{}) {
wheres := []string{}
args := []interface{}{}
Expand Down
2 changes: 1 addition & 1 deletion db/memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (db *DB) RemoveUserFromTenant(user, tenant string) error {
return nil
}

//GetTenantsForUser given a user's uuid returns a slice of Tenants that the user has membership with
// GetTenantsForUser given a user's uuid returns a slice of Tenants that the user has membership with
func (db *DB) GetTenantsForUser(user string) ([]*Tenant, error) {
l := make([]*Tenant, 0)
return l, db.exclusively(func() error {
Expand Down
6 changes: 3 additions & 3 deletions db/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func (db *DB) IsTaskRunnable(task *Task) (bool, error) {
return false, nil
}

//The caller must Lock the db mutex
// The caller must Lock the db mutex
func (db *DB) taskQueue(id string) string {
r, err := db.query(`SELECT tenant_uuid FROM tasks WHERE uuid = ?`, id)
if err != nil {
Expand Down Expand Up @@ -974,8 +974,8 @@ func (db *DB) RedactAllTaskLogs(tasks []*Task) {
}
}

//UnscheduleAllTasks takes all tasks which are in the scheduled state and puts
//them back in a pending state.
// UnscheduleAllTasks takes all tasks which are in the scheduled state and puts
// them back in a pending state.
func (db *DB) UnscheduleAllTasks() error {
return db.Exec(`UPDATE tasks SET status = 'pending' WHERE status = 'scheduled'`)
}
Expand Down
34 changes: 16 additions & 18 deletions plugin/consul-snapshot/plugin.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
// The `consul` plugin for SHIELD is intended to be a generic
// backup/restore plugin for a consul server.
//
// PLUGIN FEATURES
// # PLUGIN FEATURES
//
// This plugin implements functionality suitable for use with the following
// SHIELD Job components:
//
// Target: yes
// Store: no
// Target: yes
// Store: no
//
// PLUGIN CONFIGURATION
// # PLUGIN CONFIGURATION
//
// The endpoint configuration passed to this plugin is used to identify
// what consul instance to back up, and how to connect to it. Your
// endpoint JSON should look something like this:
//
// {
// "address":"consul.service.consul:8500", # optional - can also be prefixed with http:// or https://
// "ca-path":"/var/vcap/jobs/consul/consul/ca.cert", # optional - required for connecting via https
// "client-cert":"/var/vcap/jobs/consul/consul/consul.cert", # optional - required when verify_incoming is set to true
// "client-key":"/var/vcap/jobs/consul/consul/consul.key" # optional - required when verify_incoming is set to true
// }
// {
// "address":"consul.service.consul:8500", # optional - can also be prefixed with http:// or https://
// "ca-path":"/var/vcap/jobs/consul/consul/ca.cert", # optional - required for connecting via https
// "client-cert":"/var/vcap/jobs/consul/consul/consul.cert", # optional - required when verify_incoming is set to true
// "client-key":"/var/vcap/jobs/consul/consul/consul.key" # optional - required when verify_incoming is set to true
// }
//
// Default Configuration
//
// {
// "address" : "http://127.0.0.1:8500"
// "consul" : "/var/vcap/packages/consul/bin/consul"
// }
// {
// "address" : "http://127.0.0.1:8500"
// "consul" : "/var/vcap/packages/consul/bin/consul"
// }
//
// BACKUP DETAILS
// # BACKUP DETAILS
//
// The `consul` plugin makes uses the consul api to back up the entire kv store.
//
// RESTORE DETAILS
// # RESTORE DETAILS
//
// The `consul` plugin will also restore the entire kv store.
//
// DEPENDENCIES
//
//
package main

import (
Expand Down
4 changes: 2 additions & 2 deletions plugin/etcd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/shieldproject/shield/plugin"
)

//global variables
// global variables
var (
RoleBasedAuthentication = "Role-Based Authentication"
CertificateAuthentication = "Certificate-Based Authentication"
Expand Down Expand Up @@ -254,7 +254,7 @@ func getEtcdConfig(endpoint plugin.ShieldEndpoint) (*EtcdConfig, error) {
}, nil
}

//Validate user input
// Validate user input
func (p EtcdPlugin) Validate(endpoint plugin.ShieldEndpoint) error {
var (
s string
Expand Down
4 changes: 2 additions & 2 deletions plugin/vault/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ func expandVersionList(secret exportSecret) []exportVersion {
return append(ret, secret.Versions...)
}

//this is the value that gets written for secret versions that need to be
//destroyed
// this is the value that gets written for secret versions that need to be
// destroyed
var placeholderDestroyedValue = map[string]interface{}{"placeholder": "garbage"}

func writeSecret(v *vaultkv.KV, path string, versions []exportVersion) error {
Expand Down
4 changes: 2 additions & 2 deletions route/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Request struct {
bt []string
}

//NewRequest initializes and returns a new request object. Setting debug to
// NewRequest initializes and returns a new request object. Setting debug to
// true will cause errors to be logged.
func NewRequest(w http.ResponseWriter, r *http.Request, debug bool) *Request {
return &Request{
Expand Down Expand Up @@ -145,7 +145,7 @@ func (r *Request) JSONEncoder() *json.Encoder {
return json.NewEncoder(r.w)
}

//Payload unmarshals the JSON body of this request into the given interface.
// Payload unmarshals the JSON body of this request into the given interface.
// Returns true if successful and false otherwise.
func (r *Request) Payload(v interface{}) bool {
if r.Req.Body == nil {
Expand Down
4 changes: 2 additions & 2 deletions tui/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (f *Form) NewField(label string, name string, value interface{}, showas str
return &tmpField, nil
}

//GetField retrieves the reference to the Field with the Name attribute given
//to this function. Returns nil if no such Field was found.
// GetField retrieves the reference to the Field with the Name attribute given
// to this function. Returns nil if no such Field was found.
func (f *Form) GetField(name string) *Field {
for _, field := range f.Fields {
if field.Name == name {
Expand Down

0 comments on commit 6ba0f1e

Please sign in to comment.