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

mendersoftware / useradm / 1806832573

08 May 2025 07:30AM UTC coverage: 59.747% (-27.3%) from 87.019%
1806832573

Pull #439

gitlab-ci

alfrunes
chore(docker): Clean up build command for acceptance test image

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #439: :building_construction: Upgrade dependencies

2363 of 3955 relevant lines covered (59.75%)

12.76 hits per line

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

74.19
/api/http/middleware.go
1
// Copyright 2021 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 http
15

16
import (
17
        "errors"
18
        "net/http"
19
        "strings"
20

21
        "github.com/ant0ine/go-json-rest/rest"
22

23
        "github.com/mendersoftware/useradm/authz"
24
)
25

26
func IsVerificationEndpoint(r *rest.Request) bool {
98✔
27
        if r.URL.Path == uriInternalAuthVerify &&
98✔
28
                (r.Method == http.MethodPost || r.Method == http.MethodGet) {
107✔
29
                return true
9✔
30
        } else {
98✔
31
                return false
89✔
32
        }
89✔
33
}
34

35
// ExtractResourceAction extracts resource action from the request url
36
func ExtractResourceAction(r *rest.Request) (*authz.Action, error) {
9✔
37
        action := authz.Action{}
9✔
38

9✔
39
        // extract original uri
9✔
40
        uri := r.Header.Get("X-Forwarded-Uri")
9✔
41
        if uri == "" {
9✔
42
                uri = r.Header.Get("X-Forwarded-URI")
×
43
        }
×
44
        uriItems := strings.Split(uri, "/")
9✔
45

9✔
46
        if uri == "" || len(uriItems) < 4 {
9✔
47
                return nil, errors.New("can't parse service name from original uri " + uri)
×
48
        }
×
49

50
        action.Resource = strings.Join(uriItems[4:], ":")
9✔
51

9✔
52
        // extract original http method
9✔
53
        action.Method = r.Header.Get("X-Forwarded-Method")
9✔
54
        if action.Method == "" {
9✔
55
                action.Method = r.Header.Get("X-Forwarded-Method")
×
56
        }
×
57
        if action.Method == "" {
9✔
58
                return nil, errors.New("can't parse original request method")
×
59
        }
×
60

61
        return &action, nil
9✔
62
}
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