-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
168 lines (154 loc) · 5.64 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package authzr
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
)
// authzr server interface.
type AuthzrServer interface {
// The AuthzrFreeContext method (opnum 0) frees all remote structures and memory associated
// with the client context identified by the ContextHandle parameter.
//
// Return Values:
//
// If the function succeeds, it MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero 32-bit error code.
//
// When a remote authorization server receives this message, it MUST look up the ClientContext
// structure in the ClientContextTable ADM element and free all structures and memory
// associated with the ClientContext.
FreeContext(context.Context, *FreeContextRequest) (*FreeContextResponse, error)
// The AuthzrInitializeContextFromSid method (opnum 1) creates a client context from
// a given security identifier (SID). For domain SIDs, token group and claim attributes
// will be retrieved from Active Directory through Kerberos.
//
// Return Values:
//
// If the function succeeds, the function MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero error code.
InitializeContextFromSID(context.Context, *InitializeContextFromSIDRequest) (*InitializeContextFromSIDResponse, error)
// The AuthzrInitializeCompoundContext method (opnum 2) creates a compound context from
// two specified context handles.
//
// Return Values:
//
// If the function succeeds, the function MUST return 0x00000000. If the function fails,
// it MUST return a nonzero value.
InitializeCompoundContext(context.Context, *InitializeCompoundContextRequest) (*InitializeCompoundContextResponse, error)
// The AuthzrAccessCheck method (opnum 3) determines which access bits can be granted
// to a client for a given set of security descriptors. The AUTHZR_ACCESS_REPLY structure
// returns an array of granted access masks and error status.
//
// Return Values:
//
// If the function succeeds, the function MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero error code.
AccessCheck(context.Context, *AccessCheckRequest) (*AccessCheckResponse, error)
// The AuthzGetInformationFromContext method (opnum 4) returns information about the
// identified client context.
//
// Return Values:
//
// If the function succeeds, the function MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero error code value.
GetInformationFromContext(context.Context, *GetInformationFromContextRequest) (*GetInformationFromContextResponse, error)
// The AuthzrModifyClaims method (opnum 5) modifies information about the identified
// client context.
//
// Return Values:
//
// If the function succeeds, the function MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero error code value.
ModifyClaims(context.Context, *ModifyClaimsRequest) (*ModifyClaimsResponse, error)
// The AuthzrModifySids method (opnum 6) modifies the list of SIDs associated with the
// identified client context.
//
// Return Values:
//
// If the function succeeds, it MUST return 0x00000000.
//
// If the function fails, it MUST return a nonzero error code value.
ModifySIDs(context.Context, *ModifySIDsRequest) (*ModifySIDsResponse, error)
}
func RegisterAuthzrServer(conn dcerpc.Conn, o AuthzrServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewAuthzrServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(AuthzrSyntaxV0_0))...)
}
func NewAuthzrServerHandle(o AuthzrServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return AuthzrServerHandle(ctx, o, opNum, r)
}
}
func AuthzrServerHandle(ctx context.Context, o AuthzrServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
switch opNum {
case 0: // AuthzrFreeContext
in := &FreeContextRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.FreeContext(ctx, in)
return resp.xxx_ToOp(ctx), err
case 1: // AuthzrInitializeContextFromSid
in := &InitializeContextFromSIDRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.InitializeContextFromSID(ctx, in)
return resp.xxx_ToOp(ctx), err
case 2: // AuthzrInitializeCompoundContext
in := &InitializeCompoundContextRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.InitializeCompoundContext(ctx, in)
return resp.xxx_ToOp(ctx), err
case 3: // AuthzrAccessCheck
in := &AccessCheckRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.AccessCheck(ctx, in)
return resp.xxx_ToOp(ctx), err
case 4: // AuthzGetInformationFromContext
in := &GetInformationFromContextRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetInformationFromContext(ctx, in)
return resp.xxx_ToOp(ctx), err
case 5: // AuthzrModifyClaims
in := &ModifyClaimsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ModifyClaims(ctx, in)
return resp.xxx_ToOp(ctx), err
case 6: // AuthzrModifySids
in := &ModifySIDsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ModifySIDs(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}