Skip to content
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
2 changes: 1 addition & 1 deletion cmd/mytoken-server/mytoken-setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *commandGenSigningKey) Execute(args []string) error {
// Execute implements the flags.Commander interface
func (c *commandCreateDB) Execute(args []string) error {
password := ""
if c.Password != nil && len(*c.Password) == 0 { // -p specified without argument
if c.Password != nil && *c.Password == "" { // -p specified without argument
password = prompter.Password("Database Password")
}
db := cluster.NewFromConfig(config.DBConf{
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func validate() error {
iss0, iss1 := issuerUtils.GetIssuerWithAndWithoutSlash(p.Issuer)
conf.ProviderByIssuer[iss0] = p
conf.ProviderByIssuer[iss1] = p
if len(p.AudienceRequestParameter) == 0 {
if p.AudienceRequestParameter == "" {
p.AudienceRequestParameter = "resource"
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Connect() {

// NewNullString creates a new sql.NullString from the given string
func NewNullString(s string) sql.NullString {
if len(s) == 0 {
if s == "" {
return sql.NullString{}
}
return sql.NullString{
Expand Down
4 changes: 2 additions & 2 deletions internal/db/dbrepo/authcodeinforepo/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ func NewState(state string) *State {
}

func (s *State) Hash() string {
if len(s.hash) == 0 {
if s.hash == "" {
s.hash = hashUtils.SHA512Str([]byte(s.state))
}
return s.hash
}

func (s *State) PollingCode() string {
if len(s.pollingCode) == 0 {
if s.pollingCode == "" {
s.pollingCode = hashUtils.HMACSHA512Str([]byte(s.state), []byte("polling_code"))[:config.Get().Features.Polling.Len]
log.WithField("state", s.state).WithField("polling_code", s.pollingCode).Debug("Created polling_code for state")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func PopTokenForTransferCode(tx *sqlx.Tx, pollingCode string) (jwt string, err e
if err != nil {
return err
}
if !valid || len(jwt) == 0 {
if !valid || jwt == "" {
return nil
}
return pt.Delete(tx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (pt proxyToken) Token() string {

// ID returns the id of this token
func (pt *proxyToken) ID() string {
if len(pt.id) == 0 {
if pt.id == "" {
pt.id = hashUtils.SHA512Str([]byte(pt.token))
}
return pt.id
Expand All @@ -78,7 +78,7 @@ func (pt *proxyToken) JWT(tx *sqlx.Tx) (jwt string, valid bool, err error) {
valid = true
return
}
if len(pt.encryptedJWT) == 0 {
if pt.encryptedJWT == "" {
if err = db.RunWithinTransaction(tx, func(tx *sqlx.Tx) error {
return tx.Get(&pt.encryptedJWT, `SELECT jwt FROM ProxyTokens WHERE id=?`, pt.id)
}); err != nil {
Expand All @@ -90,7 +90,7 @@ func (pt *proxyToken) JWT(tx *sqlx.Tx) (jwt string, valid bool, err error) {
}
}
valid = true
if len(pt.encryptedJWT) == 0 {
if pt.encryptedJWT == "" {
return
}
jwt, err = cryptUtils.AES256Decrypt(pt.encryptedJWT, pt.token)
Expand Down
2 changes: 1 addition & 1 deletion internal/endpoints/revocation/revocationEndpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func HandleRevoke(ctx *fiber.Ctx) error {
}
log.Trace("Parsed super token request")
clearCookie := false
if len(req.Token) == 0 {
if req.Token == "" {
req.Token = ctx.Cookies("mytoken-supertoken")
clearCookie = true
}
Expand Down
4 changes: 2 additions & 2 deletions internal/endpoints/token/access/accessTokenEndpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func HandleAccessTokenEndpoint(ctx *fiber.Ctx) error {
return res.Send(ctx)
}
log.Trace("Checked super token capabilities")
if len(req.Issuer) == 0 {
if req.Issuer == "" {
req.Issuer = st.OIDCIssuer
} else if req.Issuer != st.OIDCIssuer {
res := serverModel.Response{
Expand Down Expand Up @@ -131,7 +131,7 @@ func handleAccessTokenRefresh(st *supertoken.SuperToken, req request.AccessToken
} else if len(usedRestriction.Scope) > 0 {
scopes = usedRestriction.Scope
}
if len(req.Audience) != 0 {
if req.Audience != "" {
auds = req.Audience
} else if len(usedRestriction.Audiences) > 0 {
auds = strings.Join(usedRestriction.Audiences, " ")
Expand Down
4 changes: 2 additions & 2 deletions internal/endpoints/token/super/transferEndpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// HandleCreateTransferCodeForExistingSuperToken handles request to create a transfer code for an existing supertoken
func HandleCreateTransferCodeForExistingSuperToken(ctx *fiber.Ctx) error {
token := ctxUtils.GetAuthHeaderToken(ctx)
if len(token) == 0 {
if token == "" {
var req pkg.CreateTransferCodeRequest
if err := json.Unmarshal(ctx.Body(), &req); err != nil {
return model.Response{
Expand All @@ -27,7 +27,7 @@ func HandleCreateTransferCodeForExistingSuperToken(ctx *fiber.Ctx) error {
}.Send(ctx)
}
token = req.SuperToken
if len(token) == 0 {
if token == "" {
return model.Response{
Status: fiber.StatusUnauthorized,
Response: pkgModel.BadRequestError("required parameter 'super_token' missing"),
Expand Down
2 changes: 1 addition & 1 deletion internal/oidc/revoke/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// RefreshToken revokes a refresh token
func RefreshToken(provider *config.ProviderConf, rt string) *model.Response {
if len(provider.Endpoints.Revocation) == 0 {
if provider.Endpoints.Revocation == "" {
return nil
}
req := oidcReqRes.NewRTRevokeRequest(rt)
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/ctxUtils/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func GetSuperTokenStr(ctx *fiber.Ctx) string {
// GetSuperToken checks a fiber.Ctx for a super token and returns a token object
func GetSuperToken(ctx *fiber.Ctx) *token.Token {
tok := GetSuperTokenStr(ctx)
if len(tok) == 0 {
if tok == "" {
return nil
}
t, err := token.GetLongSuperToken(tok)
Expand Down
2 changes: 1 addition & 1 deletion shared/supertoken/pkg/stid/stid.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (i *STID) HashValid() bool {
}

func (i *STID) Hash() string {
if len(i.hash) == 0 && i.Valid() {
if i.hash == "" && i.Valid() {
i.hash = hashUtils.SHA512Str(i.Bytes())
}
return i.hash
Expand Down
4 changes: 2 additions & 2 deletions shared/supertoken/pkg/supertoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (st *SuperToken) verifyID() bool {
}

func (st *SuperToken) verifySubject() bool {
if len(st.Subject) == 0 {
if st.Subject == "" {
return false
}
if st.Subject != issuerUtils.CombineSubIss(st.OIDCSubject, st.OIDCIssuer) {
Expand Down Expand Up @@ -186,7 +186,7 @@ func CreateTransferCode(stid stid.STID, jwt string, newST bool, responseType mod

// ToTokenResponse creates a SuperTokenResponse for this SuperToken according to the passed model.ResponseType
func (st *SuperToken) ToTokenResponse(responseType model.ResponseType, networkData serverModel.ClientMetaData, jwt string) (response.SuperTokenResponse, error) {
if len(jwt) == 0 {
if jwt == "" {
jwt = st.jwt
}
switch responseType {
Expand Down
2 changes: 1 addition & 1 deletion shared/supertoken/restrictions/restriction.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (r Restrictions) WithScopes(scopes []string) (ret Restrictions) {
return r
}
for _, rr := range r {
if len(rr.Scope) == 0 || utils.IsSubSet(scopes, utils.SplitIgnoreEmpty(rr.Scope, " ")) {
if rr.Scope == "" || utils.IsSubSet(scopes, utils.SplitIgnoreEmpty(rr.Scope, " ")) {
ret = append(ret, rr)
}
}
Expand Down