Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException: issuer cannot be empty #23

Closed
mraible opened this issue Nov 4, 2017 · 24 comments
Closed

IllegalArgumentException: issuer cannot be empty #23

mraible opened this issue Nov 4, 2017 · 24 comments

Comments

@mraible
Copy link
Contributor

mraible commented Nov 4, 2017

I'm working with @starbuxman to develop a reactive microservices stack for our Devoxx talk. Using 0.2.0 of this library throws the following error after I integrate things:

Caused by: java.lang.IllegalArgumentException: issuer cannot be empty
    at org.springframework.util.Assert.hasText (Assert.java:276)
    at com.okta.spring.oauth.discovery.OidcDiscoveryClient.<init> (OidcDiscoveryClient.java:36)
    at com.okta.spring.oauth.OktaPropertiesMappingEnvironmentPostProcessor.discoveryPropertiesSource (OktaPropertiesMappingEnvironmentPostProcessor.java:137)
    at com.okta.spring.oauth.OktaPropertiesMappingEnvironmentPostProcessor.postProcessEnvironment (OktaPropertiesMappingEnvironmentPostProcessor.java:95)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent (ConfigFileApplicationListener.java:170)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent (ConfigFileApplicationListener.java:156)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener (SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener (SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared (EventPublishingRunListener.java:73)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared (SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment (SpringApplication.java:349)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:317)

Steps to reproduce:

git clone git@github.com:mraible/cloud-native-pwas.git
cd cloud-native-pwas/kotlin-reactive/edge-service

Modify pom.xml to add this library:

<dependency>
	<groupId>com.okta.spring</groupId>
	<artifactId>okta-spring-boot-starter</artifactId>
	<version>0.2.0</version>
</dependency>

Add properties to src/main/resources/application.properties:

okta.oauth2.issuer=https://dev-158606.oktapreview.com/oauth2/default
okta.oauth2.clientId=XXX
okta.oauth2.clientSecret=XXX

Run ./mvnw spring-boot:run.

@mraible
Copy link
Contributor Author

mraible commented Nov 4, 2017

This happens incloud-native-pwas/kotlin-basic/edge-service as well. This is a regular Spring Boot 2.0.0.M5 app.

@peavers
Copy link

peavers commented Nov 4, 2017

Just noting I faced the same issue when using with Spring Cloud Dalston.SR4; My only solution was to move the okta.oauth2.issuer config to the bootstrap.yml file rather than application.yml which did work, however isn't a proper solution.

@ricard0javier
Copy link

got the same issue; moving the properties to the bootstrap file works for me as well. The problem is that they should be retrieved from an external Properties source as Consul or Vault.

@mraible
Copy link
Contributor Author

mraible commented Nov 6, 2017

I tried create a src/main/resources/bootstrap.yml with the following:

okta:
  oauth2:
    issuer: https://dev-158606.oktapreview.com/oauth2/default
    clientId: XXX
    clientSecret: YYY

However, I still get the same issue on startup. Am I creating the file in the correct location?

2017-11-06 12:35:01.507 ERROR 58475 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalArgumentException: issuer cannot be empty
        at org.springframework.util.Assert.hasText(Assert.java:276) ~[spring-core-5.0.0.RELEASE.jar:5.0.0.RELEASE]
        at com.okta.spring.oauth.discovery.OidcDiscoveryClient.<init>(OidcDiscoveryClient.java:36) ~[okta-spring-security-oauth2-0.2.0.jar:0.2.0]
        at com.okta.spring.oauth.OktaPropertiesMappingEnvironmentPostProcessor.discoveryPropertiesSource(OktaPropertiesMappingEnvironmentPostProcessor.java:137) ~[okta-spring-security-oauth2-0.2.0.jar:0.2.0]
        at com.okta.spring.oauth.OktaPropertiesMappingEnvironmentPostProcessor.postProcessEnvironment(OktaPropertiesMappingEnvironmentPostProcessor.java:95) ~[okta-spring-security-oauth2-0.2.0.jar:0.2.0]
        at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:170) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]

@haichauofficience
Copy link

@mraible I'm facing the same issue like this. Did you solve your problem?

@bdemers
Copy link
Contributor

bdemers commented Jan 8, 2018

@haichauofficience was fixed in the 0.3.0 release (just promoted, so it could take a couple hours to show up on Maven Central)

@haichauofficience
Copy link

@bdemers Ok, thank you very much.

@haichauofficience
Copy link

@bdemers I still don't see the new version on Maven Central so far. Could you please check it out?

@bdemers
Copy link
Contributor

bdemers commented Jan 10, 2018

@mraible mraible closed this as completed Feb 23, 2018
@ijer-web
Copy link

ERROR TypeError: Cannot read property 'issuer' of undefined.
Absolutely the same problem.

@bdemers
Copy link
Contributor

bdemers commented May 21, 2018

@ijer-web which version?

@bdemers bdemers reopened this May 21, 2018
@ijer-web
Copy link

@bdemers angular 6

@bdemers
Copy link
Contributor

bdemers commented May 22, 2018

@ijer-web sorry, I meant which version of ‘Okta-spring-boot-starter

@ijer-web
Copy link

ijer-web commented May 23, 2018 via email

@mraible
Copy link
Contributor Author

mraible commented May 23, 2018 via email

@bdemers
Copy link
Contributor

bdemers commented May 31, 2018

The Okta starter should be working with cloud config now as of 0.3.0+

@bdemers bdemers closed this as completed May 31, 2018
@PradeepKumarAurotfp
Copy link

PradeepKumarAurotfp commented Dec 12, 2018

@bdemers - We are using okta spring boot satarter 0.6.0 and I am facing the same issue

@bdemers
Copy link
Contributor

bdemers commented Dec 12, 2018

@PradeepKumarAurotfp what props are returned from your config server?

@PradeepKumarAurotfp
Copy link

@bdemers - I am able to get the following properties from the vault
mongo properties
spring.data.mongodb.username=${mongodb.username}
spring.data.mongodb.password=${mongodb.password}

okta properties
okta.oauth2.client-id={okta.clientId}

@bdemers
Copy link
Contributor

bdemers commented Dec 13, 2018

@PradeepKumarAurotfp no issuer?
Have you tried okta.oauth2.clientId?

@PradeepKumarAurotfp
Copy link

@bdemers Thank you, it works for me. What I changed was, I added the properties in vault as you mentioned using following keys and removed the properties from the application.properties file (which were there earlier).

okta.oauth2.clientId
okta.oauth2.issuer

Although it works this way. I am still not able to understand why id does not work for issuer and works for client it when i keep following properties in application.properties

okta.oauth2.clientId=${account.clientId}
okta.oauth2.issuer=${account.issuer}

values saved in vault using key account.clientId and account.issuer

@bdemers
Copy link
Contributor

bdemers commented Dec 14, 2018

@PradeepKumarAurotfp thanks for the follow up!

I'll guessing it has to do with the order at which property sources are defined when cloud-config is added (pure speculation though)

@prasadkolasani
Copy link

@bdemers This is nice article which is working nice. https://developer.okta.com/blog/2018/04/02/client-creds-with-spring-boot

But my problem is, when I tried same using spring-starter-web (instead of commandliner), then it is always redirecting to login page. Is there any way we can directly authenticate similar to commandLiner instead of redirecting to login page? Please help.

@bdemers
Copy link
Contributor

bdemers commented Apr 10, 2019

@prasadkolasani I'm not sure i'm following your question. Your best bet might be to post to our dev forum: https://devforum.okta.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants