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

mendersoftware / mender-server / 1978354074

11 Aug 2025 05:31PM UTC coverage: 65.755% (+0.3%) from 65.495%
1978354074

Pull #862

gitlab-ci

web-flow
chore: bump the development-dependencies group across 1 directory with 11 updates

Bumps the development-dependencies group with 11 updates in the /frontend directory:

| Package | From | To |
| --- | --- | --- |
| [@rspack/cli](https://github.com/web-infra-dev/rspack/tree/HEAD/packages/rspack-cli) | `1.4.8` | `1.4.11` |
| [@rspack/core](https://github.com/web-infra-dev/rspack/tree/HEAD/packages/rspack) | `1.4.8` | `1.4.11` |
| [@sentry/webpack-plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins) | `4.0.0` | `4.0.2` |
| [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) | `6.6.3` | `6.6.4` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `24.1.0` | `24.2.1` |
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `8.38.0` | `8.39.0` |
| [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) | `4.7.0` | `5.0.0` |
| [core-js](https://github.com/zloirock/core-js/tree/HEAD/packages/core-js) | `3.44.0` | `3.45.0` |
| [lint-staged](https://github.com/lint-staged/lint-staged) | `16.1.2` | `16.1.5` |
| [typescript](https://github.com/microsoft/TypeScript) | `5.7.3` | `5.9.2` |
| [undici](https://github.com/nodejs/undici) | `7.12.0` | `7.13.0` |



Updates `@rspack/cli` from 1.4.8 to 1.4.11
- [Release notes](https://github.com/web-infra-dev/rspack/releases)
- [Commits](https://github.com/web-infra-dev/rspack/commits/v1.4.11/packages/rspack-cli)

Updates `@rspack/core` from 1.4.8 to 1.4.11
- [Release notes](https://github.com/web-infra-dev/rspack/releases)
- [Commits](https://github.com/web-infra-dev/rspack/commits/v1.4.11/packages/rspack)

Updates `@sentry/webpack-plugin` from 4.0.0 to 4.0.2
- [Release notes](https://github.com/getsentry/sentry-javascript-bundler-plugins/releases)
- [Changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob... (continued)
Pull Request #862: chore: bump the development-dependencies group across 1 directory with 11 updates

29261 of 44500 relevant lines covered (65.76%)

1.44 hits per line

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

77.27
/backend/pkg/identity/token.go
1
// Copyright 2024 Northern.tech AS
2
//
3
//        Licensed under the Apache License, Version 2.0 (the "License");
4
//        you may not use this file except in compliance with the License.
5
//        You may obtain a copy of the License at
6
//
7
//            http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//        Unless required by applicable law or agreed to in writing, software
10
//        distributed under the License is distributed on an "AS IS" BASIS,
11
//        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//        See the License for the specific language governing permissions and
13
//        limitations under the License.
14
package identity
15

16
import (
17
        "encoding/base64"
18
        "encoding/json"
19
        "net/http"
20
        "strings"
21

22
        "github.com/pkg/errors"
23

24
        "github.com/mendersoftware/mender-server/pkg/addons"
25
)
26

27
type Identity struct {
28
        Subject  string         `json:"sub" valid:"required"`
29
        Tenant   string         `json:"mender.tenant,omitempty"`
30
        IsUser   bool           `json:"mender.user,omitempty"`
31
        IsDevice bool           `json:"mender.device,omitempty"`
32
        Plan     string         `json:"mender.plan,omitempty"`
33
        Addons   []addons.Addon `json:"mender.addons,omitempty"`
34
        Trial    bool           `json:"mender.trial"`
35
}
36

37
// ExtractJWTFromHeader inspect the Authorization header for a Bearer token and
38
// if not present looks for a "JWT" cookie.
39
func ExtractJWTFromHeader(r *http.Request) (jwt string, err error) {
8✔
40
        auth := r.Header.Get("Authorization")
8✔
41
        if auth == "" {
12✔
42
                jwtCookie, err := r.Cookie("JWT")
4✔
43
                if err != nil {
7✔
44
                        return "", errors.New("Authorization not present in header")
3✔
45
                }
3✔
46
                jwt = jwtCookie.Value
1✔
47
        } else {
8✔
48
                auths := strings.Split(auth, " ")
8✔
49

8✔
50
                if len(auths) != 2 {
10✔
51
                        return "", errors.Errorf("malformed Authorization header")
2✔
52
                }
2✔
53

54
                if !strings.EqualFold(auths[0], "Bearer") {
8✔
55
                        return "", errors.Errorf("unknown Authorization method %s", auths[0])
×
56
                }
×
57
                jwt = auths[1]
8✔
58
        }
59
        return jwt, nil
8✔
60
}
61

62
// Generate identity information from given JWT by extracting subject and tenant claims.
63
// Note that this function does not perform any form of token signature
64
// verification.
65
func ExtractIdentity(token string) (id Identity, err error) {
8✔
66
        var (
8✔
67
                claims []byte
8✔
68
                jwt    []string
8✔
69
        )
8✔
70
        jwt = strings.Split(token, ".")
8✔
71
        if len(jwt) != 3 {
10✔
72
                return id, errors.New("identity: incorrect token format")
2✔
73
        }
2✔
74
        claims, err = base64.RawURLEncoding.DecodeString(jwt[1])
8✔
75
        if err != nil {
8✔
76
                return id, errors.Wrap(err,
×
77
                        "identity: failed to decode base64 JWT claims")
×
78
        }
×
79
        err = json.Unmarshal(claims, &id)
8✔
80
        if err != nil {
8✔
81
                return id, errors.Wrap(err,
×
82
                        "identity: failed to decode JSON JWT claims")
×
83
        }
×
84
        return id, id.Validate()
8✔
85
}
86

87
func (id Identity) Validate() error {
8✔
88
        if id.Subject == "" {
8✔
89
                return errors.New("identity: claim \"sub\" is required")
×
90
        }
×
91
        return nil
8✔
92
}
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

© 2025 Coveralls, Inc