diff --git a/authentication/auth.go b/authentication/auth.go index 518c28a8..6b648543 100644 --- a/authentication/auth.go +++ b/authentication/auth.go @@ -157,45 +157,6 @@ func getSurveyMetadataFromClaims(claimValues map[string][]string, data map[strin claims["survey_metadata"] = surveyMetadata } -func generateClaims(claimValues map[string][]string, launcherSchema surveys.LauncherSchema) (claims map[string]interface{}) { - - var roles []string - if rolesValues, ok := claimValues["roles"]; ok { - roles = rolesValues - } else { - roles = []string{"dumper"} - } - - claims = make(map[string]interface{}) - - claims["roles"] = roles - TxID, _ := uuid.NewV4() - claims["tx_id"] = TxID.String() - - for key, value := range claimValues { - if key != "roles" { - if value[0] != "" { - claims[key] = value[0] - } - } else { - claims[key] = value - } - } - if len(claimValues["form_type"]) > 0 && len(claimValues["eq_id"]) > 0 { - log.Println("Deleting schema name from claims") - delete(claims, "schema_name") - } else { - // When quicklaunching, schema_name will not be set, but launcherSchema will have the schema_name. - if len(claimValues["schema_name"]) == 0 && launcherSchema.Name != "" { - claims["schema_name"] = launcherSchema.Name - } - } - - log.Printf("Using claims: %s", claims) - - return claims -} - func generateClaimsV2(claimValues map[string][]string, schema QuestionnaireSchema) (claims map[string]interface{}) { var roles []string @@ -415,48 +376,6 @@ func getStringOrDefault(key string, values map[string][]string, defaultValue str return defaultValue } -// GenerateTokenFromDefaults coverts a set of DEFAULT values into a JWT -func GenerateTokenFromDefaults(schemaURL string, accountServiceURL string, accountServiceLogOutURL string, urlValues url.Values) (token string, error string) { - launcherSchema, validationError := launcherSchemaFromURL(schemaURL) - if validationError != "" { - return "", validationError - } - - urlValues["account_service_url"] = []string{accountServiceURL} - urlValues["account_service_log_out_url"] = []string{accountServiceLogOutURL} - claims := generateClaims(urlValues, launcherSchema) - - requiredMetadata, error := getRequiredSchemaMetadata(launcherSchema) - if error != "" { - return "", fmt.Sprintf("getRequiredSchemaMetadata failed err: %v", error) - } - - for _, metadata := range requiredMetadata { - if metadata.Validator == "boolean" { - claims[metadata.Name] = getBooleanOrDefault(metadata.Name, urlValues, false) - continue - } - claims[metadata.Name] = getStringOrDefault(metadata.Name, urlValues, metadata.Default) - } - - jwtClaims := GenerateJwtClaims() - for key, v := range jwtClaims { - claims[key] = v - } - - schemaClaims := getSchemaClaims(launcherSchema) - for key, v := range schemaClaims { - claims[key] = v - } - - token, tokenError := generateTokenFromClaims(claims) - if tokenError != nil { - return token, fmt.Sprintf("GenerateTokenFromDefaults failed err: %v", tokenError) - } - - return token, "" -} - // GenerateTokenFromDefaultsV2 coverts a set of DEFAULT values into a JWT func GenerateTokenFromDefaultsV2(schemaURL string, accountServiceURL string, urlValues url.Values) (token string, error string) { launcherSchema, validationError := launcherSchemaFromURL(schemaURL) @@ -551,7 +470,7 @@ func TransformSchemaParamsToName(postValues url.Values) string { } // GenerateTokenFromPost converts a set of POST values into a JWT -func GenerateTokenFromPost(postValues url.Values, launchVersion2 bool) (string, string) { +func GenerateTokenFromPost(postValues url.Values) (string, string) { log.Println("POST received: ", postValues) schemaName := TransformSchemaParamsToName(postValues) @@ -565,13 +484,7 @@ func GenerateTokenFromPost(postValues url.Values, launchVersion2 bool) (string, return "", fmt.Sprintf("getSchema failed err: %v", error) } - var claims map[string]interface{} - - if launchVersion2 { - claims = generateClaimsV2(postValues, schema) - } else { - claims = generateClaims(postValues, launcherSchema) - } + var claims = generateClaimsV2(postValues, schema) jwtClaims := GenerateJwtClaims() for key, v := range jwtClaims { diff --git a/launch.go b/launch.go index 824b3016..e4eb2476 100644 --- a/launch.go +++ b/launch.go @@ -153,11 +153,7 @@ func redirectURL(w http.ResponseWriter, r *http.Request) { token := "" err := "" - if launchVersion == "v2" { - token, err = authentication.GenerateTokenFromPost(r.PostForm, true) - } else { - token, err = authentication.GenerateTokenFromPost(r.PostForm, false) - } + token, err = authentication.GenerateTokenFromPost(r.PostForm) if err != "" { http.Error(w, err, 500) @@ -179,20 +175,11 @@ func redirectURL(w http.ResponseWriter, r *http.Request) { func quickLauncherHandler(w http.ResponseWriter, r *http.Request) { hostURL := settings.Get("SURVEY_RUNNER_URL") accountServiceURL := getAccountServiceURL(r) - AccountServiceLogOutURL := getAccountServiceURL(r) urlValues := r.URL.Query() schemaURL := urlValues.Get("schema_url") - version := urlValues.Get("version") - launchVersion2 := true defaultValues := authentication.GetDefaultValues() - if version == "" { - urlValues.Add("version", defaultValues["version"]) - } else if version == "v1" { - launchVersion2 = false - } else { - urlValues.Add("version", version) - } + urlValues.Add("version", defaultValues["version"]) log.Println("Quick launch request received", schemaURL) @@ -207,11 +194,7 @@ func quickLauncherHandler(w http.ResponseWriter, r *http.Request) { token := "" err := "" - if launchVersion2 { - token, err = authentication.GenerateTokenFromDefaultsV2(schemaURL, accountServiceURL, urlValues) - } else { - token, err = authentication.GenerateTokenFromDefaults(schemaURL, accountServiceURL, AccountServiceLogOutURL, urlValues) - } + token, err = authentication.GenerateTokenFromDefaultsV2(schemaURL, accountServiceURL, urlValues) if err != "" { http.Error(w, err, 400) diff --git a/static/javascript/launch.js b/static/javascript/launch.js index bdabf01a..501c711d 100644 --- a/static/javascript/launch.js +++ b/static/javascript/launch.js @@ -234,29 +234,14 @@ function showSubmitFlushButtons(show, justSubmit = false) { } function includeSurveyMetadataFields(schema_name, survey_type) { - let launchPattern = document.querySelector("#launch_pattern").value; - let eqIdValue = schema_name.split("_")[0]; let formTypeValue = schema_name.split("_").slice(1).join("_"); - if (launchPattern === "v1") { - document.querySelector("#survey_metadata_fields").innerHTML = - `

${survey_type} Survey Metadata

-
- - -
-
- - -
`; - } else { - document.querySelector("#survey_metadata_fields").innerHTML = - `

${survey_type} Survey Metadata

-
- - -
`; - } + document.querySelector("#survey_metadata_fields").innerHTML = + `

${survey_type} Survey Metadata

+
+ + +
`; showSupplementaryData(true); document diff --git a/templates/launch.html b/templates/launch.html index bf71fe38..dfca1a42 100644 --- a/templates/launch.html +++ b/templates/launch.html @@ -1,42 +1,36 @@ {{ define "title" }}Launch a Survey{{ end }} {{ define "body" }} -

Launch a survey

-
- Launch Pattern -
- - -
- Launch by Schema Name -
- - +
+ Launch by Schema Name +
+ + -
-

----------

- Launch Remote Schemas -
+ + {{ end }} + +
+

----------

+ Launch Remote Schemas +
-
-
+
+
Launch a survey class="qa-schema_url" onchange="setSchemaUrl(this)"> -
-
+
+
-
-
- -
-

----------

-
-
-

CIR Metadata

-
-
-

Survey Metadata

-
-

--- Metadata fields will be loaded when you select a version and load a schema ---

-
-
-

Supplementary Data

-
-
-

Required Data

-
- - +
+
+ +
+

----------

+
+
+

CIR Metadata

+
+
+

Survey Metadata

+
+

--- Metadata fields will be loaded when you select a version and load a schema ---

+
+
+

Supplementary Data

+
+
+

Required Data

+
+ + Reload symbol -
-
- - +
+
+ + Required Data src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGhlaWdodD0iNTEycHgiIGlkPSJMYXllcl8xIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgd2lkdGg9IjUxMnB4IiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48cGF0aCBkPSJNMjU2LDM4NC4xYy03MC43LDAtMTI4LTU3LjMtMTI4LTEyOC4xYzAtNzAuOCw1Ny4zLTEyOC4xLDEyOC0xMjguMVY4NGw5Niw2NGwtOTYsNTUuN3YtNTUuOCAgIGMtNTkuNiwwLTEwOC4xLDQ4LjUtMTA4LjEsMTA4LjFjMCw1OS42LDQ4LjUsMTA4LjEsMTA4LjEsMTA4LjFTMzY0LjEsMzE2LDM2NC4xLDI1NkgzODRDMzg0LDMyNywzMjYuNywzODQuMSwyNTYsMzg0LjF6Ii8+PC9nPjwvc3ZnPg==" alt="Reload symbol"> -
- -
- - +
+ +
+ + Required Data src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGhlaWdodD0iNTEycHgiIGlkPSJMYXllcl8xIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgd2lkdGg9IjUxMnB4IiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48cGF0aCBkPSJNMjU2LDM4NC4xYy03MC43LDAtMTI4LTU3LjMtMTI4LTEyOC4xYzAtNzAuOCw1Ny4zLTEyOC4xLDEyOC0xMjguMVY4NGw5Niw2NGwtOTYsNTUuN3YtNTUuOCAgIGMtNTkuNiwwLTEwOC4xLDQ4LjUtMTA4LjEsMTA4LjFjMCw1OS42LDQ4LjUsMTA4LjEsMTA4LjEsMTA4LjFTMzY0LjEsMzE2LDM2NC4xLDI1NkgzODRDMzg0LDMyNywzMjYuNywzODQuMSwyNTYsMzg0LjF6Ii8+PC9nPjwvc3ZnPg==" alt="Reload symbol"> -
-
- - +
+
+ + Required Data src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGhlaWdodD0iNTEycHgiIGlkPSJMYXllcl8xIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgd2lkdGg9IjUxMnB4IiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48cGF0aCBkPSJNMjU2LDM4NC4xYy03MC43LDAtMTI4LTU3LjMtMTI4LTEyOC4xYzAtNzAuOCw1Ny4zLTEyOC4xLDEyOC0xMjguMVY4NGw5Niw2NGwtOTYsNTUuN3YtNTUuOCAgIGMtNTkuNiwwLTEwOC4xLDQ4LjUtMTA4LjEsMTA4LjFjMCw1OS42LDQ4LjUsMTA4LjEsMTA4LjEsMTA4LjFTMzY0LjEsMzE2LDM2NC4xLDI1NkgzODRDMzg0LDMyNywzMjYuNywzODQuMSwyNTYsMzg0LjF6Ii8+PC9nPjwvc3ZnPg==" alt="Reload symbol"> -
-

Runner Data

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - - -
-
- + +

Runner Data

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + -{{ end }} +{{ end }} \ No newline at end of file