Git Product home page Git Product logo

Comments (10)

bdemers avatar bdemers commented on May 30, 2024

Hey @vekdeq!

What call is failing? What is the error you are seeing? What have you tried so far?

from okta-auth-java.

vekdeq avatar vekdeq commented on May 30, 2024

Hi Brian,

Thanks for quick response !! Here is the code :

public boolean isUserAuthenticated(String uid, String pwd) {
    try {
        AuthenticationResponse response = oktaAuthClient.authenticate(uid, pwd.toCharArray(), null, null);
        if (response !=null && response.getSessionToken() !=null && response.getStatus() == AuthenticationStatus.SUCCESS) {
            return true;
        } else {
            return false;
        }
    } catch (AuthenticationException e) {
        LOGGER.error("---- Unable to Authenticate User : ----"+ uid, e);
        return false;
    }		 
}

We are getting AuthenticationException. The moment, we activate user from Okta Portal - it goes through. The exception trace is as below :

 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.okta.sdk.resource.ResourceException: HTTP 401, Okta E0000004 (Authentication failed), ErrorId oaecVQ9r54bStaWdl1SHc4yyQ
        at com.okta.sdk.impl.ds.DefaultDataStore.execute(DefaultDataStore.java:453)

Okta Support replied to case just now:

When a user has a staged status, it needs to be activated first with : https://developer.okta.com/docs/reference/api/users/#activate-user , and only then the auth will work.

So it seems we hit the roadblock now.

Vivek V. Bedekar

from okta-auth-java.

bdemers avatar bdemers commented on May 30, 2024

Are you using the temporary password for this attempt?

from okta-auth-java.

vekdeq avatar vekdeq commented on May 30, 2024

Yeah - the pwd which we / application create as part of createUser Api call as below :

String tempPwd = generatePassword(10);
UserBuilder.instance()
.setEmail(email)
.setFirstName(firstname)
.setLastName(lastName)
.setLogin(email)
.setPassword(tempPwd.toCharArray())
.setActive(false)
//.addGroup(TODO)
.buildAndCreate(oktaClient);

	 return tempPwd;

from okta-auth-java.

bdemers avatar bdemers commented on May 30, 2024

this inactive user was allowed to authenticate in other places? Or are the users ACTIVE when you attempt to login directly with Okta?

from okta-auth-java.

vekdeq avatar vekdeq commented on May 30, 2024

It's not inactive user - the status says staged on OKTA dashboard below. Should I try creating without - .setActive(false) ?

Test DRO [email protected] [email protected] Staged
  TEST RCO [email protected] [email protected]

from okta-auth-java.

bdemers avatar bdemers commented on May 30, 2024

Yes, .setActive(true) would allow the user to login

from okta-auth-java.

vekdeq avatar vekdeq commented on May 30, 2024

yeah - but don't want user to do that - till he complete other formalities which are built as part of account setup app/flow on our side. Hence, we need temp pwd to authenticate user and then force him to complete account setup includes - setting permanent pwd & other steps. Till that time, we were hoping to keep user in staged status and activate after account set up is complete.

The reason, for not activating upfront is - user can then log in actual site using temp pwd (without completing other legal formalities). I think, I got a work around to it as below;

activate user on approval - but don't add user to group - Only Okta User.
add to group & apps - on completing account setup. - Okta + Our Apps.

I hope it works : Question on that.
How to add groups dynamically - do you have any property file configuration for that ? As Grp ID will be different for environments.

Vivek V. Bedekar

from okta-auth-java.

bdemers avatar bdemers commented on May 30, 2024

@vekdeq I'm not sure I'm following, you want the user to be able to login from one place but not another?

I think you will need to take another approach, like a role/group check.

You should also take a look at our new Hooks (specifically the registration hook: https://developer.okta.com/docs/reference/registration-hook/#see-also)

from okta-auth-java.

bdemers avatar bdemers commented on May 30, 2024

I'm going to close this issue, as this is the intended result (you cannot login with a user that is deactivated)

from okta-auth-java.

Related Issues (20)

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.