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

mendersoftware / useradm / 1337903039

04 Jun 2024 10:02AM UTC coverage: 85.226%. Remained the same
1337903039

push

gitlab-ci

web-flow
Merge pull request #425 from mendersoftware/dependabot/go_modules/golang-dependencies-8c34a824dd

chore: bump the golang-dependencies group with 2 updates

2792 of 3276 relevant lines covered (85.23%)

49.04 hits per line

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

81.82
/authz_simple.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 main
15

16
import (
17
        "context"
18

19
        "github.com/mendersoftware/useradm/authz"
20
        "github.com/mendersoftware/useradm/jwt"
21
        "github.com/mendersoftware/useradm/scope"
22
)
23

24
// SimpleAuthz is a trivial authorizer, mostly ensuring
25
// proper permission check for the 'create initial user' case.
26
type SimpleAuthz struct {
27
}
28

29
// Authorize makes SimpleAuthz implement the Authorizer interface.
30
func (sa *SimpleAuthz) Authorize(
31
        _ context.Context,
32
        token *jwt.Token,
33
        resource,
34
        action string,
35
) error {
15✔
36
        if token == nil {
15✔
37
                return authz.ErrAuthzUnauthorized
×
38
        }
×
39

40
        tokenScope := token.Claims.Scope
15✔
41

15✔
42
        // allow all actions on all services for 'mender.*'
15✔
43
        if tokenScope == scope.All {
29✔
44
                return nil
14✔
45
        }
14✔
46

47
        return authz.ErrAuthzUnauthorized
1✔
48
}
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