Skip to content

Commit

Permalink
Portal and changes in qr code generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
masv3971 committed Nov 20, 2024
1 parent a7a9f5c commit e5f855d
Show file tree
Hide file tree
Showing 38 changed files with 356 additions and 2,516 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"sarama",
"Satosa",
"SATOSAV",
"schac",
"SDJWT",
"sdktrace",
"semconv",
Expand All @@ -55,6 +56,7 @@
"skatteverket",
"stretchr",
"SUNET",
"SVGID",
"swaggo",
"timestamppb",
"VCTM"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ build-ui:
$(info Building ui)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./bin/$(NAME)_ui ${LDFLAGS} ./cmd/ui/main.go

docker-build: docker-build-verifier docker-build-registry docker-build-persistent docker-build-mockas docker-build-apigw docker-build-issuer docker-build-ui
docker-build: docker-build-verifier docker-build-registry docker-build-persistent docker-build-mockas docker-build-apigw docker-build-issuer docker-build-ui docker-build-portal

docker-build-goland-debug: docker-build-verifier docker-build-registry docker-build-persistent docker-build-mockas docker-build-apigw docker-build-issuer docker-build-ui-goland-debug

Expand Down Expand Up @@ -154,7 +154,7 @@ docker-push-portal:
$(info Pushing docker images)
docker push $(DOCKER_TAG_PORTAL)

docker-push: docker-push-verifier docker-push-registry docker-push-persistent docker-push-apigw docker-push-issuer docker-push-ui docker-push-mockas
docker-push: docker-push-verifier docker-push-registry docker-push-persistent docker-push-apigw docker-push-issuer docker-push-ui docker-push-mockas docker-push-portal
$(info Pushing docker images)

docker-tag-apigw:
Expand Down
2 changes: 1 addition & 1 deletion cmd/portal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
// main function log
mainLog := log.New("main")

tracer, err := trace.NewForTesting(ctx, serviceName, log)
tracer, err := trace.New(ctx, cfg, serviceName, log)
if err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ common:
type: jaeger
#timeout: 10
qr:
base_url: "http://vc_dev_apigw:8080"
recovery_level: 2
size: 256
issuing_base_url: https://satosa-test-1.sunet.se
kafka:
enabled: false
brokers:
Expand Down Expand Up @@ -63,6 +63,7 @@ issuer:
enable_not_before: true
valid_duration: 3600
verifiable_credential_type: "https://credential.sunet.se/identity_credential"
static_host: "http://vc_dev_portal:8080/statics"

verifier:
api_server:
Expand Down
49 changes: 31 additions & 18 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ services:
environment:
- "VC_CONFIG_YAML=config.yaml"

# mockas2:
# container_name: "vc_dev_mockas2"
# image: docker.sunet.se/dc4eu/mockas:latest
# restart: always
# volumes:
# - ./config.yaml:/config.yaml:ro
# depends_on:
# - kafka0
# - kafka1
# networks:
# vc-dev-net:
# ipv4_address: 172.16.50.23
# environment:
# - "VC_CONFIG_YAML=config.yaml"
# mockas2:
# container_name: "vc_dev_mockas2"
# image: docker.sunet.se/dc4eu/mockas:latest
# restart: always
# volumes:
# - ./config.yaml:/config.yaml:ro
# depends_on:
# - kafka0
# - kafka1
# networks:
# vc-dev-net:
# ipv4_address: 172.16.50.23
# environment:
# - "VC_CONFIG_YAML=config.yaml"

mongo:
image: mongo:4.0.10
Expand All @@ -141,6 +141,19 @@ services:
vc-dev-net:
ipv4_address: 172.16.50.20

portal:
image: docker.sunet.se/dc4eu/portal:latest
container_name: "vc_dev_portal"
restart: always
volumes:
- ./config.yaml:/config.yaml:ro
- ./statics:/statics:ro
networks:
vc-dev-net:
ipv4_address: 172.16.50.24
environment:
- "VC_CONFIG_YAML=config.yaml"

jaeger:
image: jaegertracing/all-in-one:latest
container_name: vc_dev_jaeger
Expand Down Expand Up @@ -254,7 +267,7 @@ networks:
- subnet: 172.16.50.0/24
volumes:
mongo_data:
# kraft0-data:
# driver: local
# kraft1-data:
# driver: local
# kraft0-data:
# driver: local
# kraft1-data:
# driver: local
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/lestrrat-go/jwx v1.2.30
github.com/lithammer/shortuuid/v4 v4.0.0
github.com/moogar0880/problems v0.1.1
github.com/pbnjay/grate v0.0.0-20231006022435-3f8e65d74a14
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v1.0.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/moogar0880/problems v0.1.1 h1:bktLhq8NDG/czU2ZziYNigBFksx13RaYe5AVdNmHDT4=
github.com/moogar0880/problems v0.1.1/go.mod h1:5Dxrk2sD7BfBAgnOzQ1yaTiuCYdGPUh49L8Vhfky62c=
github.com/pbnjay/grate v0.0.0-20231006022435-3f8e65d74a14 h1:ZfXdW7GIVZT3Z9oejLJ+GHrrQv/ezU2Bwqn0BF37s4g=
github.com/pbnjay/grate v0.0.0-20231006022435-3f8e65d74a14/go.mod h1:VaZEKQrYbYr2untVA/EFNdC6hM7GyARRNM+k4+5CmA0=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/apigw/apiv1/handlers_datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type UploadRequest struct {
// @Param req body UploadRequest true " "
// @Router /upload [post]
func (c *Client) Upload(ctx context.Context, req *UploadRequest) error {
qr, err := req.Meta.QRGenerator(ctx, c.cfg.Common.QR.BaseURL, c.cfg.Common.QR.RecoveryLevel, c.cfg.Common.QR.Size)
qr, err := req.Meta.QRGenerator(ctx, c.cfg.Common.QR.IssuingBaseURL, c.cfg.Common.QR.RecoveryLevel, c.cfg.Common.QR.Size)
if err != nil {
c.log.Debug("QR code generation failed", "error", err)
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/issuer/apiv1/echic_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c *ehicClient) MetadataClaim(vct string) ([]string, error) {
Rendering: Rendering{
Simple: SimpleRendering{
Logo: Logo{
URI: fmt.Sprintf("%s/ehicCard.png", c.client.cfg.Issuer.JWTAttribute.Issuer),
URI: fmt.Sprintf("%s/ehicCard.png", c.client.cfg.Issuer.JWTAttribute.StaticHost),
URIIntegrity: "sha256-94445b2ca72e9155260c8b4879112df7677e8b3df3dcee9b970b40534e26d4ab",
AltText: "EHIC Card",
},
Expand All @@ -33,7 +33,7 @@ func (c *ehicClient) MetadataClaim(vct string) ([]string, error) {
},
SVGTemplates: []SVGTemplates{
{
URI: fmt.Sprintf("%s/ehicTemplate.png", c.client.cfg.Issuer.JWTAttribute.Issuer),
URI: fmt.Sprintf("%s/ehicTemplate.png", c.client.cfg.Issuer.JWTAttribute.StaticHost),
URLIntegrity: "",
Properties: SVGTemplateProperties{},
},
Expand Down
1 change: 0 additions & 1 deletion internal/issuer/apiv1/jwk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func mockClient(t *testing.T) *Client {
Type: "jaeger",
Timeout: 0,
},
Queues: model.Queues{},
KeyValue: model.KeyValue{},
QR: model.QRCfg{},
Kafka: model.Kafka{},
Expand Down
4 changes: 2 additions & 2 deletions internal/issuer/apiv1/pda1_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *pda1Client) MetadataClaim(vct string) ([]string, error) {
Rendering: Rendering{
Simple: SimpleRendering{
Logo: Logo{
URI: fmt.Sprintf("%s/pda1.png", c.client.cfg.Issuer.JWTAttribute.Issuer),
URI: fmt.Sprintf("%s/pda1.png", c.client.cfg.Issuer.JWTAttribute.StaticHost),
URIIntegrity: "sha256-94445b2ca72e9155260c8b4879112df7677e8b3df3dcee9b970b40534e26d4ab",
AltText: "PDA1 Card",
},
Expand All @@ -84,7 +84,7 @@ func (c *pda1Client) MetadataClaim(vct string) ([]string, error) {
},
SVGTemplates: []SVGTemplates{
{
URI: fmt.Sprintf("%s/pda1Template.svg", c.client.cfg.Issuer.JWTAttribute.Issuer),
URI: fmt.Sprintf("%s/pda1Template.svg", c.client.cfg.Issuer.JWTAttribute.StaticHost),
URLIntegrity: "",
Properties: SVGTemplateProperties{},
},
Expand Down
Empty file.
72 changes: 64 additions & 8 deletions internal/mockas/paris_users/xls.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package parisusers

import (
"encoding/csv"
"fmt"
"os"
"strings"
"vc/pkg/ehic"
"vc/pkg/model"
"vc/pkg/pda1"

"github.com/lithammer/shortuuid/v4"
"github.com/xuri/excelize/v2"
)

Expand All @@ -29,9 +30,9 @@ func makePID(fs *excelize.File) map[string]*model.CompleteDocument {
DocumentDataVersion: "1.0.0",
Identities: []model.Identity{
{
AuthenticSourcePersonID: "",
AuthenticSourcePersonID: fmt.Sprintf("authentic_source_person_id_%s", row[0]),
Schema: &model.IdentitySchema{
Name: "SE",
Name: "FR",
Version: "",
},
FamilyName: row[6],
Expand Down Expand Up @@ -76,6 +77,7 @@ func EHIC(sourceFilePath string) []model.CompleteDocument {
SocialSecurityPin := row[4]
startDate := row[5]
endDate := row[6]

CardNumber := row[7]
InstitutionID := row[8]
InstitutionName := row[9]
Expand Down Expand Up @@ -115,10 +117,10 @@ func EHIC(sourceFilePath string) []model.CompleteDocument {
AuthenticSource: row[2],
DocumentVersion: "1.0.0",
DocumentType: "EHIC",
DocumentID: fmt.Sprintf("document_id_%s", shortuuid.New()),
DocumentID: fmt.Sprintf("document_id_ehic_%s", row[0]),
RealData: false,
Collect: &model.Collect{
ID: fmt.Sprintf("collect_id_%s", shortuuid.New()),
ID: fmt.Sprintf("collect_id_ehic_%s", row[0]),
ValidUntil: 0,
},
Revocation: &model.Revocation{},
Expand All @@ -127,6 +129,19 @@ func EHIC(sourceFilePath string) []model.CompleteDocument {
DocumentDataValidationRef: "",
}

user.DocumentDisplay = &model.DocumentDisplay{
Version: "1.0.0",
Type: "secure",
DescriptionStructured: map[string]any{
"en": map[string]any{
"documentType": "EHIC",
},
"sv": map[string]any{
"documentType": "EHIC",
},
},
}

}

list := []model.CompleteDocument{}
Expand Down Expand Up @@ -235,13 +250,13 @@ func PDA1(sourceFilePath string) []model.CompleteDocument {
}

user.Meta = &model.MetaData{
AuthenticSource: row[2],
AuthenticSource: row[3],
DocumentVersion: "1.0.0",
DocumentType: "PDA1",
DocumentID: fmt.Sprintf("document_id_%s", shortuuid.New()),
DocumentID: fmt.Sprintf("document_id_pda1_%s", row[0]),
RealData: false,
Collect: &model.Collect{
ID: fmt.Sprintf("collect_id_%s", shortuuid.New()),
ID: fmt.Sprintf("collect_id_pda1_%s", row[0]),
ValidUntil: 0,
},
Revocation: &model.Revocation{},
Expand All @@ -250,6 +265,19 @@ func PDA1(sourceFilePath string) []model.CompleteDocument {
DocumentDataValidationRef: "",
}

user.DocumentDisplay = &model.DocumentDisplay{
Version: "1.0.0",
Type: "secure",
DescriptionStructured: map[string]any{
"en": map[string]any{
"documentType": "PDA1",
},
"sv": map[string]any{
"documentType": "PDA1",
},
},
}

}

list := []model.CompleteDocument{}
Expand All @@ -264,3 +292,31 @@ func PDA1(sourceFilePath string) []model.CompleteDocument {
func Make(filePath string) []model.CompleteDocument {
return append(EHIC(filePath), PDA1(filePath)...)
}

// CSV converts a list of CompleteDocument to CSV and writes it to a file
func CSV(docs model.CompleteDocuments) ([]string, [][]string, error) {
fs, err := os.Create("pda1_users.csv")
if err != nil {
return nil, nil, err
}
defer fs.Close()

return docs.CSV()

}

func saveCSVToDisk(records [][]string, filePath string) error {
f, err := os.Create(filePath)
defer f.Close()
if err != nil {
return err
}

w := csv.NewWriter(f)
defer w.Flush()

if err := w.WriteAll(records); err != nil {
return err
}
return nil
}
20 changes: 20 additions & 0 deletions internal/mockas/paris_users/xls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package parisusers

import (
"encoding/json"
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -29,3 +30,22 @@ func TestMake(t *testing.T) {

assert.Len(t, storage, 160)
}

func TestCSV(t *testing.T) {
storage := Make("testdata/users_paris.xlsx")
csv, _, err := CSV(storage)
assert.NoError(t, err)

fmt.Printf("\nauthentic_source_person_id,given_name,family_name,birth_date,identity schema name,authentic_source,collect_id,document_type\n")
fmt.Printf("%v", csv)

}

func TestSaveCSVToDisk(t *testing.T) {
storage := Make("testdata/users_paris.xlsx")
_, records, err := CSV(storage)
assert.NoError(t, err)

err = saveCSVToDisk(records, "../../../users_paris.csv")
assert.NoError(t, err)
}
16 changes: 16 additions & 0 deletions internal/portal/apiv1/handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package apiv1

import (
"context"
"vc/internal/gen/status/apiv1_status"
"vc/pkg/model"
)

// Status return status for each ladok instance
func (c *Client) Status(ctx context.Context, req *apiv1_status.StatusRequest) (*apiv1_status.StatusReply, error) {
probes := model.Probes{}

status := probes.Check("registry")

return status, nil
}
7 changes: 6 additions & 1 deletion internal/portal/httpserver/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package httpserver

import (
"context"
"vc/internal/gen/status/apiv1_status"
)

// Apiv1 interface
type Apiv1 interface {
// leaved empty for portal implementation later
Status(ctx context.Context, req *apiv1_status.StatusRequest) (*apiv1_status.StatusReply, error)
}
Loading

0 comments on commit e5f855d

Please sign in to comment.