Git Product home page Git Product logo

oktadev / okta-spring-boot-2-angular-7-example Goto Github PK

View Code? Open in Web Editor NEW
86.0 13.0 68.0 275 KB

A Cool Cars Example that showcases Spring Boot 2.1, Angular 7, and Okta's support for both.

Home Page: https://developer.okta.com/blog/2018/08/22/basic-crud-angular-7-and-spring-boot-2

License: Apache License 2.0

JavaScript 6.61% TypeScript 67.41% HTML 9.23% CSS 1.09% Java 15.67%
angular spring-boot crud-sample angular7 spring-boot2 typescript java okta-angular authentication oidc

okta-spring-boot-2-angular-7-example's Introduction

Basic CRUD App with Angular 7.0 and Spring Boot 2.1

This example app shows how to build a basic CRUD app with Spring Boot 2.1, Spring Data, and Angular 7.0.

Please read Build a Basic CRUD App with Angular 7.0 and Spring Boot 2.1 to see how this app was created.

Prerequisites: Java 8 and Node.js. For Java 10+, you'll need to change the java.version property and jaxb-api as a dependency. See Josh Long's spring-boot-and-java-10 project on GitHub for more information.

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.

Getting Started

To install this example application, run the following commands:

git clone https://github.com/oktadeveloper/okta-spring-boot-2-angular-7-example.git
cd okta-spring-boot-2-angular-7-example

This will get a copy of the project installed locally. To install all of its dependencies and start each app, follow the instructions below.

To run the server, cd into the server folder and run:

./mvnw spring-boot:run

To run the client, cd into the client folder and run:

npm install && npm start

Create a New OIDC App in Okta

To create a new OIDC app on Okta:

  1. Log in to your developer account, navigate to Applications, and click on Add Application.
  2. Select Single-Page App and click Next.
  3. Give the application a name, change all instances of localhost:8080 to localhost:4200 and click Done.

Server Configuration

Set your domain and copy the clientId into server/src/main/resources/application.yml.

NOTE: The value of {yourOktaDomain} should be something like dev-123456.oktapreview. Make sure you don't include -admin in the value!

okta:
  oauth2:
    client-id: {clientId}
    issuer: https://{yourOktaDomain}/oauth2/default

Client Configuration

For the client, set the issuer and copy the clientId into client/src/app/app.module.ts.

const config = {
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  redirectUri: window.location.origin + '/implicit/callback',
  clientId: '{clientId}'
};

Links

This example uses the following open source libraries from Okta:

Help

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

License

Apache 2.0, see LICENSE.

okta-spring-boot-2-angular-7-example's People

Contributors

rdegges avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

okta-spring-boot-2-angular-7-example's Issues

String Index Out Of Range (bare) / 401 (with /oauth2/default) - when using example

I can not run the server with "our company" configuration and am unsure why. After creating an SPA Client in Okta with OpenID Connect I clone the project. I adjust the configuration as follows:

  1. http://localhost:4200/implicit/callback set as Login redirect URI in Okta
  2. Adjust my application yaml and app module typescript as shown below
  3. Test if https://company.okta.com/.well-known/openid-configuration works (it does with the real company name)

application.yml:

    okta:
      oauth2:
        client-id: 20-digit-Client-ID-string
        issuer: https://company.okta.com

app.module.ts:

    const config = {
      issuer: 'https://company.okta.com',
      redirectUri: 'http://localhost:4200/implicit/callback',
      clientId: '20-digit-Client-ID-string'
    };

Java version:

java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)

Maven version:

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 1.8.0_192, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre
Default locale: en_NL, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"

JAVA_HOME:

/Users/m.ton/.jenv/versions/oracle64-1.8.0.192

If I then run ./mvnw spring-boot:run from the server folder I get the following error:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'okta.client-com.okta.spring.config.OktaClientProperties': Could not bind properties to 'OktaClientProperties' : prefix=okta.client, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'okta.client.org-url' to java.lang.String: String index out of range: -1 -> [Help 1]

If I change my config to the below "default" from the clone my backend runs just fine.

application.yml:

    okta:
      oauth2:
        client-id: 0oagqzcu86BBOq2jF0h7
        issuer: https://dev-737523.oktapreview.com/oauth2/default

Obviously I can't onboard users that way haha, but it runs. If I use
https://company.okta.com/oauth2/default by the way (this isn't what is shown in the Issuer field in Okta, but just in case) I receive the following error:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerConfiguration]; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwkTokenStoreConfiguration: 401 Unauthorized -> [Help 1]

Could you tell me what I can try/provide to get it running on my machine? I'm at my wits end. Using Java11 + the Issuer as shown in Okta gives the same error, albeit formatted a little differently:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'okta.client-com.okta.spring.config.OktaClientProperties': Could not bind properties to 'OktaClientProperties' : prefix=okta.client, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'okta.client.org-url' to java.lang.String: begin 0, end -1, length 25 -> [Help 1]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.