Can I enable the configurator for certain users only?
If you do not want your configurator to be publicly accessible, you can block access. There are various reasons for doing this:
- Only certain known persons should be allowed to configure.
- Only customers who are already registered in your store or ERP should be able to access the configurator.
Auth0
We use the well-known login service https://auth0.com/.
You can set up a free account there.
- Then create an application.
- Select "Single Page Application" under Settings > Application Type.
- Under Settings > Allowed Callback URLs and Allowed Web Origins, add add "https://k3.objectcode.de/app".
- Set Credentials > Authentication Method to "None".
- Select the Connections that are correct for you. This can be several:
- "Username-Password-Authentication" allows you to add specific people under User Management.
- Under Authentication > Social you can request access via Google, for example.
- Under Authentication > Enterprise > SAML you can set up SSO with your ERP, store or website.
Note the "domain" and "clientId" of your application under Settings.
Custom OAuth Connections for WordPress
For the relatively frequent case that you want to use WordPress, you can use the free plan from Auth0.
First make your WordPress an "OAuth2 server":
- Install and activate this WordPress plugin.
- Click on "miniOrange OAuth Server" in the sidebar
- Select a "Client Name" and save.
- Leave this page open, you will need information from it.
Now establish the connection in Auth0:
- Click on Authentication > Social
- Click on "Create Connection"
- Select the last option, "Create Custom"
- Give the connection a name.
- Transfer from the WordPress plugin page:
- Authorization URL
- Token URL
- Scope
- Client ID
- Client Secret
- Make a note of the "Userinfo Endpoint".
Finally, enter this code in the "Fetch User Profile Script" field, replace the "Userinfo Endpoint":
function(accessToken, ctx, cb) {
request({
method: 'GET',
url: '<Userinfo Endpoint>',
headers: {
Authorization: 'Bearer ' + accessToken
}
}, function(err, resp, body) {
if(err) {
return cb(err)
}
if(resp.statusCode !== 200) {
return cb(new Error('StatusCode:' + resp.statusCode));
}
let bodyParsed;
try {
bodyParsed = JSON.parse(body);
} catch (jsonError) {
return cb(new Error(body));
}
const profile = {
user_id: "anonymous",
name: "none"
};
cb(null, profile);
}
);
}
- Click on "Save changes"
- Click on "Try Connection"
You should now be directed to your website and be able to use it. If this is successful, you can add the new "Social connection" to your "Application".
K3
- Now switch to the Options of your configurator in K3.
- There in the Configurator access tab.
- Activate the login.
- Enter the "domain" and "clientId" of your Auth0 application.
- Save and do not forget to publish.
The live version of your configurator will then request a login via Auth0.