Skip to content

Commit 4cb6d7b

Browse files
Merge pull request #4656 from communitybridge/unicron-4639-add-is_sanctioned-to-v4-company-external
Support isSanctioned flag in all APIs + util scripts
2 parents 862b689 + 2de7d1c commit 4cb6d7b

10 files changed

+158
-3
lines changed

cla-backend-go/auth/authorizer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (a Authorizer) SecurityAuth(token string, scopes []string) (*user.CLAUser,
6060
// the list of scopes mentioned by the spec for this route.
6161

6262
// Verify the token is valid
63+
// LG:to skip verification
6364
log.WithFields(f).Debug("verifying token...")
6465
claims, err := a.authValidator.VerifyToken(token)
6566
if err != nil {
@@ -73,6 +74,7 @@ func (a Authorizer) SecurityAuth(token string, scopes []string) (*user.CLAUser,
7374

7475
// Get the username from the token claims
7576
// LG: for V3 endpoints comment this out and set: username, name and email manually for local testing.
77+
// username, name, email := "user", "Name Surname", "[email protected]"
7678
usernameClaim, ok := claims[a.authValidator.usernameClaim]
7779
if !ok {
7880
log.WithFields(f).Warnf("username not found in claims with key: %s", a.authValidator.usernameClaim)
@@ -111,6 +113,7 @@ func (a Authorizer) SecurityAuth(token string, scopes []string) (*user.CLAUser,
111113
return nil, errors.New("invalid email")
112114
}
113115
f["email"] = email
116+
// LG:end
114117

115118
// Get User by LFID
116119
log.WithFields(f).Debugf("loading user and profiles by LFID: %s", username)

utils/get_companies_go.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# API_URL=https://api.lfcla.dev.platform.linuxfoundation.org
4+
# Note: To run manually see cla-backend-go/auth/authorizer.go:SecurityAuth() and update accordingly 'LG:'
5+
6+
if [ -z "$TOKEN" ]
7+
then
8+
# source ./auth0_token.secret
9+
TOKEN="$(cat ./auth0.token.secret)"
10+
fi
11+
12+
if [ -z "$TOKEN" ]
13+
then
14+
echo "$0: TOKEN not specified and unable to obtain one"
15+
exit 1
16+
fi
17+
18+
if [ -z "$XACL" ]
19+
then
20+
XACL="$(cat ./x-acl.secret)"
21+
fi
22+
23+
if [ -z "$XACL" ]
24+
then
25+
echo "$0: XACL not specified and unable to obtain one"
26+
exit 2
27+
fi
28+
29+
if [ -z "$API_URL" ]
30+
then
31+
export API_URL="http://localhost:5000"
32+
fi
33+
34+
API="${API_URL}/v3/company"
35+
36+
if [ ! -z "$DEBUG" ]
37+
then
38+
echo "curl -s -XGET -H \"Content-Type: application/json\" \"${API}\" -H \"X-ACL: ${XACL}\" -H \"Authorization: Bearer ${TOKEN}\""
39+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}"
40+
else
41+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}" | jq -r '.'
42+
fi
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# API_URL=https://api.lfcla.dev.platform.linuxfoundation.org
4+
# V=v3|v4
5+
# Note: To run manually see cla-backend-go/auth/authorizer.go:SecurityAuth() and update accordingly 'LG:'
6+
if [ -z "$1" ]
7+
then
8+
echo "$0: you need to specify company_sfid as a 1st parameter, example '0014100000Te0yqAAB', '0016s000006UKKqAAO'"
9+
exit 1
10+
fi
11+
export company_sfid="$1"
12+
13+
if [ -z "$TOKEN" ]
14+
then
15+
# source ./auth0_token.secret
16+
TOKEN="$(cat ./auth0.token.secret)"
17+
fi
18+
19+
if [ -z "$TOKEN" ]
20+
then
21+
echo "$0: TOKEN not specified and unable to obtain one"
22+
exit 1
23+
fi
24+
25+
if [ -z "$XACL" ]
26+
then
27+
XACL="$(cat ./x-acl.secret)"
28+
fi
29+
30+
if [ -z "$XACL" ]
31+
then
32+
echo "$0: XACL not specified and unable to obtain one"
33+
exit 2
34+
fi
35+
36+
if [ -z "$API_URL" ]
37+
then
38+
export API_URL="http://localhost:5000"
39+
fi
40+
41+
if [ -z "${V}" ]
42+
then
43+
export V=v4
44+
fi
45+
46+
API="${API_URL}/${V}/company/external/${company_sfid}"
47+
48+
if [ ! -z "$DEBUG" ]
49+
then
50+
echo "curl -s -XGET -H \"Content-Type: application/json\" \"${API}\" -H \"X-ACL: ${XACL}\" -H \"Authorization: Bearer ${TOKEN}\""
51+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}"
52+
else
53+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}" | jq -r '.'
54+
fi

utils/get_company_go.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
33
# API_URL=https://api.lfcla.dev.platform.linuxfoundation.org
44
# Note: To run manually see cla-backend-go/auth/authorizer.go:SecurityAuth() and update accordingly 'LG:'
5+
# V=v3|v4
56
if [ -z "$1" ]
67
then
7-
echo "$0: you need to specify company_id as a 1st parameter, example '0ca30016-6457-466c-bc41-a09560c1f9bf'"
8+
echo "$0: you need to specify company_id as a 1st parameter, example '0ca30016-6457-466c-bc41-a09560c1f9bf', '10bde6b1-3061-4972-9c6a-17dd9a175a5c'"
89
exit 1
910
fi
1011
export company_id="$1"

utils/get_company_py.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# API_URL=https://api.lfcla.dev.platform.linuxfoundation.org
44
if [ -z "$1" ]
55
then
6-
echo "$0: you need to specify company_id as a 1st parameter, example '0ca30016-6457-466c-bc41-a09560c1f9bf'"
6+
echo "$0: you need to specify company_id as a 1st parameter, example '0ca30016-6457-466c-bc41-a09560c1f9bf', '10bde6b1-3061-4972-9c6a-17dd9a175a5c'"
77
exit 1
88
fi
99
export company_id="$1"

utils/request_corporate_signature_go_post.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# XACL='...' - X-ACL
99
# DEBUG=1 XACL="$(cat ./x-acl.secret)" TOKEN="$(cat ./auth0.token.secret)" ./utils/request_corporate_signature_go_post.sh 0016s000006Uq9VAAS a092h000004wx1DAAQ github 'http://localhost'
1010
# DEBUG=1 XACL="$(cat ./x-acl.secret)" TOKEN="$(cat ./auth0.token.secret)" ./utils/request_corporate_signature_go_post.sh 0014100000Te0yqAAB lfbrdgbVFK7QngqnzD github 'http://localhost'
11+
# DEBUG=1 XACL="$(cat ./x-acl.secret)" TOKEN="$(cat ./auth0.token.secret)" ./utils/request_corporate_signature_go_post.sh 0016s000006UKKqAAO lfbrdgbVFK7QngqnzD github 'http://localhost'
1112
# select distinct data:user_external_id from fivetran_ingest.dynamodb_product_us_east_1.cla_prod_users
1213
# select distinct data:company_external_id from fivetran_ingest.dynamodb_product_us_east_1.cla_prod_companies
1314
# select user_id, data:user_external_id from fivetran_ingest.dynamodb_product_us_east1_dev.cla_dev_users where data:lf_username = 'uname'

utils/request_corporate_signature_py_post.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# return_url='http://localhost'
77
# DEBUG=1 ./utils/request_corporate_signature_py_post.sh 862ff296-6508-4f10-9147-2bc2dd7bfe80 88ee12de-122b-4c46-9046-19422054ed8d github 'http://localhost'
88
# ./utils/request_corporate_signature_py_post.sh 0ca30016-6457-466c-bc41-a09560c1f9bf 88ee12de-122b-4c46-9046-19422054ed8d github 'http://localhost'
9+
# ./utils/request_corporate_signature_py_post.sh 10bde6b1-3061-4972-9c6a-17dd9a175a5c 88ee12de-122b-4c46-9046-19422054ed8d github 'http://localhost'
910
# Note: this is only for internal usage, it requires 'check_auth' function update in cla-backend/cla/routes.py (see LG:) and can only be tested locally (LG:)
1011

1112
if [ -z "$1" ]

utils/search_company_go.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# API_URL=https://api.lfcla.dev.platform.linuxfoundation.org
4+
# Note: To run manually see cla-backend-go/auth/authorizer.go:SecurityAuth() and update accordingly 'LG:'
5+
if [ -z "$1" ]
6+
then
7+
echo "$0: you need to specify search term as a 1st parameter, example 'Linux Foundation'"
8+
exit 1
9+
fi
10+
export search="$1"
11+
export encoded_search=$(jq -rn --arg x "$search" '$x|@uri')
12+
13+
if [ -z "$TOKEN" ]
14+
then
15+
# source ./auth0_token.secret
16+
TOKEN="$(cat ./auth0.token.secret)"
17+
fi
18+
19+
if [ -z "$TOKEN" ]
20+
then
21+
echo "$0: TOKEN not specified and unable to obtain one"
22+
exit 1
23+
fi
24+
25+
if [ -z "$XACL" ]
26+
then
27+
XACL="$(cat ./x-acl.secret)"
28+
fi
29+
30+
if [ -z "$XACL" ]
31+
then
32+
echo "$0: XACL not specified and unable to obtain one"
33+
exit 2
34+
fi
35+
36+
if [ -z "$API_URL" ]
37+
then
38+
export API_URL="http://localhost:5000"
39+
fi
40+
41+
API="${API_URL}/v3/company/search?companyName=${encoded_search}"
42+
43+
if [ ! -z "$DEBUG" ]
44+
then
45+
echo "curl -s -XGET -H \"Content-Type: application/json\" \"${API}\" -H \"X-ACL: ${XACL}\" -H \"Authorization: Bearer ${TOKEN}\""
46+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}"
47+
else
48+
curl -s -XGET -H "Content-Type: application/json" -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" "${API}" | jq -r '.'
49+
fi

utils/test_sanctioned_flag.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
2+
# 10bde6b1-3061-4972-9c6a-17dd9a175a5c - dev LF
3+
# 0ca30016-6457-466c-bc41-a09560c1f9bf - dev CNCF
4+
# 0016s000006UKKqAAO - dev LF SFID
5+
# 0014100000Te0yqAAB - dev CNCF SFID
26
./utils/update_company_is_sanctioned.sh 0ca30016-6457-466c-bc41-a09560c1f9bf true
37
# Python APIs
48
./utils/get_company_py.sh 0ca30016-6457-466c-bc41-a09560c1f9bf

utils/update_company_is_sanctioned.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ then
88
fi
99
if [ -z "$1" ]
1010
then
11-
echo "$0: you need to specify company_id, for example: '0ca30016-6457-466c-bc41-a09560c1f9bf'"
11+
echo "$0: you need to specify company_id, for example: '0ca30016-6457-466c-bc41-a09560c1f9bf', '10bde6b1-3061-4972-9c6a-17dd9a175a5c'"
1212
exit 1
1313
fi
1414
if [ -z "$2" ]

0 commit comments

Comments
 (0)