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

Empty exception when parsing Go paseto v2 public #16

Open
hazcod opened this issue May 18, 2021 · 2 comments
Open

Empty exception when parsing Go paseto v2 public #16

hazcod opened this issue May 18, 2021 · 2 comments

Comments

@hazcod
Copy link

hazcod commented May 18, 2021

Hi! Thank you for the library.

I am trying to parse a public (v2) paseto token generated by https://github.com/o1egl/paseto .
However, an empty exception is returned when parsing.

        try:
            parsed = paseto.parse(
                key=self.tokenSecretKey,
                purpose='local',
                token=tokenValue,
                encoder=paseto.JsonEncoder, 
                validate=False,
                rules=None,
                required_claims=[
                    '1',
                    '2',
                    '3',
                ]
            )
        except Exception as e:
            raise ValueError("token decrypt failed: " + str(e))

Returns: token decrypt failed:.

Generator:

			now := time.Now()
                        pasetoV2 := paseto.NewV2()
			jsonToken := paseto.JSONToken{
				Audience:   "",
				Subject:    "",
				Issuer:     "foo",
				Jti:        strconv.FormatUint(ID, 10),
				Expiration: now.AddDate(0, 0, tokenExpiryDays),
				IssuedAt:   now,
				NotBefore:  now,
			}

			jsonToken.Set("1", testUUID)
			jsonToken.Set("2", strconv.FormatUint(ID, 10))
			jsonToken.Set("3", user.Name)

			token, err := pasetoV2.Encrypt(cryptoKeyBytes, jsonToken, nil)
			if err != nil { ... }
@rlittlefield
Copy link
Owner

If you have a public token, try passing in purpose='public' to the paseto.parse call. If you pass "local", it will be expecting a local type token.

@rlittlefield
Copy link
Owner

Not sure if you had any luck with this. I'm guessing this is because we don't have messages for some of these exceptions.

I've added this issue to track this: #18

If you are having trouble figuring out which exception before I get a fix in for this, you can to str(type(e)), which should give you the name of the exception class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants