<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D51Y00008JOT0uSAHOkta Classic EngineIntegrationsAnswered2023-08-24T19:43:00.000Z2020-04-18T02:38:21.000Z2020-04-18T03:57:01.000Z
How to make otka login work from inside a docker container?

Hello,

 

I've developed a web application based on the tutorial in the link below, which used okta for the login:

 

https://developer.okta.com/blog/2018/07/19/simple-crud-react-and-spring-boot

 

This worked great until I deployed it into docker. When run from a container, the login api call is apparently going directly to the spring boot app instead of getting redirected to okta.

 

The reason I say this is spring is returning the default "White Label Error Page" when I try to log in, and the url displayed in the browser is "http://localhost:8080/private".

 

This must come for the following code in the React front end:

 

login() {

let port = (window.location.port ? ':' + window.location.port : '');

if (port === ':3000') {

port = ':8080';

}

window.location.href = '//' + window.location.hostname + port + '/private';

}

 

Any ideas on why this wouldn't work from inside a docker container? I'm a newbie to Docker, so I'm not sure what setup needs to be done in this situation.

 

Here's the docker-compose.yml

 

version: "3"

services:

 

 * Backend Service

 

 app-server:

  image: licensing-app

  ports:

   - "8080:8080"

  networks:

   - backend

  depends_on:

   - mysqldb

 

 * Frontend Service

 app-client:

  image: license_front_end

  ports:

   - "3000:80" * Map the exposed port 80 on the container to port 3000 on the host machine

  restart: always

  depends_on:

   - app-server

  networks:

   - backend 

 

 * Database Service (Mysql)

 

 mysqldb:

  image: mysql:8

  ports:

   - "3306:3306"

  environment:

    MYSQL_ROOT_PASSWORD: mypassword

    MYSQL_DATABASE: license_db

  volumes:

   - db-data:/var/lib/mysql

  networks:

   - backend

 

* Volumes

volumes:

 db-data:

 

* Networks to be created to facilitate communication between containers

networks:

 backend:

 

Thanks in advance for any help or suggestions.

 


  • Some additional info - per this link: 

     

    spring.security.oauth2.client.registration.okta.client-id

     

    I've added three environment variables (with the "xxx'" replaced with my credentials) to the yml, but still no luck. The relevant section is shown below:

     

     app-server:

      image: licensing-app

      ports:

       - "8080:8080"

      networks:

       - backend

      depends_on:

       - mysqldb

      environment:

       - OKTA_OAUTH2_ISSUER=https://dev-xxxxxx.okta.com/oauth2/default

       - OKTA_OAUTH2_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxx

       - OKTA_OAUTH2_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

     

    Expand Post
This question is closed.
Loading
How to make otka login work from inside a docker container?