Skip to content

Commit 01e624a

Browse files
Support client_credentials grant (a.k.a. M2M)
2 parents ff88df4 + c2a8f60 commit 01e624a

216 files changed

Lines changed: 13951 additions & 724 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Provided the graphql schema: ./portal/src/graphql/adminapi/schema.graphql
2+
3+
Add .graphql a file under ./portal/src/graphql/adminapi/mutations for $ARGUMENTS.
4+
5+
- You should first read the graphql schema to understand how to write the mutation before you start.
6+
- Query all fields inside the entity, except nested entities, unless the user explicitly mentioned they are required.
7+
- After adding the graphql file, run `npm run gentype` inside ./portal to generate the ncessary code.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Provided the graphql schema: ./portal/src/graphql/adminapi/schema.graphql
2+
3+
Add a .graphql file under ./portal/src/graphql/adminapi/query for $ARGUMENTS.
4+
5+
- You should first read the graphql schema to understand how to write the query before you start.
6+
- Include cursor, pageInfo, totalCount if available unless the user mentioned they are not needed.
7+
- Query all fields inside the entity, except nested entities, unless the user explicitly mentioned they are required.
8+
- After adding the graphql file, run `npm run gentype` inside ./portal to generate the ncessary code.

.make-lint-expect

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@ exit status 1
1111
pkg/lib/deps/deps_common.go cannot import github.com/authgear/authgear-server/pkg/latte/proofofphonenumberverification
1212
pkg/lib/workflow/dependencies.go cannot import github.com/authgear/authgear-server/pkg/latte/proofofphonenumberverification
1313

14-
exit status 1
15-
pkg/admin/graphql/audit_log.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
16-
pkg/admin/graphql/authenticator_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
17-
pkg/admin/graphql/authorization_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
18-
pkg/admin/graphql/entity.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
19-
pkg/admin/graphql/group.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
20-
pkg/admin/graphql/group_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
21-
pkg/admin/graphql/group_user_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
22-
pkg/admin/graphql/identity_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
23-
pkg/admin/graphql/nodes.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
24-
pkg/admin/graphql/query.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
25-
pkg/admin/graphql/role.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
26-
pkg/admin/graphql/role_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
27-
pkg/admin/graphql/role_user_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
28-
pkg/admin/graphql/session_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
29-
pkg/admin/graphql/user.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
30-
pkg/admin/graphql/user_mutation.go cannot import github.com/authgear/authgear-server/pkg/graphqlgo/relay
31-
3214
exit status 1
3315
pkg/auth/wire_gen.go cannot import github.com/authgear/authgear-server/pkg/latte/proofofphonenumberverification
3416

.vettedpositions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
/pkg/lib/oauth/response_mode.go:122:40: requestcontext
303303
/pkg/lib/oauth/response_mode.go:149:40: requestcontext
304304
/pkg/lib/oauth/response_mode.go:161:40: requestcontext
305-
/pkg/lib/oauth/scope.go:116:34: requestcontext
305+
/pkg/lib/oauth/scope.go:117:34: requestcontext
306306
/pkg/lib/oauthrelyingparty/oauthrelyingpartyutil/contextbackground.go:11:52: contextbackground
307307
/pkg/lib/otelauthgear/nethttp.go:30:10: requestcontext
308308
/pkg/lib/saml/samlbinding/http_post.go:176:35: requestcontext

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ lint:
6060
go run ./devtools/translationlinter
6161
-go run ./devtools/importlinter api api >.make-lint-expect 2>&1
6262
-go run ./devtools/importlinter lib api util >> .make-lint-expect 2>&1
63-
-go run ./devtools/importlinter admin api lib util >> .make-lint-expect 2>&1
63+
-go run ./devtools/importlinter admin api lib util graphqlgo >> .make-lint-expect 2>&1
6464
-go run ./devtools/importlinter auth api lib util >> .make-lint-expect 2>&1
6565
-go run ./devtools/importlinter portal api lib util >> .make-lint-expect 2>&1
6666
-go run ./devtools/importlinter resolver api lib util >> .make-lint-expect 2>&1
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
-- +migrate Up
2+
3+
CREATE TABLE _auth_resource (
4+
id text PRIMARY KEY,
5+
app_id text NOT NULL,
6+
created_at timestamp without time zone NOT NULL,
7+
updated_at timestamp without time zone NOT NULL,
8+
uri text NOT NULL,
9+
name text,
10+
metadata jsonb
11+
);
12+
CREATE UNIQUE INDEX _auth_resource_uri_unique ON _auth_resource USING btree (app_id, uri);
13+
CREATE INDEX _auth_resource_uri_typeahead ON _auth_resource USING btree (app_id, uri text_pattern_ops);
14+
CREATE INDEX _auth_resource_name_typeahead ON _auth_resource USING btree (app_id, name text_pattern_ops);
15+
CREATE INDEX _auth_resource_app_id_created_at ON _auth_resource USING btree (app_id, created_at);
16+
17+
CREATE TABLE _auth_resource_scope (
18+
id text PRIMARY KEY,
19+
app_id text NOT NULL,
20+
created_at timestamp without time zone NOT NULL,
21+
updated_at timestamp without time zone NOT NULL,
22+
resource_id text NOT NULL REFERENCES _auth_resource(id),
23+
scope text NOT NULL,
24+
description text,
25+
metadata jsonb
26+
);
27+
CREATE UNIQUE INDEX _auth_resource_scope_unique ON _auth_resource_scope USING btree (app_id, resource_id, scope);
28+
CREATE INDEX _auth_resource_scope_scope_typeahead ON _auth_resource_scope USING btree (app_id, resource_id, scope text_pattern_ops);
29+
CREATE INDEX _auth_resource_scope_app_id_resource_id_created_at ON _auth_resource_scope USING btree (app_id, resource_id, created_at);
30+
31+
CREATE TABLE _auth_client_resource (
32+
id text PRIMARY KEY,
33+
app_id text NOT NULL,
34+
created_at timestamp without time zone NOT NULL,
35+
updated_at timestamp without time zone NOT NULL,
36+
client_id text NOT NULL,
37+
resource_id text NOT NULL REFERENCES _auth_resource(id)
38+
);
39+
CREATE UNIQUE INDEX _auth_client_resource_unique ON _auth_client_resource USING btree (app_id, client_id, resource_id);
40+
41+
CREATE TABLE _auth_client_resource_scope (
42+
id text PRIMARY KEY,
43+
app_id text NOT NULL,
44+
created_at timestamp without time zone NOT NULL,
45+
updated_at timestamp without time zone NOT NULL,
46+
client_id text NOT NULL,
47+
resource_id text NOT NULL REFERENCES _auth_resource(id),
48+
scope_id text NOT NULL REFERENCES _auth_resource_scope(id)
49+
);
50+
CREATE UNIQUE INDEX _auth_client_resource_scope_unique ON _auth_client_resource_scope USING btree (app_id, client_id, resource_id, scope_id);
51+
52+
-- +migrate Down
53+
54+
DROP INDEX IF EXISTS _auth_client_resource_scope_unique;
55+
DROP TABLE IF EXISTS _auth_client_resource_scope;
56+
DROP INDEX IF EXISTS _auth_client_resource_unique;
57+
DROP TABLE IF EXISTS _auth_client_resource;
58+
DROP INDEX IF EXISTS _auth_resource_scope_app_id_resource_id_created_at;
59+
DROP INDEX IF EXISTS _auth_resource_scope_scope_typeahead;
60+
DROP INDEX IF EXISTS _auth_resource_scope_unique;
61+
DROP TABLE IF EXISTS _auth_resource_scope;
62+
DROP INDEX IF EXISTS _auth_resource_app_id_created_at;
63+
DROP INDEX IF EXISTS _auth_resource_name_typeahead;
64+
DROP INDEX IF EXISTS _auth_resource_uri_typeahead;
65+
DROP INDEX IF EXISTS _auth_resource_uri_unique;
66+
DROP TABLE IF EXISTS _auth_resource;

cmd/portal/analytic/wire_gen.go

Lines changed: 18 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/pkg/testrunner/matcher.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ func MatchJSON(jsonStr string, schema string) ([]MatchViolation, error) {
4545
return violations, nil
4646
}
4747

48-
func matchMap(path string, data, schema map[string]interface{}) (violations []MatchViolation) {
48+
func matchMap(path string, data interface{}, schema map[string]interface{}) (violations []MatchViolation) {
49+
dataMap, ok := data.(map[string]interface{})
50+
if !ok {
51+
if ok {
52+
violations = append(violations, typeMismatchViolation(path, "[[object]]", data))
53+
}
54+
return
55+
}
4956
for key, schemaValue := range schema {
5057
if key == "[[...rest]]" {
5158
continue
@@ -55,7 +62,7 @@ func matchMap(path string, data, schema map[string]interface{}) (violations []Ma
5562
continue
5663
}
5764

58-
dataValue, ok := data[key]
65+
dataValue, ok := dataMap[key]
5966
if schemaValue == "[[never]]" {
6067
if ok {
6168
violations = append(violations, typeMismatchViolation(path+"/"+key, "[[never]]", dataValue))
@@ -76,9 +83,9 @@ func matchMap(path string, data, schema map[string]interface{}) (violations []Ma
7683
// Allow extra fields by default
7784
restSchemaValue = "[[ignore]]"
7885
}
79-
for dataKey := range data {
86+
for dataKey := range dataMap {
8087
if _, ok := schema[dataKey]; !ok {
81-
violations = append(violations, matchValue(path+"/"+dataKey, data[dataKey], restSchemaValue)...)
88+
violations = append(violations, matchValue(path+"/"+dataKey, dataMap[dataKey], restSchemaValue)...)
8289
}
8390
}
8491

@@ -90,7 +97,7 @@ func matchValue(path string, dataValue, schemaValue interface{}) (violations []M
9097
case string:
9198
violations = append(violations, matchScalar(path, dataValue, schemaValue)...)
9299
case map[string]interface{}:
93-
violations = append(violations, matchMap(path, dataValue.(map[string]interface{}), schemaValue)...)
100+
violations = append(violations, matchMap(path, dataValue, schemaValue)...)
94101
case []interface{}:
95102
violations = append(violations, matchArray(path, dataValue.([]interface{}), schemaValue)...)
96103
default:
@@ -108,19 +115,21 @@ func matchArray(path string, data []interface{}, schemaValue interface{}) (viola
108115

109116
for i, item := range data {
110117
var itemType interface{}
111-
if schemaArray[0] == "[[arrayof]]" {
118+
if len(schemaArray) > 0 && schemaArray[0] == "[[arrayof]]" {
112119
itemType = schemaArray[1]
113120
} else {
114-
itemType = schemaArray[i]
121+
if i > len(schemaArray)-1 {
122+
violations = append(violations, typeMismatchViolation(fmt.Sprintf("%s/%d", path, i), "[[undefined]]", data[i]))
123+
continue
124+
} else {
125+
itemType = schemaArray[i]
126+
}
115127
}
116128

117129
violations = append(violations, matchValue(fmt.Sprintf("%s/%d", path, i), item, itemType)...)
118130
}
119131

120132
if len(data) != len(schemaArray) && schemaArray[0] != "[[arrayof]]" {
121-
for i := len(schemaArray); i < len(data); i++ {
122-
violations = append(violations, matchValue(fmt.Sprintf("%s/%d", path, i), data[i], schemaArray[len(schemaArray)-1])...)
123-
}
124133
for i := len(data); i < len(schemaArray); i++ {
125134
violations = append(violations, missingFieldViolation(fmt.Sprintf("%s/%d", path, i), schemaArray[i]))
126135
}

e2e/pkg/testrunner/matcher_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,29 @@ func TestMatchJSON(t *testing.T) {
199199
},
200200
},
201201
},
202+
{
203+
name: "Array: len(data) > len(schema)",
204+
jsonStr: `{
205+
"testarray": [1, 2, 3]
206+
}`,
207+
schema: `{
208+
"testarray": [1]
209+
}`,
210+
expected: []MatchViolation{
211+
{
212+
Path: "/testarray/1",
213+
Message: "type mismatch",
214+
Expected: "[[undefined]]",
215+
Actual: "[[number]]",
216+
},
217+
{
218+
Path: "/testarray/2",
219+
Message: "type mismatch",
220+
Expected: "[[undefined]]",
221+
Actual: "[[number]]",
222+
},
223+
},
224+
},
202225
}
203226

204227
for _, tc := range testCases {

0 commit comments

Comments
 (0)