supertokens / docs

SuperTokens documentation
40 stars 71 forks source link

Us vs keycloack #24

Open rishabhpoddar opened 3 years ago

rishabhpoddar commented 3 years ago

Questions

rishabhpoddar commented 3 years ago

See the answers for SuperTokens here

Describe the dev setup experience (how many steps and what are they + time overall)

Can you easily add a custom social provider?

Flow for setting up Google and Facebook:

The dashboard has extensive customization options(setting a custom login flow, setting scopes etc..)

How do go about sending emails yourself if you want to?

Keyclaok is not able to send emails by default but requires you to use a smtp mail server.

Flow for setup using zoho mail:

How to implement sign out functionality?

Can sessions be used with httpOnly cookies?

How can we go about customising the UI? From colours to full customisation

How to go about customising the email design and or the sender's domain?

How would adding custom sign up fields work?

How would adding custom sign up validators work?

Changing password validation(or some similar feature) for sign up does this get propagated to other places(Signin, password reset)

Changing the password validation in one flow will not affect another flow. If one wants these changes to propagate to other custom flows we would need to create the custom action(password validation in this case) and use it in place of the default action in all Authentication flows

If someone wants to tweak the sign up / sign in APIs, how can they do that?

How do we do things like handle sign up success?

How to implement revoking a user's session functionality?

What if you want to embed the sign up / in page into your website UI (As opposed to opening a new tab..). Is that possible?

If one needs to do something like paginating across all users in the app in their API, how can they do that?

Keycloak allows for pagination and has an api that you can use to query for paginated user data. It takes to query parameters, first and max. first is the element id and max is the number of elements to return. More info can be found here

Social account consolidation?

For social account consolidation, how does changing the email work.

How does changing the email for social providers work?

Testing social account consolidation:

Will their solution work with serverless env like in nextjs or netlify?

Keycloak has no native support for react and ssr, there is a third party library which uses the javascript client adapter and allows for ssr. Used the third party library, There is almost no documentation, had to set it up using the example provided in the github repo.

How would one go about exposing their keycloak instance to the internet and securing that? Some person had said they required to use some oauth proxy or something which made it complex.. not sure.

You can expose keycloak to the internet and secure it using a reverse proxy. Ive seen people using Apache and NGINX to reverse proxy to keycloak. The tutorial I checked for using NGINX with keycloak had no mention of using an oauth proxy.

Setting up for the two use cases of multi tenancy?

Keycloak supports the first case of multi-tenancy one login with multiple subdomains. Each tenant will be assigned its own realm and during authentication you can decide how to redirect the user. An example of a keycloak multi tenant app can be found here. I havent seen implementations of the second case of having one login per subdomain. There are some issues with this above method as if your single keycloak instance has more than 100 realms then it starts having instability issues(taking more time to respond to requests) and having more than 400 realms can cause keycloak to become unresponsive and crash.

sharing session across sub domains

Test sharing across subdomains:

What are the supported databases?

Documentation review

Email verification with Social providers, how does it work

Revoke session between your frontend and backend, how does it work

logout function on the front-end will invalidate the refresh session token for authentication with the back end. On the backend the admin library can be used to revoke sessions

User has multiple sessions, only want to revoke a couple of them, how does that work

How does load balancing work in keycloak with multiple instances

if you want to add a password strength meter to registration, how does it work

I haven't seen any implementation of changing GUI in the login screen, the only things I've seen people do is write hooks that would display a custom message when input was given to a form field.

How does Keycloak Database sharding work?

They do not mention database sharding in their docs. I found one person online asking about database sharding in keycloak but there were no answers.

User pagination use API, what is the output, if user is using social login, what is the output, what is the user object returned.

social login user {"id":"b49669d0-b88e-40c7-a546-241edf83b0ff","createdTimestamp":1615291348730,"username":"johnDoe@gmail.com","enabled":true,"totp":false,"emailVerified":true,"firstName":"john","lastName":"Doe","email":"johndoe@gmail.com","disableableCredentialTypes":[],"requiredActions":[],"notBefore":0,"access":{"manageGroupMembership":true,"view":true,"mapRoles":true,"impersonate":true,"manage":true}} email password user {"id":"7b772aff-b118-417f-a8f5-448f2689f2a1","createdTimestamp":1615208135285,"username":"johnDoe","enabled":true,"totp":false,"emailVerified":true,"firstName":"John","lastName":"Doe","email":"johnDoe@gmail.com","disableableCredentialTypes":[],"requiredActions":[],"notBefore":0,"access":{"manageGroupMembership":true,"view":true,"mapRoles":true,"impersonate":true,"manage":true}}

If a session expires is there a pop-up? does the user have to handle it?

There is no session expires pop up when the frontend access token expires the frontend has to refresh the session.

RBAC, check properly, how to get the role of the user within the API for custom logic for both frontend and backend.

Frontend

Backend

What are the differences between keycloak realm roles and client roles?

Keycloaks roles can be created as a realm role which is the global namespace and client roles that are specific to the application.

implementation with ssr

Using the @react-keycloak/ssr to setup a nextjs app with keycloak. I Flow Click on the login button, redirects you the keycloak login page enter account credentials On redirection the ssr library will set the access token cookies in the browser Refresh tokens seem to automatically refreshed kcToken decoded payload:

{ "exp": 1617188790, "iat": 1617188490, "auth_time": 1617187986, "jti": "fedd20ef-ce34-43bc-bea2-e3ab005e149a", "iss": "http://localhost:8080/auth/realms/Keycloak-Demo", "aud": "account", "sub": "f78d9978-8f96-40f3-9e48-57e481ca64ae", "typ": "Bearer", "azp": "nextjs-frontend", "nonce": "ffadcd8a-27bd-4ba2-8d62-14eea49981de", "session_state": "eabd12a8-7529-4a66-b908-4eaddae71658", "acr": "0", "allowed-origins": [ "*" ], "realm_access": { "roles": [ "offline_access", "admin", "uma_authorization", "user" ] }, "resource_access": { "account": { "roles": [ "manage-account", "manage-account-links", "view-profile" ] } }, "scope": "openid profile email", "email_verified": false, "name": "johndoe", "preferred_username": "johndoe@gmail.com", "given_name": "john", "family_name": "Doe", "email": "johnDoe@gmail.com" }

kcIdToken decoded payload: { "exp": 1617188790, "iat": 1617188490, "auth_time": 1617187986, "jti": "42e254cc-f7ea-4572-87d3-20b11f42c2c7", "iss": "http://localhost:8080/auth/realms/Keycloak-Demo", "aud": "nextjs-frontend", "sub": "f78d9978-8f96-40f3-9e48-57e481ca64ae", "typ": "ID", "azp": "nextjs-frontend", "nonce": "ffadcd8a-27bd-4ba2-8d62-14eea49981de", "session_state": "eabd12a8-7529-4a66-b908-4eaddae71658", "at_hash": "uxVNHLsPyX-8Zem6_s7OAg", "acr": "0", "email_verified": false, "name": "johnDoe", "preferred_username": "johnDoe@gmail.com", "given_name": "john", "family_name": "Doe", "email": "johnDoe@gmail.com" }

How to set roles for a user on the backend and how to set multiple roles for a user.

Is there a mechanism for protecting routes (similar to the supertokens auth wrapper). How easy is it to protect multiple pages and what does the code look like?

Keycloak mobile implementation, IOS and Android

email verification not switched on, the user signs up and in and doesn't have to verify, later on, verification is turned on later, on signing in now is the user prompted to verify the email?

Yes, the user is prompter to verify the email. One possible issue is that now if email verification is turned off then the user is still prompted to verify his email every time he tries to log in. This is because as soon email verification was turned on, "verify email" was assigned to the user as a "required action" (ex. Update Profile, Terms and Conditions, Configure OTP, etc...), When email verification was turned off "verify email" "required action" was not removed from the user.

Email is not verified but password reset is done, does that verify email?

When email verification is turned off resetting your password does not verify the email. When email verification is turned on and you click on the password reset link, it redirects you to the email verification screen. On clicking the email verification link you continue with the password reset flow and are able to reset your password.

Community (mainly for nextjs)

Keyclokas main focus seems to be centered around java enterprise applications. Most of the documentation is focused on configuring keycloak and support for java ee apps. The official document support for other language adapters is limited and for certain tech stacks, you have to rely on community integration, like the ssr keycloak library. The problem that I encountered is that there is not a large enough community using keycloak as an auth solution for their nextjs app so finding support for some of the questions I had was almost impossible due to limited questions from being asked on forums, a nonengaging Reddit community and there no discord communities which specifically discuss keycloak ssr.

How well do they support various platforms and SDKs?

Good support( Complete Documentation, examples, active community) Java: JBoss EAP, WildFly, Fuse, Tomcat, Jetty 9, Servlet Filter, Spring Boot, Spring Security JavaScript (client-side): JavaScript Node.js (server-side): node adapter

No keycloak sdks(used as a generic OIDC provider) C#: OWIN (community) Python: oidc (generic) Android: AppAuth (generic) iOS: AppAuth (generic) Apache HTTP Server: mod_auth_openidc

The documentation for the node management API's was very lacking.

What are features that they provide that we don't?

Dashboard for managing your app

Keycloaks dashboard is extensive, allowing customization for most of the aspects of the app Users can be created, roles and user groups can be created and assigned, Social Providers can be added

Role-based access control.

Required actions: ability to assign actions like Update Profile, Terms and Conditions, Configure OTP, etc to users whenever they log in.

More supported Social Providers.

2-factor auth

User Federation

Support for LDAP and Active Directory

How does keycloak allow users to use pre-populated databases with userinfo.(callbacks for api's, transactions?)

How to disallow sign up and only have sign in?

The Dashboard provides an option to disable sign ups.

Does it provide Email OTP as a feature?

There is no Email OTP feature, OTP in keycloak uses password generators like google authenticator and is used for 2fa with something like a mobile device

Can a user be re-authenticated when visiting a protected route?

This doesn't seem to be a feature keycloak offers in its sdk and it seems to be up to the user to implement. Their docs mention the setting a param in the initial auth request to always show the login page even if the user is authenticated, but they also say that this currently doesnt work,

What is Keycloak Gatekeeper?

They seemed to have removed all docs about Gatekeeper. Originally as mentioned in this forum post the docs described Keycloak Gatekeeper to be the go lang adapter but it is actually an authentication proxy to be used when your app/lib doesn’t support grant code flow, but it is able to read user identity from request headers. This was a community project which seems to be deprecated

Changing Email for social provider, how it works

Keycloak doesn't provide a flow for changing emails. They do provide an endpoint for updating emails in their management API. The users in this forum post mention issues implementing an email update flow

Can you make the provider's frontend talk to your API instead of theirs? And then your APIs talk to their API.

Keycloak allows you to completely customize the login widget and auth flows so it should be possible to make this change, I haven't seen anyone in the community ask for this feature though or implement it.

jscyo commented 1 year ago

User reported issues with Keycloak: