Skip to content
Snippets Groups Projects
Commit 2a6a4e15 authored by dylan.peiry's avatar dylan.peiry
Browse files

fix(jwt): fixed "Client Id" does not match"

parent 1a6eb67f
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@ package auth
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
jwtverifier "github.com/okta/okta-jwt-verifier-golang"
"io"
......@@ -15,7 +14,6 @@ import (
var toValidate = map[string]string{
"aud": "api://default",
"cid": os.Getenv("OKTA_CLIENT_ID"),
}
func RequestCode(c *gin.Context) {
......@@ -34,7 +32,6 @@ func RequestCode(c *gin.Context) {
//ExchangeCodeForJWT Request accessToken using code from RequestCode
func ExchangeCodeForJWT(c *gin.Context) {
code := c.Query("code")
fmt.Println(code)
if code != "" {
data := url.Values{
"grant_type": {"authorization_code"},
......@@ -73,6 +70,7 @@ func ExchangeCodeForJWT(c *gin.Context) {
}
func VerifyJWT(c *gin.Context) (jwtverifier.Jwt, bool) {
toValidate["cid"] = os.Getenv("OKTA_CLIENT_ID")
status := true
token := c.Request.Header.Get("Authorization")
var jwtToken = jwtverifier.Jwt{
......
......@@ -2,7 +2,6 @@ package middlewares
import (
"appSec/pkg/api/auth"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)
......@@ -41,7 +40,6 @@ func BasicAuthorization(c *gin.Context) {
func JWTAuthorization(c *gin.Context) {
if jwt, ok := auth.VerifyJWT(c); ok {
user := jwt.Claims["user"].(string)
fmt.Println(user)
Authorization(c, user)
}
c.AbortWithStatus(http.StatusUnauthorized)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment