GitLabgitlab-org
cli
main
1package dpop
3import (
4 "crypto/ecdsa"
5 "crypto/ed25519"
6 "crypto/rsa"
7 "encoding/base64"
8 "fmt"
9 "math/big"
11 "github.com/golang-jwt/jwt/v5"
12)
14/*
15MIT License
17Copyright (c) 2023 Software go-dpop
18Portions Copyright 2024 Gitlab B.V
19Permission is hereby granted, free of charge, to any person obtaining a copy
20of this software and associated documentation files (the "Software"), to deal
21in the Software without restriction, including without limitation the rights
22to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23copies of the Software, and to permit persons to whom the Software is
24furnished to do so, subject to the following conditions:
26The above copyright notice and this permission notice shall be included in all
27copies or substantial portions of the Software.
29THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35SOFTWARE.
36*/
38type ecdsaJWK struct {
39 X string `json:"x"`
40 Y string `json:"y"`
41 Crv string `json:"crv"`
42 Kty string `json:"kty"`
43}
45type rsaJWK struct {
46 Exponent string `json:"e"`
47 Modulus string `json:"n"`
48 Kty string `json:"kty"`
49}
51type ed25519JWK struct {
52 PublicKey string `json:"x"`
53 Kty string `json:"kty"`
54}
56type HTTPVerb string
58// HTTP method supported by the package.
59const (
60 GET HTTPVerb = "GET"
61 POST HTTPVerb = "POST"
62 PUT HTTPVerb = "PUT"
63 DELETE HTTPVerb = "DELETE"
64 PATCH HTTPVerb = "PATCH"
65 HEAD HTTPVerb = "HEAD"
66 OPTIONS HTTPVerb = "OPTIONS"
67 TRACE HTTPVerb = "TRACE"
68 CONNECT HTTPVerb = "CONNECT"
69)
71type ProofTokenClaims struct {
72 *jwt.RegisteredClaims
74 // the `htm` (HTTP Method) claim. See https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop#section-4.2
75 Method HTTPVerb `json:"htm"`
77 // the `htu` (HTTP URL) claim. See https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop#section-4.2
78 URL string `json:"htu"`
80 // the `ath` (Authorization Token Hash) claim. See https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop#section-4.2
81 AccessTokenHash string `json:"ath,omitempty"`
83 // the `nonce` claim. See https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop#section-4.2
84 Nonce string `json:"nonce,omitempty"`
85}
87func Reflect(v any) (any, error) {
88 switch v := v.(type) {
89 case *ecdsa.PublicKey:
90 ecdhKey, err := v.ECDH()
91 if err != nil {
92 return nil, err
93 }
94 b := ecdhKey.Bytes()
95 byteLen := (v.Curve.Params().BitSize + 7) / 8
96 return &ecdsaJWK{
97 X: base64.RawURLEncoding.EncodeToString(b[1 : 1+byteLen]),
98 Y: base64.RawURLEncoding.EncodeToString(b[1+byteLen:]),
99 Crv: v.Curve.Params().Name,
100 Kty: "EC",
101 }, nil
102 case *rsa.PublicKey:
103 return &rsaJWK{
104 Exponent: base64.RawURLEncoding.EncodeToString(big.NewInt(int64(v.E)).Bytes()),
105 Modulus: base64.RawURLEncoding.EncodeToString(v.N.Bytes()),
106 Kty: "RSA",
107 }, nil
108 case ed25519.PublicKey:
109 return &ed25519JWK{
110 PublicKey: base64.RawURLEncoding.EncodeToString(v),
111 Kty: "OKP",
112 }, nil
113 }
114 return nil, fmt.Errorf("unsupported key type")
115}
Diagnostics9 git calls · 240 ms
CallStatusSizeTime0240 ms
discover200185 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=185 git.server.agent=git/2.56.g1891de4-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=185 git.pkt.payload.max=35
ls-refs20058 KiB · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=59849 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=731 git.pkt.data=730 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=59849 git.pkt.payload.max=143 git.ls_refs.count=730 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=32926 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=22 git.pkt.data=20 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=32926 git.pkt.payload.max=32046 git.sideband.band1.bytes=32046 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=80 git.pack.bytes=32046 git.pack.ofs_delta=36 git.pack.ref_delta=0 git.pack.chain.max=2 git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91 git.pack.full=44Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=4 git.response.bytes=4273 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4273 git.pkt.payload.max=4173 git.sideband.band1.bytes=4173 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=11 git.pack.bytes=4173 git.fetch.wide.objects=11 git.fetch.wide.extra_bytes=3930 git.fetch.wide.blobs=0
fetchtree:02001.8 KiB · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=4 git.response.bytes=1857 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=tree:0 git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1857 git.pkt.payload.max=1830 git.sideband.band1.bytes=1830 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=1830 git.pack.trailer=fb03183b7909876778f740d196d7516811003517Open pack map
fetchtree:0200358 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=358 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=5d783fac547a70b19ca138c47d067b44febb52da git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=358 git.pkt.payload.max=331 git.sideband.band1.bytes=331 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=331 git.pack.trailer=22a484e5ecad6d6e62b224e8a7f90cf5ff085938Open pack map
fetchtree:0200204 B · hit5 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=5 git.response.bytes=204 git.response.cache=HIT git.response.duration_ms=5 git.fetch.filter=tree:0 git.fetch.wants=7f57e69c1796ef0dd4d7877c582d94d8a96a5369 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=204 git.pkt.payload.max=177 git.sideband.band1.bytes=177 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=177 git.pack.trailer=abcd288a8924fff99397ff5cd51aa278233a24e2Open pack map
fetchtree:0200105 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=105 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=37ff40e56d51c8178db72b54848ed116c86d0943 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=105 git.pkt.payload.max=78 git.sideband.band1.bytes=78 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=78 git.pack.trailer=d97b8d185cfecd384628757198783aa6ca2ad22fOpen pack map
fetch2001.5 KiB218 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=218 git.response.bytes=1587 git.response.cache=MISS git.response.duration_ms=218 git.fetch.wants=8b669c0c41a66e4cf860462569ccad31a49741a7 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1587 git.pkt.payload.max=1560 git.sideband.band1.bytes=1560 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://gitlab.com/gitlab-org/cli
- Ref
- refs/heads/main
- Commit
- 0dd7574dce9e385c5c30540e6c15657adc6bdce9
- cf-ray
- a5e2f71ceb973a24
- Request
- 23696930…
- Protocol
- v2 · sha1
- Agent
- git/2.56.g1891de4-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format