Using Auth0
Using Auth0 for your Rock mobile application login.
If you are building your app utilizing the orange/blue Rock Mobile application and would like to test Auth0, you should coordinate your efforts with the App Factory publishing service.
What is Auth0?
Auth0 is a cloud-based identity and access management (IAM) platform that provides developers and organizations with secure and easy-to-use solutions for authenticating and authorizing user access to applications. Auth0 offers a range of authentication methods such as username and password, social identity providers, multi-factor authentication, and more.
With Auth0, developers can add authentication and authorization capabilities to their applications quickly and easily. Check out their website to learn more about the services they offer.
Setup
To ensure Auth0 works seamlessly in Rock Mobile, follow this step-by-step guide to configure a new Auth0 application for Rock Mobile. In this guide, we will:
Create and configure a new Auth0 application for Rock Mobile.
Configure Auth0 to provide enough data for Rock sign-up.
Configure Rock Mobile to support Auth0.
Rock requires a First Name
, Last Name
and either a valid Phone Number
or Email
to process external authentication. You should take steps to ensure that those specific data points are always returned from Auth0 authentication.
Creating an Auth0 Application
To begin, let's create the Auth0 application that will handle our Rock Mobile logins. You should only need one application for all of your mobile applications.
In the Auth0 Dashboard, create a new application.
You cannot use the same application you've configured for Rock Web, since it requires settings specific to mobile authentication.
Select
Native
as the type of application.Head into the
Settings
of the Application. You can ignore the Quick Start guide that they typically start you on. Note down theClient ID
andDomain
of your Auth0 application.
Make sure you have your app's
Bundle ID
(iOS) andPackage Name
(android) available. If you are unsure of these values or where to retrieve them you should contact the AppFactory publishing service.In the
Allowed Callback URLs
of the Auth0 application, add an entry in the following format. If your package name and bundle identifier differ, you will require two URLs, one for each.
Under
Credentials
, ensure theToken Endpoint Authentication Method
is set toNone
. Mobile apps use a different form of authentication in comparison to web applications.
Great! We should now have all of the basic configuration finished.
Getting Additional Data for Rock
In order to sign a person up, Rock requires a First Name
, Last Name
, and either a Phone Number
or an Email
. Auth0 does not require all of these data points out of the box. There are quite a few ways that you could customize the login flow to support this additional data, but we're going to keep it pretty straightforward in this guide.
To ensure all of the necessary data for Rock is obtained, we will:
Configure Universal Login to add additional fields for database sign-up.
(optional) Configure a post-login rule to pass additional information to Rock.
Configuring Universal Login
First, we need to configure Auth0's
Universal Login
to ensure there is enough data collected to create a person in Rock. Head over toBranding > Universal Login > Advanced Options > Login
. Enable theCustomize Login Page
option.Scroll down to the customizable HTML. This section will allow us to modify the sign-up page to request additional information. You can supply
additionalSignUpFields
to the mainLock
object to set specific user data. In this tutorial, we'll be accepting an additional phone number, gender, and the individual's first and last name. You can view the Auth0 documentation to see more about what you can do with these fields.
The entire file looks like this if you want to copy and paste the entire example.
Once finished, paste it into the HTML section into the box. Ensure the preview looks correct.
(optional) Pass in Additional Information to your Rock instance
This part of the tutorial utilizes an Auth0 Action, which is not part of the free Auth0 plan. If you don't want or need to pass down custom fields such as Gender
, feel free to skip to Configuring Rock Mobile.
There are a billion ways in which you can configure your Auth0 login process. You may want to enhance the process to return additional information to your Rock instance (such as Gender
, BirthDate
, etc).
This is supported through the use of Identity Claims. In short, identity claims are set during your authentication process to provide additional information about an authenticated individual. There are quite a few ways you can set these claims as well, mostly through Auth0 Rules or Actions.
Do you remember the
additionalSignUpFields
we configured earlier? Let's add some more fields to that.
This will add a Gender
picker that reflects the Gender enum, and a basic Phone Number
field.
Jump into
Action > Flows
and pressLogin
to configure a post-login flow. SelectBuild Custom
.
In
onExecutePostLogin
method, configure the identity claims to pass down the proper data, like such:
Press Deploy
. The last thing we need to do is add it to the login flow. Add the Action
you just created before the completion of the login, like such. Make sure to press Apply
afterwards.
Configuring Rock Mobile
There are a couple of configuration steps for Rock Mobile.
In your mobile application (
Cms Configuration > Mobile Applications
), look for theAuth0 Client ID
andAuth0 Domain
settings. Update them with your application values.Enable Auth Login in the Login block.
Hooray! You should now be fully capable of handling Auth0-related logins.
Go into your login block, and press the Login With Auth0
button. That button has a btn-auth0
style class applied for customization. You should now be prompted with an Auth0 login.
In the Sign Up
tab, you should see all of the additional fields you configured.
When you successfully log in with Auth0 (even for new accounts), a Person
in Rock will be matched or created with the values of the Auth0 account.
Supported Claims
The following identity claims are supported and can be utilized to supply additional information about a Rock Person. Since Auth0 configurations can vary, we supply a few different keys that are recognized and translated accordingly.
Key(s) | Type | Value |
---|---|---|
firstname, first_name, given_name | string | The |
lastname, last_name, family_name | string | The |
phone, phonenumber, phone_number | string | The |
campus, campus_guid | Guid | The |
photo, picure, profile_image, avatar | string | The source of the |
nickname | string | The nickname of the |
birthday, birth_date, birthdate, date_of_birth | DateTime | The |
gender | string | The |
Last updated