All Projects → oktadev → okta-react-native-spring-boot-example

oktadev / okta-react-native-spring-boot-example

Licence: Apache-2.0 license
React Native + Spring Boot + OIDC

Programming Languages

java
68154 projects - #9 most used programming language
typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
SCSS
7915 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to okta-react-native-spring-boot-example

okta-jhipster-microservices-oauth-example
A microservices architecture built with JHipster, OAuth 2.0, and Okta
Stars: ✭ 29 (+20.83%)
Mutual labels:  jhipster, oidc
rider
Fliver Rider for Android & iOS🛺
Stars: ✭ 80 (+233.33%)
Mutual labels:  mobile-app
HelpingHand
Leveraging Intelligent Processing Tools and Algorithms to help the Visually Impaired see and navigate 💥✨
Stars: ✭ 29 (+20.83%)
Mutual labels:  mobile-app
Social-Dating-Android-App
📢 The pH7 Social Dating Android App allows you to use pH7CMS through an easy-going and intuitive Android app. Keep pH7CMS everywhere in your pocket and make as much modification as you can thanks the 100% open source code
Stars: ✭ 37 (+54.17%)
Mutual labels:  mobile-app
AspNetCoreBackChannelLogout
ASP.NET Core Back-Channel Logout for Hybrid Clients, Redis, Key Vault, Azure
Stars: ✭ 17 (-29.17%)
Mutual labels:  oidc
study-snap
📓📲 Flutter app for managing study materials in form of photos.
Stars: ✭ 34 (+41.67%)
Mutual labels:  mobile-app
cabenomeubolso
Faça compras dentro do seu orçamento!
Stars: ✭ 25 (+4.17%)
Mutual labels:  mobile-app
keycloak-springsecurity5-sample
Spring Security 5 OAuth2 Client/OIDC integration with Keycloak sample
Stars: ✭ 55 (+129.17%)
Mutual labels:  oidc
react-native-text-area
Simple and easy to use TextArea for React Native.
Stars: ✭ 20 (-16.67%)
Mutual labels:  mobile-app
MobileHumanPose
This repo is official PyTorch implementation of MobileHumanPose: Toward real-time 3D human pose estimation in mobile devices(CVPRW 2021).
Stars: ✭ 206 (+758.33%)
Mutual labels:  mobile-app
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+1879.17%)
Mutual labels:  oidc
Dianoia-app
Mobile (Ionic 3 - Angular 4) app about non-pharmaceutical activities and information for people with dementia.
Stars: ✭ 13 (-45.83%)
Mutual labels:  mobile-app
path-19
COVID-19 contact tracing mobile app
Stars: ✭ 12 (-50%)
Mutual labels:  mobile-app
react-mobile-social
The React Mobile Social is an open source social app using React Native.
Stars: ✭ 51 (+112.5%)
Mutual labels:  mobile-app
app-sense
📱 Easily learn & create React Native app basics using zero coding, drag-and-drop interface & logic blocks.
Stars: ✭ 86 (+258.33%)
Mutual labels:  mobile-app
generator-jhipster-spring-cloud-stream
📪 JHipster module for messaging microservices with Spring Cloud Stream
Stars: ✭ 22 (-8.33%)
Mutual labels:  jhipster
CrossMobile
Create native iOS, Android, Windows Phone and Desktop applications in Java. Write it once, and produce sophisticated multiplatform applications.
Stars: ✭ 48 (+100%)
Mutual labels:  mobile-app
casdoor-go-sdk
Go client SDK for Casdoor
Stars: ✭ 37 (+54.17%)
Mutual labels:  oidc
nextLevelWeek2.0
Projeto Proffy desenvolvido na NLW #2 em homenagem à o dia do profissional de educação.
Stars: ✭ 19 (-20.83%)
Mutual labels:  mobile-app
authentik
The authentication glue you need.
Stars: ✭ 2,941 (+12154.17%)
Mutual labels:  oidc

React Native mobile app, Spring Boot API, and OIDC Authentication

A React Native and Spring Boot app with the following features:

  • Secure, Spring Boot API
  • React Native app that works on iOS or Android
  • Production API on Cloud Foundry
  • Production API on Google Cloud (via Kubernetes and GKE)
  • OIDC Login with Okta or Keycloak

All generated by JHipster and Ignite JHipster! 👏❤️

Please read Build a Mobile App with React Native and Spring Boot to see how this app was created.

Prerequisites: Java 8 and Node 8.

Okta has standards-based APIs that support OIDC, OAuth 2.0, PKCE, and SAML. They're legit, you should check them out.

Getting Started

To download this example locally, run the following commands:

git clone https://github.com/oktadeveloper/okta-react-native-spring-boot-example.git
cd okta-react-native-spring-boot-example

Create a Web Application in Okta

You will need to create an OpenID Connect Application in Okta to get your values to perform authentication. Log in to your Okta Developer account and navigate to Applications > Add Application. Click Web and click Next. Give the app a name you'll remember, specify http://localhost:8080/login as a Login redirect URI, and click Done. Note the client ID and secret. You'll need to copy/paste them into a file in a minute.

Create a ROLE_ADMIN and ROLE_USER group (Users > Groups > Add Group) and add users to them. I recommend adding the account you signed up with to ROLE_ADMIN and creating a new user (Users > Add Person) to add to ROLE_USER.

Navigate to API > Authorization Servers and click the one named default to edit it. Click the Claims tab and Add Claim. Name it "groups", and include it in the ID Token. Set the value type to "Groups" and set the filter to be a Regex of .*. Click Create to complete the process.

Create a file on your hard drive called ~/.okta.env and specify the settings for your app in it.

#!/bin/bash

# Okta with JHipster

export SECURITY_OAUTH2_CLIENT_ACCESS_TOKEN_URI="https://{yourOktaDomain}/oauth2/default/v1/token"
export SECURITY_OAUTH2_CLIENT_USER_AUTHORIZATION_URI="https://{yourOktaDomain}/oauth2/default/v1/authorize"
export SECURITY_OAUTH2_RESOURCE_USER_INFO_URI="https://{yourOktaDomain}/oauth2/default/v1/userinfo"
export SECURITY_OAUTH2_CLIENT_CLIENT_ID="{yourClientId}"
export SECURITY_OAUTH2_CLIENT_CLIENT_SECRET="{yourClientSecret}"

TIP: Make sure your URI variables do not have -admin in them. This is a common mistake.

Create a Native Application in Okta

Ignite JHipster leverages React Native AppAuth, an SDK for communicating with OAuth 2.0 providers. It supports PKCE instead of a client secret, which is a more secure configuration. To use PKCE, you'll need to create a new Native application in Okta.

Log in to your Okta Developer account and navigate to Applications > Add Application. Click Native and click Next. Give the app a name you'll remember (e.g., React Native), select Refresh Token as a grant type, in addition to the default Authorization Code. Change the Login redirect URI to be healthpoints://authorize and click Done.

Modify react-native-app/app/modules/login/login.sagas.js to use the generated clientId.

const { issuer, scope } = authInfo.data
const config = {
  issuer,
  clientId: '{yourNativeClientId}',
  scopes: scope.split(' '),
  redirectUrl: `${AppConfig.appUrlScheme}://authorize`
}

Start Spring Boot API

In the terminal where you want to run the Spring Boot API, run source ~/.okta.env, followed by ./gradlew. You should be able to login using Okta at http://localhost:8080.

Start React Native App

Open a new terminal and navigate to the react-native-app directory. Run yarn to install all the dependencies (brew install yarn if you don't have it). Then run react-native run-ios or react-native run-android to start an emulator with the app running in it. Want more info? Read the blog post. ;)

Links

This example uses some excellent open source projects:

And some kick-ass platforms:

Help

Please post any questions as comments on the companion blog post, or visit our Okta Developer Forums. You can also email [email protected] if you would like to create a support ticket.

License

Apache 2.0, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].