Questions tagged [jwt-go]

59 questions
2
votes
1 answer

Golang and JWT - Simple Logout

I'm currently working on an API and after a bit of time, I now understand how to use JWT in Go to get a token. With this token, I can keep a user connected but, how can I logout from the client application? Here is my token.go code: package…
Emixam23
  • 3,854
  • 8
  • 50
  • 107
2
votes
1 answer

(Golang) JWT Signature Verification Issue

I'm trying to get my head around JWT tokens in Golang. I'm using github.com/dgrijalva/jwt-go. What caught me off guard is the fact that I can enter multiple valid signatures. For example, head over to http://jwt.io - enter MySuperSecretKey for the…
zeroc8
  • 853
  • 1
  • 10
  • 20
2
votes
1 answer

Can a jwt created in one language or library be decoded and verified in another?

So I have an API server that uses golang and the jwt-go library to issue jwt and i want to have a socket.io server running using node.js and jsonwebtoken library that needs to decode and verify the token, so my question is can I issue a token from…
zola
  • 5,737
  • 8
  • 33
  • 48
2
votes
1 answer

Golang package jwt-go with rsa key. How to put the public key and how to get it from the token?

I'm trying to generate a token with a rsa key using the jwt-go package in golang. Here there is a blog explaining how to do it but that code will always be validating all tokens because is using the public key stored in the server and is not…
victorsamuelmd
  • 39
  • 1
  • 1
  • 3
1
vote
1 answer

Verify JWT Token fails in Golang

I have a JWT token generated in nodejs app. It is signed using HS256. I've written the code to validate it in golang. I get an error message of "signature is invalid" even though I verified it in the JWT.io site. The code validates also…
1
vote
2 answers

RS256 message too long for RSA public key size - error signing JWT

I'm using https://github.com/dgrijalva/jwt-go to build a JWT using a 256-bit private PEM key. I'm using SigningMethodRS256 to sign the JWT: signBytes, _ := ioutil.ReadFile(privKeyPath) signKey, err := jwt.ParseRSAPrivateKeyFromPEM(signBytes) token…
1
vote
1 answer

JWT Signing Method HS256 Golang

I have a question about JWT signing with method HS256 in Go. I'm using this import "github.com/dgrijalva/jwt-go" It doesn't require a secret key length >= 256 bits (32 bytes)? Let's say I have an server application written in Golang which gives JWT…
user3057153
  • 11
  • 1
  • 3
1
vote
1 answer

JWT-GO Error 4 and token verification from another api url

I am using package "github.com/dgrijalva/jwt-go" in golang to authenticate api hits. The code for creating a jwt token is: token := jwt.NewWithClaims(jwt.SigningMethodHS256, &jwt.MapClaims{ "email": "test@example.com", "exp": …
Amandeep kaur
  • 985
  • 3
  • 15
  • 35
1
vote
2 answers

How to test authenticate JWT routes in go

I want to test protected routes in go with JWT authentication. Already try to receive a response and try to pass a token, but its only returns 401 as code response. package routes import ( "fmt" "github.com/stretchr/testify/assert" …
1
vote
1 answer

Go's JWT token expires when I compile new code

I am working on a SAAS based product which is built in Angular5 at front end. It uses Go's rest APIs to connect to DB and all back end functionality. I am using JWT token to authenticate the users on this system. On the back end, I am using Gin…
Amandeep kaur
  • 985
  • 3
  • 15
  • 35
1
vote
2 answers

How can I add JWT automatically after login?

I have a cruel doubt. I'm running the code below: package main import ( "net/http" "time" "github.com/dgrijalva/jwt-go" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) func login(c echo.Context) error { …
Marcus Pereira
  • 220
  • 3
  • 11
1
vote
3 answers

Confusion relating to public and private keys and JWT

I'm trying out JWT (JSON Web Tokens) in a Go web service. Here's what I've done so far: package jwt import( "fmt" "net/http" "github.com/gorilla/mux" "github.com/dgrijalva/jwt-go" "io/ioutil" ) var privateKey []byte var…
W.K.S
  • 9,787
  • 15
  • 75
  • 122
1
vote
1 answer

Gcloud components update -> can't find import

Our code base has been compiling just fine up until now. Today, gcloud started pestering me with its update message again, so I ran a "gcloud components update" and it updated successfully. However, now when I try to deploy our project using…
Scott L
  • 11
  • 1
0
votes
1 answer

JWT Claims not retained after token signing

I have the following code. I am creating a json web token (using golang-jwt) with custom claims. The issue is that when I sign the token with a key (method = HS256) and then parse the token the claims are getting changed. What mistake I am…
Sushant
  • 123
  • 8
0
votes
1 answer

Golang REST API - passing information from a verified and decoded token

I have set up middleware to verify and extract the claims from the JWT token (using https://github.com/golang-jwt/jwt). My problem now is I want to pass that information on somehow to the route hander func so that it can check the permissions that…
Ol1BoT
  • 37
  • 3