Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXCDT-546: Add logic to fetch universal login branding data #861

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Oct 4, 2023

🔧 Changes

This PR adds logic for the auth0 universal-login customize command in order to fetch universal login branding data:

universalLoginBrandingData struct {
		AuthenticationProfile *management.Prompt                 `json:"auth_profile"`
		Settings              *management.Branding               `json:"settings"`
		Template              *management.BrandingUniversalLogin `json:"template"`
		Theme                 *management.BrandingTheme          `json:"theme"`
		Tenant                *tenantData                        `json:"tenant"`
		Prompt                *promptData                        `json:"prompt"`
}

Each API calls is executed in parallel using errgroup and if an error is encountered it gets propagated immediately during this phase.

When fetching the prompt data, we only fetch the login prompt and screen text for the default language set on the tenant. If custom text is not set for any of the fields available for the login screen, the defaults will get displayed.

Example of the full payload:

{
    "auth_profile": {
        "universal_login_experience": "new",
        "identifier_first": false,
        "webauthn_platform_first_factor": false
    },
    "settings": {
        "colors": {
            "primary": "#2A2E35",
            "page_background": "#FF4F40"
        },
        "favicon_url": "https://example.com/favicon.png",
        "logo_url": "https://cdn.auth0.com/manhattan/versions/1.3935.0/assets/badge.png"
    },
    "template": {},
    "theme": {
        "borders": {
            "button_border_radius": 3,
            "button_border_weight": 1,
            "buttons_style": "rounded",
            "input_border_radius": 3,
            "input_border_weight": 1,
            "inputs_style": "rounded",
            "show_widget_shadow": true,
            "widget_border_weight": 0,
            "widget_corner_radius": 5
        },
        "colors": {
            "base_focus_color": "#635dff",
            "base_hover_color": "#000000",
            "body_text": "#1e212a",
            "error": "#d03c38",
            "header": "#1e212a",
            "icons": "#65676e",
            "input_background": "#ffffff",
            "input_border": "#c9cace",
            "input_filled_text": "#000000",
            "input_labels_placeholders": "#65676e",
            "links_focused_components": "#635dff",
            "primary_button": "#635dff",
            "primary_button_label": "#ffffff",
            "secondary_button_border": "#c9cace",
            "secondary_button_label": "#1e212a",
            "success": "#13a688",
            "widget_background": "#ffffff",
            "widget_border": "#c9cace"
        },
        "fonts": {
            "body_text": {
                "bold": false,
                "size": 87.5
            },
            "buttons_text": {
                "bold": false,
                "size": 100
            },
            "font_url": "",
            "input_labels": {
                "bold": false,
                "size": 100
            },
            "links": {
                "bold": true,
                "size": 87.5
            },
            "links_style": "normal",
            "reference_text_size": 16,
            "subtitle": {
                "bold": false,
                "size": 87.5
            },
            "title": {
                "bold": false,
                "size": 150
            }
        },
        "page_background": {
            "background_color": "#000000",
            "background_image_url": "",
            "page_layout": "center"
        },
        "widget": {
            "header_text_alignment": "center",
            "logo_height": 52,
            "logo_position": "center",
            "logo_url": "",
            "social_buttons_layout": "bottom"
        }
    },
    "tenant": {
        "friendly_name": "My Test Tenant",
        "enabled_locales": [
            "en",
            "es"
        ],
        "domain": "test-tenant.eu.auth0.com"
    },
    "prompt": {
        "language": "en",
        "prompt": "login",
        "custom_text": {
            "login": {
                "alertListTitle": "Alerts",
                "auth0-users-validation": "Something went wrong, please try again later",
                "authentication-failure": "We are sorry, something went wrong when attempting to login",
                "buttonText": "Continue",
                "custom-script-error-code": "Something went wrong, please try again later.",
                "description": "Log in to ${companyName} to continue to ${clientName}.",
                "editEmailText": "Edit",
                "emailPlaceholder": "Email address",
                "federatedConnectionButtonText": "Continue with ${connectionName}",
                "footerLinkText": "Sign up",
                "footerText": "Don't have an account?",
                "forgotPasswordText": "Forgot password?",
                "hidePasswordText": "Hide password",
                "invalid-connection": "Invalid connection",
                "invalid-email-format": "Email is not valid.",
                "invitationDescription": "Log in to accept ${inviterName}'s invitation to join ${companyName} on ${clientName}.",
                "invitationTitle": "You've Been Invited!",
                "ip-blocked": "We have detected suspicious login behavior and further attempts will be blocked. Please contact the administrator.",
                "logoAltText": "${companyName}",
                "no-db-connection": "Invalid connection",
                "no-email": "Please enter an email address",
                "no-password": "Password is required",
                "no-username": "Username is required",
                "pageTitle": "Log in | ${clientName}",
                "password-breached": "We have detected a potential security issue with this account. To protect your account, we have prevented this login. Please reset your password to proceed.",
                "passwordPlaceholder": "Password",
                "same-user-login": "Too many login attempts for this user. Please wait, and try again later.",
                "separatorText": "Or",
                "showPasswordText": "Show password",
                "signupActionLinkText": "${footerLinkText}",
                "signupActionText": "${footerText}",
                "title": "Welcome",
                "user-blocked": "Your account has been blocked after multiple consecutive login attempts.",
                "usernamePlaceholder": "Username or email address",
                "wrong-credentials": "Wrong username or password",
                "wrong-email-credentials": "Wrong email or password"
            }
        }
    }
}

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@sergiught sergiught marked this pull request as ready for review October 4, 2023 16:21
@sergiught sergiught requested a review from a team as a code owner October 4, 2023 16:21
@codecov-commenter
Copy link

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (1cff49f) 73.41% compared to head (ee43b12) 73.69%.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           DXCDT-545-skeleton     #861      +/-   ##
======================================================
+ Coverage               73.41%   73.69%   +0.27%     
======================================================
  Files                      93       93              
  Lines                   11911    12069     +158     
======================================================
+ Hits                     8745     8894     +149     
- Misses                   2649     2658       +9     
  Partials                  517      517              
Files Coverage Δ
internal/auth0/auth0.go 100.00% <100.00%> (ø)
internal/cli/universal_login_customize.go 93.02% <93.12%> (+13.02%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from DXCDT-545-skeleton to feature/auth0-universal-login-customize October 5, 2023 08:39
internal/cli/universal_login_customize.go Outdated Show resolved Hide resolved
internal/cli/universal_login_customize.go Outdated Show resolved Hide resolved
internal/cli/universal_login_customize.go Outdated Show resolved Hide resolved
internal/cli/universal_login_customize.go Show resolved Hide resolved
@sergiught sergiught merged commit b20738a into feature/auth0-universal-login-customize Oct 5, 2023
8 checks passed
@sergiught sergiught deleted the DXCDT-546-fetch-initial-data branch October 5, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants