Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #97 from UlfBj/consent
Browse files Browse the repository at this point in the history
Consent support complete.
  • Loading branch information
UlfBj authored Jan 5, 2024
2 parents 389e00d + c7749e9 commit d5da421
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 260 deletions.
7 changes: 4 additions & 3 deletions client/client-1.0/Javascript/appclient_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ URL: Vehicle/ADAS/ABS?filter={"type":"static-metadata", "parameter":""}
// AGTserver POST input @agtclient.html:
<AGT server IP address>
agtserver
{"vin":"GEO001", "context":"Independent+OEM+Cloud", "proof":"ABC", "key":"DEF"}
{"action": "agt-request", "vin":"GEO001", "context":"Independent+OEM+Cloud", "proof":"ABC", "key":"DEF"}


// ATserver POST input @atclient.html:
<AT server IP address>
atserver
{"token":"ag-token", "purpose":"fuel-status", "pop":""}
{"action": "at-request", "agToken":"xyz", "purpose":"fuel-status", "pop":""}
{"action": "at-inquiry", "sessionId":"xxx"}

//VISSv2 server request for fuel-status use case:
wsclient_uncompressed.html:
Expand All @@ -90,5 +91,5 @@ wsclient_uncompressed.html:

http_client.html:
URL: Vehicle/Cabin/Door/Row1/Right/IsOpen
Access token: from ATS request
Access token: from at-request response

10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ go 1.18
replace github.com/w3c/automotive-viss2/utils => ./utils

replace (
github.com/COVESA/vss-tools/binary/go_parser/datamodel => github.com/UlfBj/vss-tools/binary/go_parser/datamodel v0.0.0-20231219145220-847ed46699dc
github.com/COVESA/vss-tools/binary/go_parser/parserlib => github.com/UlfBj/vss-tools/binary/go_parser/parserlib v0.0.0-20231219145220-847ed46699dc
// github.com/COVESA/vss-tools/binary/go_parser/datamodel => github.com/UlfBj/vss-tools/binary/go_parser/datamodel v0.0.0-20231219145220-847ed46699dc
// github.com/COVESA/vss-tools/binary/go_parser/parserlib => github.com/UlfBj/vss-tools/binary/go_parser/parserlib v0.0.0-20231219145220-847ed46699dc
github.com/w3c/automotive-viss2/grpc_pb => ./grpc_pb
github.com/w3c/automotive-viss2/server/vissv2server/atServer => ./server/vissv2server/atServer
github.com/w3c/automotive-viss2/server/vissv2server/grpcMgr => ./server/vissv2server/grpcMgr
Expand All @@ -21,8 +21,8 @@ replace (
//replace github.com/w3c/automotive-viss2/protobuf/protoc-out => ./protobuf/protoc-out

require (
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20231218135229-3cd370821711
github.com/COVESA/vss-tools/binary/go_parser/parserlib v0.0.0-20231218135229-3cd370821711
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20231222140420-5343e9c0884d
github.com/COVESA/vss-tools/binary/go_parser/parserlib v0.0.0-20231222140420-5343e9c0884d
github.com/akamensky/argparse v1.4.0
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/go-redis/redis v6.15.9+incompatible
Expand All @@ -38,8 +38,6 @@ require (
google.golang.org/protobuf v1.31.0
)

require github.com/golang/protobuf v1.5.3

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
github.com/UlfBj/vss-tools/binary/go_parser/datamodel v0.0.0-20231219145220-847ed46699dc h1:IhfqGgTj5bMuyxrpriL/ijQ83n8ieUcCRwhCO61oGt4=
github.com/UlfBj/vss-tools/binary/go_parser/datamodel v0.0.0-20231219145220-847ed46699dc/go.mod h1:g2N97BLJNriANqodWem0usF9fKwwUFHP+VxG1dfSsZQ=
github.com/UlfBj/vss-tools/binary/go_parser/parserlib v0.0.0-20231219145220-847ed46699dc h1:h2Pml3Esx5Wikvw/rjLbBj6ob3KLUGdSqx8LsEU1sUw=
github.com/UlfBj/vss-tools/binary/go_parser/parserlib v0.0.0-20231219145220-847ed46699dc/go.mod h1:rWjamgjPuXRJ5kKJrwibrR1Pe771seoUO/9OauCu/Y4=
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20211207094201-7208d48f32b6/go.mod h1:g2N97BLJNriANqodWem0usF9fKwwUFHP+VxG1dfSsZQ=
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20231222140420-5343e9c0884d h1:xDbVda6eQvHk6MotDq4iKnKO/zCmSpLdkDtTkyljBV4=
github.com/COVESA/vss-tools/binary/go_parser/datamodel v0.0.0-20231222140420-5343e9c0884d/go.mod h1:g2N97BLJNriANqodWem0usF9fKwwUFHP+VxG1dfSsZQ=
github.com/COVESA/vss-tools/binary/go_parser/parserlib v0.0.0-20231222140420-5343e9c0884d h1:/m3tP0SJlrfGVnX52eNu/oSo/aFFH2u4NtmcqRCdl/E=
github.com/COVESA/vss-tools/binary/go_parser/parserlib v0.0.0-20231222140420-5343e9c0884d/go.mod h1:rWjamgjPuXRJ5kKJrwibrR1Pe771seoUO/9OauCu/Y4=
github.com/akamensky/argparse v1.4.0 h1:YGzvsTqCvbEZhL8zZu2AiA5nq805NZh75JNj4ajn1xc=
github.com/akamensky/argparse v1.4.0/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down
22 changes: 11 additions & 11 deletions server/agt_server/agt_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Payload struct {
Context string `json:"context"`
Proof string `json:"proof"`
//Key utils.JsonWebKey `json:"key"`
Key string `json:"key"`
Key string `json:"key"`
}

// Handles the request depending on the url and the method for the request
Expand Down Expand Up @@ -143,15 +143,15 @@ func generateResponse(input string, pop string) string {
err := json.Unmarshal([]byte(input), &payload)
if err != nil {
utils.Error.Printf("generateResponse:error input=%s", input)
return `{"error": "Client request malformed"}`
return `{"action": "agt-request", "error": "Client request malformed"}`
}
if authenticateClient(payload) {
if pop != "" {
return generateLTAgt(payload, pop) // In case a pop claim appears, a LT agt must be generated
}
return generateAgt(payload) // In case no pop claim appears, an ST AGT is issued
}
return `{"error": "Client authentication failed"}`
return `{"action": "agt-request", "error": "Client authentication failed"}`
}

// Client roles checking
Expand Down Expand Up @@ -223,27 +223,27 @@ func generateLTAgt(payload Payload, pop string) string {
err := popToken.Unmarshal(pop)
if err != nil {
utils.Error.Printf("generateLTAgt: Error unmarshalling pop, err = %s", err)
return `{"error": "Client request malformed"}`
return `{"action": "agt-request", "error": "Client request malformed"}`
}
if !addCheckJti(popToken.PayloadClaims["jti"]) {
utils.Error.Printf("generateLTAgt: JTI used")
return `{"error": "Repeated JTI"}`
return `{"action": "agt-request", "error": "Repeated JTI"}`
}
err = popToken.CheckSignature()
if err != nil {
utils.Info.Printf("generateLTAgt: Invalid POP signature")
return `{"error": "Invalid POP signature"}`
return `{"action": "agt-request", "error": "Invalid POP signature"}`
}
if ok, info := popToken.Validate(payload.Key, "vissv2/agts", GAP, LIFETIME); !ok {
utils.Info.Printf("generateLTAgt: Not valid POP Token: %s", info)
return `{"error": "Invalid POP Token"}`
return `{"action": "agt-request", "error": "Invalid POP Token"}`
}
// Generates the response token
var jwtoken utils.JsonWebToken
var unparsedId uuid.UUID
if unparsedId, err = uuid.NewRandom(); err != nil { // Better way to generate uuid than calling an ext program
utils.Error.Printf("generateAgt:Error generating uuid, err=%s", err)
return `{"error": "Internal error"}`
return `{"action": "agt-request", "error": "Internal error"}`
}
iat := int(time.Now().Unix())
exp := iat + LT_DURATION // defined by const
Expand All @@ -259,7 +259,7 @@ func generateLTAgt(payload Payload, pop string) string {
//utils.Info.Printf("generateAgt:jwtPayload=%s", jwtoken.GetPayload())
jwtoken.Encode()
jwtoken.AssymSign(privKey)
return `{"token":"` + jwtoken.GetFullToken() + `"}`
return `{"action": "agt-request", "token":"` + jwtoken.GetFullToken() + `"}`
}

// Generates an AGT (short term)
Expand All @@ -268,7 +268,7 @@ func generateAgt(payload Payload) string {
uuid, err := exec.Command("uuidgen").Output()
if err != nil {
utils.Error.Printf("generateAgt:Error generating uuid, err=%s", err)
return `{"error": "Internal error"}`
return `{"action": "agt-request", "error": "Internal error"}`
}
uuid = uuid[:len(uuid)-1] // remove '\n' char
iat := int(time.Now().Unix())
Expand All @@ -285,7 +285,7 @@ func generateAgt(payload Payload) string {
utils.Info.Printf("generateAgt:jwtPayload=%s", jwtoken.GetPayload())
jwtoken.Encode()
jwtoken.AssymSign(privKey)
return `{"token":"` + jwtoken.GetFullToken() + `"}`
return `{"action": "agt-request", "token":"` + jwtoken.GetFullToken() + `"}`
}

func main() {
Expand Down
Binary file removed server/server
Binary file not shown.
Loading

0 comments on commit d5da421

Please sign in to comment.