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

Refactor: Eliminate Global Variable to Enhance Testability #4997

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
91e910f
chore(3.14.0): Add the installation manifest for 3.14.0 version (#4995)
ispeakc0de Dec 17, 2024
e448062
Refactor: Eliminate Global Variable to Enhance Testability
andoriyaprashant Dec 17, 2024
36969a8
checks
andoriyaprashant Dec 17, 2024
b713310
chore: Adding Pokerbaazi as adopters (#4958)
S-ayanide Dec 20, 2024
e12cdef
Proposal: Load testing with locust (#4955)
kwx4957 Dec 20, 2024
a388ed8
chore(deps): Bump nanoid from 3.3.7 to 3.3.8 in /chaoscenter/web (#4992)
dependabot[bot] Dec 20, 2024
be791ec
chore(deps): Bump cross-spawn from 7.0.3 to 7.0.6 in /chaoscenter/web…
dependabot[bot] Dec 20, 2024
2615dac
chore: update base image because of the CVE-2024-3596 (#4964)
namkyu1999 Dec 20, 2024
500e1ff
JVM fault injection proposal (#4977)
bjoky Dec 20, 2024
188096a
Introducing LitmusChaos Guru on Gurubase.io (#4943)
kursataktas Dec 20, 2024
fef592c
chore(deps): Bump golang.org/x/crypto (#4985)
dependabot[bot] Dec 20, 2024
6ade2a7
Fix vulnerabilities in Graphql and Authentication server (#5002)
Saranya-jena Dec 20, 2024
57d07af
Add probe source part to kubernetes cmd properties of ChaosEngine man…
rogeriofbrito Dec 20, 2024
5840c35
user_jwt.go fixed
andoriyaprashant Dec 26, 2024
20f4d91
chore: Updating Governance policy and memebership roles (#5016)
S-ayanide Jan 9, 2025
200e174
chore: Fixing MAINTAINER.md formatting (#5017)
S-ayanide Jan 9, 2025
6ef4819
chore: Fixing ISSUE_TEMPLATE naming (#5018)
S-ayanide Jan 13, 2025
9cc779c
fix: return only message when no projects are found (#5011)
ayush3160 Jan 15, 2025
7e16aa7
Added 3.15 installation manifests and fixed vulnerabilities (#5025)
Saranya-jena Jan 15, 2025
a63eab8
refactor: update code syntax in backend server (#4944)
jemlog Jan 15, 2025
484a0ba
chore(3.15.0): Add the installation manifests for 3.15.0 version (#5027)
ispeakc0de Jan 15, 2025
f5cf97f
backend unit tests
andoriyaprashant Jan 18, 2025
56f0785
Merge branch 'master' into 1branch
andoriyaprashant Jan 18, 2025
6329562
imports
andoriyaprashant Jan 18, 2025
c783ef7
Merge branch '1branch' of https://github.com/andoriyaprashant/litmus …
andoriyaprashant Jan 18, 2025
21a3c8d
wrong type for method DeleteProbe and AddRemoteChaosHub
andoriyaprashant Jan 18, 2025
9efca1b
Imports Fix
andoriyaprashant Jan 18, 2025
ebf29ac
DeleteProbe and DeleteChaosHub wrong type
andoriyaprashant Jan 18, 2025
9911bd9
service and handler
andoriyaprashant Jan 18, 2025
8e69135
NewChaosProbeOperator
andoriyaprashant Jan 19, 2025
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
Prev Previous commit
Next Next commit
user_jwt.go fixed
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
andoriyaprashant committed Jan 18, 2025
commit 5840c35ea94fc5266edbbd4f2566dcd2052582ac
16 changes: 13 additions & 3 deletions chaoscenter/graphql/server/pkg/authorization/user_jwt.go
Original file line number Diff line number Diff line change
@@ -12,8 +12,18 @@ import (
"github.com/golang-jwt/jwt"
)

type Operator struct {
authConfigOperator *authConfig.Operator
}

func NewAuthorizationOperator(mongodbOperator mongodb.MongoOperator) *Operator {
return &Operator{
authConfigOperator: authConfig.NewAuthConfigOperator(mongodbOperator),
}
}

// UserValidateJWT validates the cluster jwt
func UserValidateJWT(token string, salt string) (jwt.MapClaims, error) {
func (o *Operator) UserValidateJWT(token string, salt string) (jwt.MapClaims, error) {
tkn, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) {
if _, isValid := token.Method.(*jwt.SigningMethodHMAC); !isValid {
return nil, fmt.Errorf("invalid token %s", token.Header["alg"])
@@ -39,8 +49,8 @@ func UserValidateJWT(token string, salt string) (jwt.MapClaims, error) {
}

// GetUsername returns the username from the jwt token
func GetUsername(token string) (string, error) {
salt, err := authConfig.NewAuthConfigOperator(mongodb.Operator).GetAuthConfig(context.Background())
func (o *Operator) GetUsername(token string) (string, error) {
salt, err := o.authConfigOperator.GetAuthConfig(context.Background())
if err != nil {
return "", err
}