JanssenProject / jans

An open source enterprise digital identity platform for CIAM or workforce... Janssen is a distribution of standards-based, developer friendly, components that are engineered to work together in any cloud. #OAuth #OpenID #FIDO
https://docs.jans.io
Apache License 2.0
453 stars 73 forks source link

Not able to see enabled auth script in Authn. #6440

Open MohitMaliFtechiz opened 10 months ago

MohitMaliFtechiz commented 10 months ago

Describe the bug Not able to see enabled auth script in Authn

To Reproduce Steps to reproduce the behavior:

1.install jans 1.0.20.nightly 2.enable any script on jans -tui

  1. go to authn and check enabled scripts

Expected behavior all enabled script should be available on authn

Screenshots Screenshot (16)

if we check in jans-tarp enabled script is available

Screenshot (17)

Desktop (please complete the following information):

devrimyatar commented 10 months ago

@pujavs This shouldn't be TUI issue. May be admin-ui queries all scripts and filter internally. I enabled DUO script on both LDAP and PostgreSQL backends. When I executed this query:

 python3 /opt/jans/jans-cli/cli/config_cli.py --operation-id=get-config-scripts --endpoint-args='fieldValuePair:scriptType=person_authentication,fieldValuePair:enabled=true'

OpenDJ backend response is good as expected:

q-ldap

But PostgreSQL backends reponses error:

{
  "cause2": "Failed to build search entries query. Key: 'scripts', expression: '(lower(doc.description) like %% || lower(doc.displayName) like %%) && doc.jansEnabled = true && doc.jansScrTyp = person_authentication'",
  "cause1": "io.jans.orm.exception.EntryPersistenceException: Failed to find entries with key: 'scripts'",
  "servlet": "io.jans.configapi.rest.ApiApplication",
  "cause4": "org.postgresql.util.PSQLException: ERROR: operator does not exist: boolean = character varying\n  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.\n  Position: 448",
  "cause3": "com.querydsl.core.QueryException: Caught PSQLException for select "doc"."jansConfProperty", "doc"."displayName", "doc"."jansRevision", "doc"."description", "doc"."jansScrTyp", "doc"."jansModuleProperty", "doc"."inum", "doc"."jansAlias", "doc"."jansProgLng", "doc"."jansScrError", "doc"."jansScr", "doc"."jansEnabled", "doc"."jansLevel", "doc"."dn", "doc"."doc_id"\nfrom "public"."jansCustomScr" "doc"\nwhere (lower("doc"."description") like ? or lower("doc"."displayName") like ?) and ("doc"."jansEnabled" = ? and "doc"."jansScrTyp" = ?)\norder by "inum" asc, "jansLevel" asc\nlimit ?\noffset ?",
  "cause0": "org.jboss.resteasy.spi.UnhandledException: io.jans.orm.exception.EntryPersistenceException: Failed to find entries with key: 'scripts'",
  "message": "org.jboss.resteasy.spi.UnhandledException: io.jans.orm.exception.EntryPersistenceException: Failed to find entries with key: 'scripts'",
  "url": "/jans-config-api/api/v1/config/scripts",
  "status": "500"
}

See the error in config-api jetty log:

2023_11_04.jetty.log

pujavs commented 10 months ago

Seems orm issue, have requested @yurem for guidance

yurem commented 10 months ago

In the log there are 2 SQL Exception parts: com.querydsl.core.QueryException: Caught PSQLException for select "doc"."jansConfProperty", "doc"."displayName", "doc"."jansRevision", "doc"."description", "doc"."jansScrTyp", "doc"."jansModuleProperty", "doc"."inum", "doc"."jansAlias", "doc"."jansProgLng", "doc"."jansScrError", "doc"."jansScr", "doc"."jansEnabled", "doc"."jansLevel", "doc"."dn", "doc"."doc_id"|from "public"."jansCustomScr" "doc"|where (lower("doc"."description") like ? or lower("doc"."displayName") like ?) and ("doc"."jansEnabled" = ? and "doc"."jansScrTyp" = ?)|order by "inum" asc, "jansLevel" asc|limit ?|offset ?

and

org.postgresql.util.PSQLException: ERROR: operator does not exist: boolean = character varying| Hint: No operator matches the given name and argument types. You might need to add explicit type casts.| Position: 448

According to the second one we compare boolean value with character varying. I think the issue in this filter part "doc"."jansEnabled" = ?.

Do you set boolean value or string in this filter part? Can you dump value/value_class_type of each parameter which you put into filter?

pujavs commented 10 months ago

@yurem, the field and value provided are query parameter and hence passed as string. 2023-11-07 14:52:18,142 TRACE [qtp366004251-17] [io.jans.service.custom.CustomScriptService] (CustomScriptService.java:113) - CustomScript entry.getKey():jansEnabled, entry.getValue():true, entry.getValue().getClass():class java.lang.String`

Please find attached logs for both LDAP and PLSQL.

yurem commented 10 months ago

I added strings "true" and "1" to boolean "true" conversion if column type is boolean