• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FIWARE / VCVerifier / 22361224684

24 Feb 2026 04:27PM UTC coverage: 44.29%. Remained the same
22361224684

Pull #78

github

Mortega5
use minified css instead of cdn
Pull Request #78: Update QR v2 interface

8 of 10 new or added lines in 2 files covered. (80.0%)

175 existing lines in 2 files now uncovered.

1656 of 3739 relevant lines covered (44.29%)

0.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.95
/openapi/api_frontend.go
1
/*
2
 * vcverifier
3
 *
4
 * Backend component to verify credentials
5
 *
6
 * API version: 0.0.1
7
 * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8
 */
9

10
package openapi
11

12
import (
13
        "net/http"
14
        "slices"
15

16
        "github.com/fiware/VCVerifier/common"
17
        "github.com/fiware/VCVerifier/logging"
18
        "github.com/fiware/VCVerifier/verifier"
19

20
        "github.com/gin-gonic/gin"
21
)
22

23
const DEFAULT_REQUEST_MODE = verifier.REQUEST_MODE_BY_REFERENCE
24

25
var frontendVerifier verifier.Verifier
26
var requestObjectClient *verifier.RequestObjectClient
27

28
func getFrontendVerifier() verifier.Verifier {
1✔
29
        if frontendVerifier == nil {
1✔
30
                frontendVerifier = verifier.GetVerifier()
×
31
        }
×
32
        return frontendVerifier
1✔
33
}
34

35
func getRequestObjectClient() *verifier.RequestObjectClient {
×
36
        if requestObjectClient == nil {
×
37
                requestObjectClient = verifier.NewRequestObjectClient()
×
38
        }
×
39
        return requestObjectClient
×
40
}
41

42
// VerifierPageDisplayQRSIOP - Presents a qr as starting point for the auth process
43
func VerifierPageDisplayQRSIOP(c *gin.Context) {
1✔
44

1✔
45
        state, stateExists := c.GetQuery("state")
1✔
46
        if !stateExists {
2✔
47
                c.AbortWithStatusJSON(http.StatusBadRequest, ErrorMessageNoState)
1✔
48
                // early exit
1✔
49
                return
1✔
50
        }
1✔
51

52
        callback, callbackExists := c.GetQuery("client_callback")
1✔
53
        if !callbackExists {
2✔
54
                c.AbortWithStatusJSON(http.StatusBadRequest, ErrorMessageNoCallback)
1✔
55
                // early exit
1✔
56
                return
1✔
57
        }
1✔
58

59
        clientId, clientIdExists := c.GetQuery("client_id")
1✔
60
        if !clientIdExists {
2✔
61
                logging.Log().Infof("Start a login flow for a not specified client.")
1✔
62
        }
1✔
63

64
        nonce, nonceExists := c.GetQuery("nonce")
1✔
65
        if !nonceExists {
2✔
66
                nonce = ""
1✔
67
        }
1✔
68

69
        requestMode, requestModeExists := c.GetQuery("request_mode")
1✔
70
        if !requestModeExists {
2✔
71
                logging.Log().Infof("Using default request mode %s.", DEFAULT_REQUEST_MODE)
1✔
72
                requestMode = DEFAULT_REQUEST_MODE
1✔
73
        }
1✔
74

75
        qr, err := getFrontendVerifier().ReturnLoginQR(c.Request.Host, "https", callback, state, clientId, nonce, requestMode)
1✔
76
        if err != nil {
2✔
77
                c.AbortWithStatusJSON(http.StatusInternalServerError, ErrorMessage{"qr_generation_error", err.Error()})
1✔
78
                return
1✔
79
        }
1✔
80

81
        c.HTML(http.StatusOK, "verifier_present_qr", gin.H{"qrcode": qr})
1✔
82
}
83

84
// VerifierLoginQr - Presents a qr as starting point for the auth process
85
func VerifierLoginQr(c *gin.Context) {
×
86

×
87
        state, stateExists := c.GetQuery("state")
×
88
        if !stateExists {
×
89
                c.AbortWithStatusJSON(http.StatusBadRequest, ErrorMessageNoState)
×
90
                // early exit
×
91
                return
×
92
        }
×
93

94
        redirectUri, redirectUriExists := c.GetQuery("redirect_uri")
×
95
        requestUri, requestUriExists := c.GetQuery("request_uri")
×
96

×
97
        if !redirectUriExists && !requestUriExists {
×
98
                c.AbortWithStatusJSON(http.StatusBadRequest, ErrorMessageNoRedircetUri)
×
99
                // early exit
×
100
                return
×
101
        }
×
102

103
        clientId, clientIdExists := c.GetQuery("client_id")
×
104
        if !clientIdExists {
×
105
                logging.Log().Infof("Start a login flow for a not specified client.")
×
106
        }
×
107

108
        scope, scopeExists := c.GetQuery("scope")
×
109
        if !scopeExists {
×
110
                logging.Log().Infof("Start a login flow with default scope.")
×
111
                scope = ""
×
112
        }
×
113

114
        if requestUriExists {
×
115
                logging.Log().Debug("Requesting the client for its request object.")
×
116
                cro, err := getRequestObjectClient().GetClientRequestObject(requestUri)
×
117
                if err != nil {
×
118
                        logging.Log().Warnf("Was not able to get request object. Err: %v", err)
×
119
                        c.AbortWithStatusJSON(http.StatusInternalServerError, ErrorMessageUnresolvableRequestObject)
×
120
                        return
×
121
                }
×
122
                if !slices.Contains(cro.Aud, getFrontendVerifier().GetHost()) {
×
123
                        c.AbortWithStatusJSON(http.StatusInternalServerError, ErrorMessageInvalidAudience)
×
124
                        return
×
125
                }
×
126

127
                clientId = cro.ClientId
×
128
                scope = cro.Scope
×
129
                redirectUri = cro.RedirectUri
×
130
        }
131

132
        nonce, nonceExists := c.GetQuery("nonce")
×
133
        if !nonceExists {
×
134
                c.AbortWithStatusJSON(http.StatusBadRequest, ErrorMessageNoNonce)
×
135
                // early exit
×
136
                return
×
137
        }
×
138

139
        requestMode, requestModeExists := c.GetQuery("request_mode")
×
140
        if !requestModeExists {
×
141
                logging.Log().Infof("Using default request mode %s.", DEFAULT_REQUEST_MODE)
×
142
                requestMode = DEFAULT_REQUEST_MODE
×
143
        }
×
144

145
        qr, err := getFrontendVerifier().ReturnLoginQRV2(c.Request.Host, "https", redirectUri, state, clientId, scope, nonce, requestMode)
×
146
        if err != nil {
×
147
                c.AbortWithStatusJSON(500, ErrorMessage{"qr_generation_error", err.Error()})
×
148
                return
×
149
        }
×
150

NEW
151
        c.HTML(http.StatusOK, "verifier_present_qr_v2", gin.H{"qrcode": qr, "wsUrl": getFrontendVerifier().GetHost() + "/ws?state=" + state, "qrDuration": common.CacheExpiry})
×
152
}
153

154
// VerifierPageLoginExpired - Presents a page when the login session is expired
155
func VerifierPageLoginExpired(c *gin.Context) {
×
156
        c.JSON(http.StatusOK, gin.H{})
×
157
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc