ajout de la mise en forme du resultat
This commit is contained in:
@@ -18,7 +18,9 @@ import (
|
||||
|
||||
//File structure du fichier
|
||||
type File struct {
|
||||
jwtProduce string
|
||||
JwtProduce string
|
||||
Header string
|
||||
Payload string
|
||||
}
|
||||
|
||||
type JsonToken struct {
|
||||
@@ -92,8 +94,6 @@ func (s *server) handleLocal() http.HandlerFunc {
|
||||
|
||||
// Declare the token with the algorithm used for signing, and the claims
|
||||
tokenstr := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
zer, _ := json.Marshal(tokenstr.Claims)
|
||||
fmt.Printf("zer %v", string(zer))
|
||||
|
||||
// Create the JWT string
|
||||
tokenString, err := tokenstr.SignedString(jwtKey)
|
||||
@@ -103,21 +103,25 @@ func (s *server) handleLocal() http.HandlerFunc {
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.Printf("le token %v \n", tokenString)
|
||||
tableau := strings.Split(tokenString, ".")
|
||||
log.Println(tableau[0])
|
||||
headerrr, _ := base64.URLEncoding.DecodeString(tableau[0])
|
||||
log.Println(string(string(headerrr)))
|
||||
header, _ := base64.URLEncoding.DecodeString(tableau[0])
|
||||
log.Println(string(string(header)))
|
||||
|
||||
log.Println(tableau[1])
|
||||
claimssss, _ := base64.URLEncoding.DecodeString(tableau[1])
|
||||
log.Println(string(string(claimssss)))
|
||||
payload, _ := base64.URLEncoding.DecodeString(tableau[1])
|
||||
log.Println(string(payload))
|
||||
|
||||
log.Println(tableau[2])
|
||||
test, _ := base64.URLEncoding.DecodeString(tableau[2])
|
||||
log.Println(string(string(test)))
|
||||
|
||||
s.response(rw, r, string(zer), http.StatusOK)
|
||||
tokenSssss := map[string]interface{}{
|
||||
"access_token": tokenString,
|
||||
"header": string(header),
|
||||
"payload": string(payload),
|
||||
}
|
||||
|
||||
s.responseFile(rw, r, tokenSssss, http.StatusOK)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,7 +140,7 @@ func (s *server) handleOAuth20() http.HandlerFunc {
|
||||
}
|
||||
|
||||
log.Println(currentCompany)
|
||||
redirecthttp := "https://" + domain + "/entreprise-partenaire/authorize?client_id=" + clientID + "&scope=" + scopes + "¤t_company=" + currentCompany + "&redirect_uri=http://localhost:8080/oauth/redirect"
|
||||
redirecthttp := "https://" + domain + "/entreprise-partenaire/authorize?client_id=" + clientID + "&scope=" + scopes + "¤t_company=" + currentCompany + "&redirect_uri=http://localhost:8080/oauth/redirect&abort_uri=http://localhost:8080/index"
|
||||
http.Redirect(rw, r, redirecthttp, http.StatusMovedPermanently)
|
||||
|
||||
}
|
||||
|
||||
@@ -55,10 +55,16 @@ func (s *server) responseFile(rw http.ResponseWriter, _ *http.Request, data inte
|
||||
}
|
||||
|
||||
sssss := tokenVal["access_token"].(string)
|
||||
header := tokenVal["header"].(string)
|
||||
payload := tokenVal["payload"].(string)
|
||||
//sssss := "erer"
|
||||
log.Println(sssss)
|
||||
|
||||
f := File{jwtProduce: sssss}
|
||||
f := File{
|
||||
JwtProduce: sssss,
|
||||
Header: header,
|
||||
Payload: payload,
|
||||
}
|
||||
|
||||
err = tem.Execute(rw, f)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,7 +11,12 @@
|
||||
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha512.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64-min.js"></script>
|
||||
<script>
|
||||
|
||||
var payloadJson = `{{.Payload}}`
|
||||
console.log(JSON.stringify(payloadJson))
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -19,13 +24,21 @@
|
||||
<h1 class="center-align">Composition</h1>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
||||
{{.jwtProduce }}
|
||||
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<i class="material-icons prefix">account_circle</i>
|
||||
<label for="name">{{.jwtProduce }}</label>
|
||||
<div class="col s5">
|
||||
<span style="width:300px; word-wrap:break-word; display:inline-block;">
|
||||
{{.JwtProduce }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col s7">
|
||||
header
|
||||
<div>{{.Header}}</div>
|
||||
Payload
|
||||
<div>
|
||||
<span style="width:300px; word-wrap:break-word; display:inline-block;">
|
||||
{{.Payload}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user