Revoke all the refresh token issued to the user during resetpassword

This topic has 7 replies, 4 voices, and was last updated 3 years ago by sahoob.

  • Author
    Posts
  • #21524
     sahoob
    Participant

    Hi,

    We want to invalidate all the access token and refresh token issued to the user during reset password and change username.
    I am able to locate the token on opendj by below query. But do we have any factory class from where i will get the opendj connection object from openam for configuration store.

    ./ldapsearch -h localhost -p 50389 -D “cn=Directory Manager” -w cangeit -b “ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=forgerock,dc=org” “(&(coreTokenString03=demo)(coreTokenString09=myClientID)(!(coreTokenString10=access_code)))” coreTokenString10

    I am looking into below, but its returning user store details.

    AMIdentity amIdentity = null;
    amIdentity = AuthD.getAuth().getIdentity(IdType.USER, userName,
    getRequestOrg());
    IdSearchResults searchResults = this.amIdentityRepo
    .searchIdentities(IdType.USER, this.userName, idsc);

    Does anyone have the sample code to connect to opendj and retrieve the above token details from config store or CTS store? I don’t want to manage the opendj connection with in mycode, if we have any connection factory available on openam code, that I can user then its will be very helpful.

    Regards,
    Biswajit Sahoo

    #21525
     domingos.creado
    Participant

    Hi Biswajit,

    Have you tried the token administration endpoints provided by openam?
    there are endpoints to query the existing tokens for a username and a revoke specific token.
    you can find more details on OAuth2 guide:
    https://backstage.forgerock.com/docs/am/5.5/oauth2-guide/index.html#rest-api-oauth2-token-admin-endpoint

    #21529
     sahoob
    Participant

    Thanks ,

    We are using openam 13.5.0 the endpoint (/frrest/oauth2/token) depend on amadmin token and it has some defect associated to it.

    So we thought we will directly fetch the details from Dj for the user and use revoke endpoint to revoke the details.

    Do you know any of the class which connect to opendj with basedn of config store from openam?

    regards,
    Biswajit

    #21535
     sahoob
    Participant

    Hi,

    I have got the code to get the read the tokens , but its returning just DNs. Can anyone point out what is the wrong I am doing here?

    Set<String> dns = SMSEntry.search(token, “ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=org”, “(&([email protected])(coreTokenType=OAUTH)(!(coreTokenString10=access_code)))” , 0, 0, false, false);
    This just returning the list of DNs (coreTokenId=c9484576-9de9-44a4-8dd9-e4cbeefe62de,ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=org)

    If I do as follow also its returning DNs

    Iterator dns1 = SMSEntry.search(token, “ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=org”, “(&([email protected])(coreTokenType=OAUTH)(!(coreTokenString10=access_code)))” , 0, 0, false, false, null);

    Result : SearchResultEntry(name=coreTokenId=c9484576-9de9-44a4-8dd9-e4cbeefe62de,ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=org, attributes=[], controls=[])

    If I am running the command on Dj its showing other attributes

    ldapsearch -h localhost-p 1389 -D “cn=Directory Manager” -w password -b “ou=famrecords,ou=openam-session,ou=tokens,dc=openam,dc=org” “(&([email protected])(coreTokenType=OAUTH)(!(coreTokenString10=access_code)))”

    dn: coreTokenId=c9484576-9de9-44a4-8dd9-e4cbeefe62de,ou=famrecords,ou=openam-ses
    sion,ou=tokens,dc=openam,dc=org
    objectClass: top
    objectClass: frCoreToken
    coreTokenType: OAUTH
    coreTokenId: c9484576-9de9-44a4-8dd9-e4cbeefe62de
    coreTokenExpirationDate: 20180426132148.273Z
    coreTokenString10: refresh_token
    coreTokenString12: authorization_code
    coreTokenString01: uid,LifeTimeId,openid
    coreTokenObject: {“expireTime”:[“1524748908273″],”tokenName”:[“refresh_token”],”
    scope”:[“uid”,”LifeTimeId”,”openid”],”grant_type”:[“authorization_code”],”c
    lientID”:[“oauth2clientlong”],”authGrantId”:[“f236baed-aee8-4948-9d0b-ebd8de1f4
    f42″],”authModules”:[“passphrase|LDAP|AccountLockChecktest”],”id”:[“c9
    484576-9de9-44a4-8dd9-e4cbeefe62de”],”tokenType”:[“Bearer”],”auditTrackingId”:[
    “10450f1a-7e53-415b-a6e3-9c8c8edbf03d-186″],”realm”:[“/testPoc”],”redirectURI”:[“h
    ttp://openam.example.com:18080/openid/cb-basic.html”],”userName”:[“Magpie9.Pass
    [email protected]”],”acr”:[]}
    coreTokenString07: Bearer
    coreTokenString08: /testpoc
    coreTokenString09: oauth2clientlong
    coreTokenString15: f236baed-aee8-4948-9d0b-ebd8de1f4f42
    coreTokenString03: [email protected]
    coreTokenString04: http://openam.example.com:18080/openid/cb-basic.html

    Please can anyone help me here.

    Regards,
    Biswajit

    #21536
     handat
    Participant

    Try passing in an empty Set instead of null to the search

    #21599
     sahoob
    Participant

    That doesn’t help, So I have written my own class by extending the SMSLdapObject class and now I am able to get the details.

    Thanks,
    Biswajit

    #26510
     mhamdy
    Participant

    Would you please tell me how you revoked the refresh token when the password changed?

    #26511
     sahoob
    Participant

    You need to capture all the Refresh Token from the DJ for that user and Revoke the to token by call revoke endpoint

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?