resolveRequestParams replaces DetectionSub placeholders in RequestParams fields with actual values derived from the user inputs.
(reqParams auth0.RequestParams, name string, port int)
| 1472 | // resolveRequestParams replaces DetectionSub placeholders in RequestParams fields |
| 1473 | // with actual values derived from the user inputs. |
| 1474 | func resolveRequestParams(reqParams auth0.RequestParams, name string, port int) auth0.RequestParams { |
| 1475 | if port == 0 { |
| 1476 | port = 3000 |
| 1477 | } |
| 1478 | baseURL := fmt.Sprintf("http://localhost:%d", port) |
| 1479 | |
| 1480 | callbacks := make([]string, len(reqParams.Callbacks)) |
| 1481 | copy(callbacks, reqParams.Callbacks) |
| 1482 | logoutURLs := make([]string, len(reqParams.AllowedLogoutURLs)) |
| 1483 | copy(logoutURLs, reqParams.AllowedLogoutURLs) |
| 1484 | webOrigins := make([]string, len(reqParams.WebOrigins)) |
| 1485 | copy(webOrigins, reqParams.WebOrigins) |
| 1486 | |
| 1487 | resolvedName := reqParams.Name |
| 1488 | if resolvedName == auth0.DetectionSub { |
| 1489 | resolvedName = name |
| 1490 | } |
| 1491 | callbackPath := "/callback" |
| 1492 | if reqParams.CallbackPath != "" { |
| 1493 | callbackPath = reqParams.CallbackPath |
| 1494 | } |
| 1495 | for i, cb := range callbacks { |
| 1496 | switch cb { |
| 1497 | case auth0.DetectionSub: |
| 1498 | callbacks[i] = baseURL + callbackPath |
| 1499 | case auth0.DetectionSubAsBase: |
| 1500 | callbacks[i] = baseURL |
| 1501 | } |
| 1502 | } |
| 1503 | for i, u := range logoutURLs { |
| 1504 | if u == auth0.DetectionSub { |
| 1505 | logoutURLs[i] = baseURL |
| 1506 | } |
| 1507 | } |
| 1508 | for i, u := range webOrigins { |
| 1509 | if u == auth0.DetectionSub { |
| 1510 | webOrigins[i] = baseURL |
| 1511 | } |
| 1512 | } |
| 1513 | |
| 1514 | return auth0.RequestParams{ |
| 1515 | AppType: reqParams.AppType, |
| 1516 | Callbacks: callbacks, |
| 1517 | AllowedLogoutURLs: logoutURLs, |
| 1518 | WebOrigins: webOrigins, |
| 1519 | Name: resolvedName, |
| 1520 | CallbackPath: reqParams.CallbackPath, |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | func replaceDetectionSub(envValues map[string]string, tenantDomain string, client *management.Client, port int) (map[string]string, error) { |
| 1525 | if port == 0 { |
no outgoing calls