Skip to content

Commit 9fb5dfd

Browse files
I18n implementation (#10515)
* Adding ja-jp and fr-ca folders * Updated .yml for non-interactive QS * updated yml files for ja-jp and fr-ca * adding acul quickstart * moving acul to en articles * updating sidebar values for apis section (i18n) * updating interactive qs for android fb login * updating translations on quickstarts
1 parent 5c2835b commit 9fb5dfd

File tree

4,781 files changed

+338646
-4299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,781 files changed

+338646
-4299
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: auth_config.json
3+
language: json
4+
---
5+
6+
```json
7+
//auth0-react-samples/Sample-01/src/auth_config.json
8+
{
9+
"domain": "${account.namespace}",
10+
"clientId": "${account.clientId}"
11+
}
12+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: index.tsx
3+
language: javascript
4+
---
5+
6+
```javascript
7+
import { LoginId } from '@auth0/auth0-acul-js';
8+
import { useState } from 'react';
9+
10+
export const LoginIdScreen = () => {
11+
const loginManager = new LoginId();
12+
const [email, setEmail] = useState('');
13+
14+
return (
15+
<div className="w-[100vw] min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
16+
<div className="max-w-md w-full space-y-6 bg-white p-8 rounded-lg shadow-md">
17+
<input
18+
type="email"
19+
placeholder="Enter your email"
20+
value={email}
21+
onChange={(e) => setEmail(e.target.value)}
22+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
23+
/>
24+
25+
<button
26+
className="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-black bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
27+
onClick={() => loginManager.login({ username: email })}
28+
>
29+
Continue
30+
</button>
31+
32+
{loginManager.transaction.alternateConnections?.map(({ name, strategy }) => (
33+
<button
34+
key={name}
35+
className="w-full flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
36+
onClick={() => loginManager.socialLogin({ connection: name })}
37+
>
38+
Continue with {strategy}
39+
</button>
40+
))}
41+
</div>
42+
</div>
43+
);
44+
};
45+
46+
export default LoginIdScreen
47+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: settings.json
3+
language: json
4+
---
5+
6+
```json
7+
{
8+
"rendering_mode": "advanced",
9+
"context_configuration": [
10+
"screen.texts"
11+
],
12+
"default_head_tags_disabled": false,
13+
"head_tags": [
14+
{
15+
"attributes": {
16+
"async": true,
17+
"defer": true,
18+
"integrity": [
19+
"ASSET_SHA"
20+
],
21+
"src": "http://127.0.0.1:8080/index.js"
22+
},
23+
"tag": "script"
24+
},
25+
{
26+
"attributes": {
27+
"href": "http://127.0.0.1:8080/index.css",
28+
"rel": "stylesheet"
29+
},
30+
"tag": "link"
31+
}
32+
]
33+
}
34+
```
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
title: Build a Login ID screen using ACUL
2+
logo: auth0
3+
thirdParty: false
4+
languages:
5+
- JavaScript
6+
author:
7+
name: Auth0 Team
8+
9+
community: false
10+
topics:
11+
- quickstart
12+
contentType: tutorial
13+
useCase: quickstart
14+
snippets:
15+
dependencies: quickstart/acul/dependencies
16+
setup: quickstart/acul/setup
17+
use: quickstart/acul/use
18+
articles:
19+
- interactive
20+
default_article: interactive
21+
show_steps: true
22+
github:
23+
org: auth0-samples
24+
repo: auth0-react-samples
25+
sdk:
26+
name: auth0-acul-js
27+
url: https://github.com/auth0/universal-login
28+
logo: auth0
29+
requirements:
30+
- auth0-acul-js 1.0.0
31+
next_steps:
32+
- path: interactive
33+
list:
34+
- text: Configure other identity providers
35+
icon: 345
36+
href: "/identityproviders"
37+
- text: Enable multifactor authentication
38+
icon: 345
39+
href: "/multifactor-authentication"
40+
- text: Learn about attack protection
41+
icon: 345
42+
href: "/attack-protection"
43+
- text: Learn about rules
44+
icon: 345
45+
href: "/rules"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Build a Login ID screen using ACUL
3+
description: Learn how to build a Login screen using ACUL
4+
interactive: true
5+
files:
6+
- files/settings
7+
- files/auth_config
8+
- files/index
9+
github:
10+
path: https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01
11+
locale: en-US
12+
---
13+
14+
# Build a Login ID screen using ACUL
15+
16+
17+
<p>`</p>
18+
19+
## Configure Auth0
20+
21+
22+
<p>To use Auth0 services, you’ll need to have an application set up in the Auth0 Dashboard. The Auth0 application is where you will configure how you want authentication to work for the project you are developing.</p><h3>Configure an application</h3><p>Use the interactive selector to create a new Auth0 application or select an existing application that represents the project you want to integrate with. Every application in Auth0 is assigned an alphanumeric, unique client ID that your application code will use to call Auth0 APIs through the SDK.</p><p>Any settings you configure using this quickstart will automatically update for your Application in the <a href="https://manage.auth0.com/#/">Dashboard</a>, which is where you can manage your Applications in the future.</p><p>If you would rather explore a complete configuration, you can view a sample application instead.</p><h3>Configure Callback URLs</h3><p>A callback URL is a URL in your application that you would like Auth0 to redirect users to after they have authenticated. If not set, users will not be returned to your application after they log in.</p><p><div class="alert-container" severity="default"><p>If you are following along with our sample project, set this to <code>http://localhost:3000</code>.</p></div></p><h3>Configure Logout URLs</h3><p>A logout URL is a URL in your application that you would like Auth0 to redirect users to after they have logged out. If not set, users will not be able to log out from your application and will receive an error.</p><p><div class="alert-container" severity="default"><p>If you are following along with our sample project, set this to <code>http://localhost:3000</code>.</p></div></p><h3>Configure Allowed Web Origins</h3><p>An Allowed Web Origin is a URL that you want to be allowed to access to your authentication flow. This must contain the URL of your project. If not properly set, your project will be unable to silently refresh authentication tokens, so your users will be logged out the next time they visit your application or refresh a page.</p><p><div class="alert-container" severity="default"><p>If you are following along with our sample project, set this to <code>http://localhost:3000</code>.</p></div></p>
23+
24+
## Configure ACUL for Login ID screen {{{ data-action="code" data-code="settings.json" }}}
25+
26+
27+
<p>Use <a href="https://github.com/auth0/auth0-cli">Auth0 CLI</a> to enable ACLU Login ID screen in your tenant.
28+
29+
30+
31+
In the root directory of your project, save the settings.json file.</p><p>Enable ACUL by running the following command in your terminal:</p><p><code></code><pre><code class="language-powershell">auth0 ul customize --rendering-mode advanced --prompt login-id --screen login-id --settings-file ./settings.json
32+
33+
</code></pre>
34+
35+
</p><p><div class="alert-container" severity="default"><p><b>Development Setup</b>: This example is using localhost (127.0.0.1:8080) for development. </p><p>For production, you will need to update these URLs to point to your CDN or static hosting service.</p></div></p>
36+
37+
## Initiate Universal Login {{{ data-action="code" data-code="auth_config.json" }}}
38+
39+
40+
<p>Use one of the sample apps provided by Auth0 to initiate Universal Login</p><p>In the root folder of your project, clone the Auth0 sample application using the following command:
41+
42+
43+
44+
<pre><code class="language-powershell">git clone https://github.com/auth0-samples/auth0-react-samples
45+
46+
</code></pre>
47+
48+
</p><p>Change directory to the <code>auth0-react-samples/Sample-01 </code>folder and install the sample application using the following command:</p><p><pre><code class="language-powershell">cd auth0-react-samples/Sample-01
49+
50+
npm install
51+
52+
</code></pre>
53+
54+
</p><p>Change directory to the <code>auth0-react-samples/Sample-01/src</code> folder and add the <code>auth_config.json</code> file. Edit the file to add your tenant&#39;s Custom Domain.</p><p>Run the application</p><p><pre><code class="language-powershell">npm run dev
55+
56+
</code></pre>
57+
58+
</p><p><div class="checkpoint">ACUL Login ID screen Step 2 - Checkpoint <div class="checkpoint-default"><ol><li><p>Open your application (default: <a href="http://localhost:3000/">http://localhost:3000</a>)</p></li><li><p>Select the <b>Log In</b> button on the sample app</p></li><li><p>You should be redirected to your Auth0 domain</p></li></ol><p>After selecting <b>Log In</b>, you should see a blank page. </p><p>This is expected! It means Auth0 is trying to load your custom UI assets, which we have not created yet. </p></div>
59+
60+
<div class="checkpoint-success"></div>
61+
62+
<div class="checkpoint-failure"><p>If you see the default Auth0 page instead of a blank page:</p><ol><li><p>Check if your custom domain is properly configured.</p></li><li><p>Ensure your application is using the custom domain.</p></li></ol><p></p></div>
63+
64+
</div>
65+
66+
</p><p>
67+
68+
</p><p>
69+
70+
</p><p></p>
71+
72+
## Build a custom interface for login-id screen {{{ data-action="code" data-code="index.tsx" }}}
73+
74+
75+
<p>Run a single-page application to build custom login screens. </p><h3>Configure the Boilerplate application</h3><p>1. In the root folder of your project, open a new terminal and clone the Auth0 boilerplate application using the following command:</p><p><pre><code class="language-javascript">git clone https://github.com/auth0-samples/auth0-acul-react-boilerplate
76+
77+
</code></pre>
78+
79+
</p><p>2. Change directory to the <code>auth0-acul-react-boilerplate</code> folder and install the application and the <a href="https://github.com/auth0/universal-login">ACUL JS SDK</a>.</p><p><pre><code class="language-javascript">// open the directory where you git clone the boilerplate
80+
81+
cd auth0-acul-react-boilerplate &amp;&amp; npm i
82+
83+
84+
85+
// Install the ACUL JS SDK
86+
87+
npm install @auth0/auth0-acul-js
88+
89+
</code></pre>
90+
91+
</p><p>3. Build the application</p><p><pre><code class="language-powershell">npm run build
92+
93+
</code></pre>
94+
95+
</p><p>4. Serve the assets</p><p><pre><code class="language-javascript">npx http-server dist -p 8080
96+
97+
</code></pre>
98+
99+
</p><p><div class="alert-container" severity="default"><p>The assets are served from localhost during development. </p><p>For production, you&#39;ll need to serve these assets from a CDN or static hosting service.</p></div></p><p><div class="checkpoint">ACUL Login ID screen quickstart step 4 checkpoint <div class="checkpoint-default"><p>After selecting <b>Log In</b>, you are greeted with a <code>“Hello World”</code> page. </p></div>
100+
101+
<div class="checkpoint-success"></div>
102+
103+
<div class="checkpoint-failure"><p>Make sure to have installed the <a href="https://github.com/auth0/universal-login">ACUL JS SDK</a> after installing the boilerplate application.</p></div>
104+
105+
</div></p><h3>Build the ACUL Login ID screen </h3><p>Change directory to the <code>auth0-acul-react-boilerplate/src/screens/loginId/ </code>and edit the <code>index.tsx</code> file.</p><p>Rebuild the application with the following command:</p><p><pre><code class="language-powershell">npm run build
106+
107+
</code></pre>
108+
109+
</p><p><div class="checkpoint">ACUL Login ID screen quickstart step 4 rebuild the app checkpoint <div class="checkpoint-default"><p>Select <b>Log In</b>. </p><p>You should now see a customized login page as shown below:</p><img src="//images.ctfassets.net/cdy7uua7fh8z/1RGhZSvF6omC3hH5ewzqQO/6ccb62962617d84cede8795d8ee3979d/Screenshot_2025-02-12_at_14.37.25.png" alt="" /><p></p></div>
110+
111+
<div class="checkpoint-success"></div>
112+
113+
<div class="checkpoint-failure"></div>
114+
115+
</div></p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: ApiController.cs
3+
language: csharp
4+
---
5+
6+
```csharp
7+
[Route("api")]
8+
public class ApiController : Controller
9+
{
10+
[HttpGet("private")]
11+
[Authorize]
12+
public IActionResult Private()
13+
{
14+
return Ok(new
15+
{
16+
Message = "Hello from a private endpoint!"
17+
});
18+
}
19+
20+
[HttpGet("private-scoped")]
21+
[Authorize("read:messages")]
22+
public IActionResult Scoped()
23+
{
24+
return Ok(new
25+
{
26+
Message = "Hello from a private-scoped endpoint!"
27+
});
28+
}
29+
}
30+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: HasScopeHandler.cs
3+
language: csharp
4+
---
5+
6+
```csharp
7+
public class HasScopeHandler : AuthorizationHandler<HasScopeRequirement>
8+
{
9+
protected override Task HandleRequirementAsync(
10+
AuthorizationHandlerContext context,
11+
HasScopeRequirement requirement
12+
) {
13+
// If user does not have the scope claim, get out of here
14+
if (!context.User.HasClaim(c => c.Type == "scope" && c.Issuer == requirement.Issuer))
15+
return Task.CompletedTask;
16+
17+
// Split the scopes string into an array
18+
var scopes = context.User
19+
.FindFirst(c => c.Type == "scope" && c.Issuer == requirement.Issuer).Value.Split(' ');
20+
21+
// Succeed if the scope array contains the required scope
22+
if (scopes.Any(s => s == requirement.Scope))
23+
context.Succeed(requirement);
24+
25+
return Task.CompletedTask;
26+
}
27+
}
28+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: HasScopeRequirement.cs
3+
language: csharp
4+
---
5+
6+
```csharp
7+
public class HasScopeRequirement : IAuthorizationRequirement
8+
{
9+
public string Issuer { get; }
10+
public string Scope { get; }
11+
12+
public HasScopeRequirement(string scope, string issuer)
13+
{
14+
Scope = scope ?? throw new ArgumentNullException(nameof(scope));
15+
Issuer = issuer ?? throw new ArgumentNullException(nameof(issuer));
16+
}
17+
}
18+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Program.cs
3+
language: csharp
4+
---
5+
6+
```csharp
7+
var builder = WebApplication.CreateBuilder(args);
8+
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
9+
.AddJwtBearer(options =>
10+
{
11+
options.Authority = $"https://{builder.Configuration["Auth0:Domain"]}/";
12+
options.Audience = builder.Configuration["Auth0:Audience"];
13+
options.TokenValidationParameters = new TokenValidationParameters
14+
{
15+
NameClaimType = ClaimTypes.NameIdentifier
16+
};
17+
});
18+
19+
builder.Services
20+
.AddAuthorization(options =>
21+
{
22+
options.AddPolicy(
23+
"read:messages",
24+
policy => policy.Requirements.Add(
25+
new HasScopeRequirement("read:messages", domain)
26+
)
27+
);
28+
});
29+
30+
builder.Services.AddSingleton<IAuthorizationHandler, HasScopeHandler>();
31+
32+
var app = builder.Build();
33+
app.UseAuthentication();
34+
app.UseAuthorization();
35+
```

articles/quickstart/backend/aspnet-core-webapi/files/appsettings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: appsettings.json
33
language: json
44
---
5-
5+
66
```json
77
{
88
"Auth0": {

0 commit comments

Comments
 (0)