Skip to content

Commit 23112a0

Browse files
authored
Merge pull request #127 from LalitDeore/admin2
fix autoprovisining of users
2 parents 15ad3b3 + 092c297 commit 23112a0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

shared.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11806,6 +11806,10 @@ func HandleEditOrg(resp http.ResponseWriter, request *http.Request) {
1180611806
org.SSOConfig = tmpData.SSOConfig
1180711807
}
1180811808

11809+
if tmpData.SSOConfig.AutoProvision != org.SSOConfig.AutoProvision {
11810+
org.SSOConfig.AutoProvision = tmpData.SSOConfig.AutoProvision
11811+
}
11812+
1180911813
if (tmpData.SSOConfig.OpenIdClientId != org.SSOConfig.OpenIdClientId) || (tmpData.SSOConfig.OpenIdAuthorization != org.SSOConfig.OpenIdAuthorization) {
1181011814
org.SSOConfig = tmpData.SSOConfig
1181111815
}
@@ -19327,6 +19331,14 @@ func HandleOpenId(resp http.ResponseWriter, request *http.Request) {
1932719331
return
1932819332
}
1932919333

19334+
//Don't create user if auto-provisioning is disabled
19335+
if org.SSOConfig.AutoProvision {
19336+
log.Printf("[INFO] Auto-provisioning is disable for id: %s", org.Id)
19337+
resp.WriteHeader(401)
19338+
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Auto-provisioning is disabled for this organization. Please ask your administrator to enable it."}`)))
19339+
return
19340+
}
19341+
1933019342
log.Printf("[AUDIT] Adding user %s to org %s (%s) through single sign-on", userName, org.Name, org.Id)
1933119343
newUser := new(User)
1933219344
// Random password to ensure its not empty
@@ -19856,6 +19868,14 @@ func HandleSSO(resp http.ResponseWriter, request *http.Request) {
1985619868
return
1985719869
}
1985819870

19871+
//Don't create user if auto-provisioning is disabled
19872+
if foundOrg.SSOConfig.AutoProvision {
19873+
log.Printf("[INFO] Auto-provisioning is disable for id: %s", foundOrg.Id)
19874+
resp.WriteHeader(401)
19875+
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Auto-provisioning is disabled for this organization. Please ask your administrator to enable it."}`)))
19876+
return
19877+
}
19878+
1985919879
log.Printf("[AUDIT] Adding user %s to org %s (%s) through single sign-on", userName, foundOrg.Name, foundOrg.Id)
1986019880
newUser := new(User)
1986119881
// Random password to ensure its not empty

structs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,7 @@ type SSOConfig struct {
27392739
OpenIdAuthorization string `json:"openid_authorization" datastore:"openid_authorization"`
27402740
OpenIdToken string `json:"openid_token" datastore:"openid_token"`
27412741
SSORequired bool `json:"SSORequired" datastore:"SSORequired"`
2742+
AutoProvision bool `json:"auto_provision" datastore:"auto_provision"`
27422743
}
27432744

27442745
type SamlRequest struct {

0 commit comments

Comments
 (0)