hello :wave: We are building POC using <permit.io...
# general
n
hello πŸ‘‹ We are building POC using permit.io for our use case (single tenant, fairly simple resource hierarchy of 3 levels, using permit to manage top level permissions in the webapplication), and so far everything looks good on permissions side - we're primarily looking to use ReBAC. Now I have started testing UI elements, and running into some issues - I've embedded access management element with
&resourceInstanceKey=XYZ
, and have managed to get elements UI loading properly (auth works). However, I can see no users/roles, and iframe FE code doesn't seem to pass the resourceId further. I can provide more diagnostic details, just not sure if this is good channel to do so
o
Hi, @Nikola Tosic, welcome πŸ€—. Sounds like. You're off to a good start. Usually the right channel would be #permit-saas, but as you already started the thread you can continue here
Please share your workspace / project / env And details on your current element setup CC: @Shuvy Ankor, @Alon Boshi
n
thank you @Or Weis
ok it does seem like iframe url was urlencoded by python/flask templating so resourceId did not get passed down. => everything now seems working nicely πŸŽ‰ Looks like I just needed a rubber duck to debug thing on my own while putting the debug data out there. Good to know for any future questions #permit-saas is goto. While I'm at it, are there plans to implement token based auth against embed apis compared to current cookie based auth, as some browsers/settings may block 3rd party cookies?
o
Happy to be of service πŸ¦† Re: auth to avoid 3rd party cookies issues: Yes - https://docs.permit.io/embeddable-uis/element-login/#support-for-private-browsing-mode-eap
πŸ‘€ 1
n
Thanks for the help @Or Weis I've tried this - is there a test/sample app that uses "supportsPrivateBrowser" login method with JWT sent to iframe. I'm having conflicting information that a) elements iframe should be loaded only when login action is completed b) library giving me following error when there is no iframe
Copy code
Element iframe with https://embed.permit.io/workspace-access-management?envId=ABC&darkMode=false&resourceInstanceKey=G1&elementsToken=true not found
indicating there must be iframe already when the login is being loaded. Before trying with token login and used cookie method, I would just create
iframe
using javascript dynamically upon successful login to elements API . Perhaps it's a fairly low complexity question that @Ask Inkeep can answer
a
Thanks for tagging me @Nikola Tosic. I'll look through relevant sources and get back to you shortly.
You're correct that there's a specific order required when using the
supportsPrivateBrowser
option. The iframe must be present in the DOM before calling the login method (1) . Here's the proper sequence for implementing the token-based authentication: 1. First, create the iframe element in your HTML :
Copy code
<iframe  
 title="Permit Element Name"  
 src="https://embed.permit.io/<ELEMENT_NAME>?envId=<SOME_UNIQUE_ID>&darkMode=false&resourceInstanceKey=<RESOURCE_INSTANCE_KEY>&tenantKey=<TENANT_KEY>"  
 width="100%"  
 height="100%"  
 style="border: none;"  
/>
(2) 2. Then call the login method with the
supportsPrivateBrowser
option (1) :
Copy code
permit.elements  
 .login({  
 loginMethod: LoginMethod.frontendOnly,
 userJwt: '<USER_JWT>',
 tenant: '<TENANT_KEY>',
 envId: '<ENV_ID>',
 supportsPrivateBrowser: true
 })
 .then((res) => {
 // Handle successful login
 })
 .catch((err) => {
 // Handle error
 }) ;
The documentation emphasizes that ensuring login runs before the iframe loads is important to prevent issues with private browsing mode (3) . This means the login process should complete before the iframe attempts to authenticate, but the iframe element itself needs to exist in the DOM for the SDK to find it and inject the authentication token. For a working example, check out the example project mentioned in the documentation (1) .
To learn more, see the sources I considered: [[1] Embedding Elements](https://docs.permit.io/embeddable-uis/embedding-elements) [[2] Operation Approval Element](https://docs.permit.io/embeddable-uis/element/operation-approval) [[3] Login Method](https://docs.permit.io/embeddable-uis/element-login)
n
that is still very conflicting, as the browser will try to load the iframe as soon as it's in the DOM, and that is before the login succeeds. I will try and dig through the library to understand what happens under the hood
o
You can render the Iframe / update it’s URL after the login has completed
I think the AI agent is just confused
s
Hi @Nikola Tosic If you are using React, you can load the Iframe only after the login has been successfully completed. I will write you an example of this.
n
so, the library requests url to be set before login is executed here , then tries to send the message to iframe of type
permitToken
as in here - i'm trying to do this, but having endless loader bar, without any console / ajax errors. Trying to post message directly with the token to iframe (from console) doesn't work either. Not using React, plain TS compiled JS
s
Please send me your JS code privately or here, and I will understand and be able to fix it until it works for you.
n
thanks @Shuvy Ankor - i'll post it tomorrow morning, coming from AEST TZ and now away from keyboard