-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yaml
171 lines (155 loc) · 5.43 KB
/
template.yaml
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
169
170
171
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Okta AWS SSO SCIM Groups Connector
This application listens to group membership events from Okta and syncrhonizes
membership changes to identically named groups in AWS SSO which begin with the
prefix `AWS_`.
Changes are effected by interacting with the SCIM 2.0 endpoint provided by AWS SSO
for automatic provisioning.
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Parameters:
ScimUrl:
Type: String
Description: "The SCIM url provided when setting up AWS SSO."
Metadata:
AWS::ServerlessRepo::Application:
Author: Myles Loffler
Name: "Okta AWS SSO SCIM Groups Connector"
SemanticVersion: 0.0.1
Description: >
This application listens to group membership events from Okta and syncrhonizes
membership changes to identically named groups in AWS SSO which begin with the
prefix `AWS_`.
Changes are effected by interacting with the SCIM 2.0 endpoint provided by AWS SSO
for automatic provisioning.
Labels: ['AWS SSO', 'Okta', 'IAM']
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README.md
HomePageUrl: https://github.com/myles2007/okta-aws-sso-scim-groups-connector
SourceCodeUrl: https://github.com/myles2007/okta-aws-sso-scim-groups-connector
Resources:
ReadAppSecretsPolicy:
Type: "AWS::IAM::ManagedPolicy"
Properties:
Path: "/app/okta-aws-sso-scim-groups-connector/read-secrets/"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "secretsManager:GetSecretValue"
Resource: !Ref Secrets
TokenAuthorizerRole:
Type: "AWS::IAM::Role"
Properties:
Path: "/app/okta-aws-sso-scim-groups-connector/token-authorizer/"
ManagedPolicyArns:
- !Ref ReadAppSecretsPolicy
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
EventProcessorRole:
Type: "AWS::IAM::Role"
Properties:
Path: "/app/okta-aws-sso-scim-groups-connector/event-processor/"
ManagedPolicyArns:
- !Ref ReadAppSecretsPolicy
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Secrets:
Type: AWS::SecretsManager::Secret
Properties:
Description: "Contains the secrets expected to be provided by Okta and required by AWS SSO."
Name: app/okta-aws-sso-scim-groups-connector
GenerateSecretString:
SecretStringTemplate: "{\"aws_sso_scim_key\": \"<MUST BE PROVIDED>\"}"
GenerateStringKey: "auth_token_for_okta"
PasswordLength: 256
OktaEventsApi:
Type: "AWS::Serverless::Api"
Properties:
StageName: Prod
Cors:
AllowOrigin: "'https://britecore.okta.com'"
Auth:
DefaultAuthorizer: TokenAuth
Authorizers:
TokenAuth:
FunctionArn: !GetAtt TokenAuthorizer.Arn
FunctionPayloadType: "REQUEST"
Identity:
Headers:
- Authorization
- x-api-key
ApiKeyRequired: true # sets for all methods
UsagePlan:
CreateUsagePlan: "PER_API"
EventHookVerifier:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: app/
Handler: verify.lambda_handler
Runtime: python3.8
Events:
Verify:
Type: Api
Properties:
RestApiId: !Ref OktaEventsApi
Path: /
Method: get
EventProcessor:
Type: AWS::Serverless::Function
Properties:
CodeUri: app/
Handler: processor.lambda_handler
Runtime: python3.8
Events:
OktaEvent: # Should just be group member added/group member removed, but unfiltered.
Type: Api
Properties:
RestApiId: !Ref OktaEventsApi
Path: /
Method: post
Environment:
Variables:
SCIM_URL: !Ref ScimUrl
Role: !GetAtt EventProcessorRole.Arn
TokenAuthorizer:
Type: AWS::Serverless::Function
Properties:
CodeUri: app
Handler: authorizer.lambda_handler
Runtime: python3.8
Role: !GetAtt TokenAuthorizerRole.Arn
Outputs:
OktaEventsApi:
Description: "API Gateway endpoint URL for Prod stage for OktaEventsApi"
Value: !Sub "https://${OktaEventsApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
EventHookVerifier:
Description: "Perform initial endpoint verification with Okta"
Value: !GetAtt EventHookVerifier.Arn
EventHookVerifierIamRole:
Description: "Implicit IAM Role created for EventHookVerifier function"
Value: !GetAtt EventHookVerifierRole.Arn
EventProcessor:
Description: "Process events from Okta (specifically interesting group membership changes"
Value: !GetAtt EventProcessor.Arn