Skip to content
Merged

dev #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1f815d1
Fixes to DB
maxlandon Aug 16, 2023
80e3326
Add WithTeamDirectory() option to client/servers
maxlandon Aug 17, 2023
1a31b3e
Fix version printing and add method to team.Client interface.
maxlandon Aug 17, 2023
54017bc
Move transports to example directory
maxlandon Aug 17, 2023
2ea0e4a
Print daemon listening status
maxlandon Aug 17, 2023
d8c7c9c
Fix log level not printed in status
maxlandon Aug 17, 2023
5af72d7
Add some stuff to README
maxlandon Aug 17, 2023
8c15e15
Add more to README
maxlandon Aug 17, 2023
c67f6ac
README
maxlandon Aug 17, 2023
6880015
Add code examples to readme
maxlandon Aug 17, 2023
ee2f75b
README
maxlandon Aug 17, 2023
48fc6a4
README Examples
maxlandon Aug 17, 2023
e403916
README
maxlandon Aug 17, 2023
81f898e
Differences with Hashicorp plugins
maxlandon Aug 17, 2023
dd0e577
Add README to example
maxlandon Aug 17, 2023
4c4dd5f
README
maxlandon Aug 17, 2023
d0a84a2
README
maxlandon Aug 17, 2023
deac495
Update ncruces/sqlite dependencies
maxlandon Aug 17, 2023
8435ef0
Use go1.21 in actions
maxlandon Aug 17, 2023
22bce36
Fix cgo build
maxlandon Aug 17, 2023
f77d921
Try to fix actions CodeQL
maxlandon Aug 17, 2023
eeb6493
Tidy comments
maxlandon Aug 17, 2023
3b6554d
Tidy comments
maxlandon Aug 17, 2023
7fd7c8b
Cleanup and comments tidying
maxlandon Aug 17, 2023
1840d40
Fix actions
maxlandon Aug 17, 2023
14dde50
Remove logging of cleartext credentials
maxlandon Aug 17, 2023
be74c02
Fix imports
maxlandon Aug 17, 2023
2aac56a
Fix client imports
maxlandon Aug 17, 2023
de56f43
Fix and restructure imports
maxlandon Aug 17, 2023
f5b58ee
Fix windows action
maxlandon Aug 17, 2023
754c8ea
Finish server examples code
maxlandon Aug 17, 2023
e11fb0e
Merge branch 'main' into dev
maxlandon Aug 17, 2023
6ba1009
Fix imports and update survey version
maxlandon Aug 17, 2023
bfaf8ef
Fix imports AGAIN
maxlandon Aug 17, 2023
c8e8313
Fix wrong server configs directory usage
maxlandon Aug 17, 2023
83753bc
Fixes to security alerts
maxlandon Aug 17, 2023
9d570b3
Update dependencies
maxlandon Dec 20, 2023
bb9d1e2
Remove useless imports in cgo build
maxlandon Dec 20, 2023
f2791a9
Format
maxlandon Dec 20, 2023
5f78601
Merge branch 'main' into dev
maxlandon Dec 20, 2023
e4c9c91
Fix and clean the user permissions system
maxlandon Feb 12, 2025
849ae28
Update cobra
maxlandon Feb 12, 2025
1bd9206
Merge branch 'main' into dev
maxlandon Feb 12, 2025
5ae5008
Fix examples
maxlandon Feb 12, 2025
c3ce338
Merge branch 'main' into dev
maxlandon Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions example/transports/grpc/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ import (
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
grpc_tags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"github.com/reeflective/team/example/transports/grpc/common"
"github.com/reeflective/team/server"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"

"github.com/reeflective/team/example/transports/grpc/common"
"github.com/reeflective/team/server"
)

// BufferingOptions returns a list of server options with max send/receive
Expand Down Expand Up @@ -139,6 +138,7 @@ func (ts *Teamserver) initAuthMiddleware() ([]grpc.ServerOption, error) {
requestOpts = append(requestOpts,
grpc_auth.UnaryServerInterceptor(serverAuthFunc),
)

streamOpts = append(streamOpts,
grpc_auth.StreamServerInterceptor(serverAuthFunc),
)
Expand Down Expand Up @@ -166,23 +166,27 @@ func serverAuthFunc(ctx context.Context) (context.Context, error) {
return newCtx, nil
}

// tokenAuthFunc uses the core reeflective/team/server to authenticate user requests.
func (ts *Teamserver) tokenAuthFunc(ctx context.Context) (context.Context, error) {
log := ts.NamedLogger("transport", "grpc")
log.Debugf("Auth interceptor checking user token ...")

rawToken, err := grpc_auth.AuthFromMD(ctx, "Bearer")
if err != nil {
log.Errorf("Authentication failure: %s", err)
return nil, status.Error(codes.Unauthenticated, "Authentication failure")
}

// Let our core teamserver driver authenticate the user.
// The teamserver has its credentials, tokens and everything in database.
user, authorized, err := ts.UserAuthenticate(rawToken)
if err != nil || !authorized || user == "" {
if err != nil || !authorized || user.Name == "" {
log.Errorf("Authentication failure: %s", err)
return nil, status.Error(codes.Unauthenticated, "Authentication failure")
}

newCtx := context.WithValue(ctx, Transport, "mtls")
// Fetch the user in database for permissions.

newCtx := context.WithValue(ctx, Transport, user)
newCtx = context.WithValue(newCtx, User, user)

return newCtx, nil
Expand Down
7 changes: 3 additions & 4 deletions example/transports/grpc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ import (
"runtime/debug"
"sync"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"

clientConn "github.com/reeflective/team/example/transports/grpc/client"
"github.com/reeflective/team/example/transports/grpc/proto"
teamserver "github.com/reeflective/team/server"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
)

const (
Expand Down