Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Account linking #338

Closed
gigaga opened this issue Jul 10, 2018 · 16 comments
Closed

Documentation: Account linking #338

gigaga opened this issue Jul 10, 2018 · 16 comments
Labels

Comments

@gigaga
Copy link

gigaga commented Jul 10, 2018

Hi,

That will be great if documentation is more complete by describing how configure our local keycloak instance to be able to link our accounts.
While, I added github as broker, currently, I have always a web page with "invalid request" message :(

Thx

@EricWittmann EricWittmann changed the title Account linking Documentation: Account linking Jul 10, 2018
@EricWittmann
Copy link
Member

Yes I think this would be a good candidate for a new article in the documentation. The configuration in Keycloak is relatively complex, and it also requires some configuration in each of the identity providers (GitHub, GitLab, Bitbucket). Perhaps at least an article with links to the appropriate Keycloak documentation.

@EricWittmann
Copy link
Member

Until that article is complete, there is documentation in Keycloak for configuring account linking (social login):

https://www.keycloak.org/docs/latest/server_admin/index.html#social-identity-providers

There may be some quirks to the configuration that are needed to successfully get account linking working.

@gigaga
Copy link
Author

gigaga commented Jul 12, 2018

Thanks a lot!
I'm going to try it!

@gigaga
Copy link
Author

gigaga commented Jul 12, 2018

I tried but it doesn't work.
I validated my configuration because I am able to be authenticated by using github as broker identity on another app.

I added roles indicated in the following documentation to my client apicurio, but no effect :(
https://www.keycloak.org/docs/3.1/server_development/topics/identity-brokering/account-linking.html

From Keycloak page http://<keycloak_host>/auth/realms//account/identity I am able to link my account on Github (it uses "account" client), but Apicurio page (it uses "apicurio" client), it doesn't work

@EricWittmann
Copy link
Member

EricWittmann commented Jul 12, 2018

Here are some screenshots of the configuration I'm using in "studio.apicur.io". Note: for that installation users are able to link their GitHub account but cannot use it to authenticate. But hopefully this information will help:

GitHub Identity Provider

image

Default Realm Roles

image

GitHub Settings (OAuth Apps)

image

@gigaga
Copy link
Author

gigaga commented Jul 12, 2018

Thanks a lot!!!
I will try!

@EricWittmann
Copy link
Member

I've updated the documentation to include information about account linking:

https://apicurio-studio.readme.io/docs/setting-up-keycloak-for-use-with-apicurio

@gigaga
Copy link
Author

gigaga commented Jul 18, 2018

Hi,

Thanks a lot... Linking is done for now. However, I have again an issue. After linking, when I try to publish to Bitbucket, the request "/api-hub/accounts/Bitbucket/teams" returns an error 500 and nothing is displayed in console (stdout).
Maybe it is due to my proxy configuration. I'm going to try without proxy.

Thanks

@EricWittmann
Copy link
Member

Error 500 is definitely bad - when you receive that error does Apicurio show you an error page labeled Server Error Encountered? If so is there a Toggle Details button on the page? And if there is, can you click it and copy/paste the resulting stack trace here?

@EricWittmann
Copy link
Member

Also, if the error does not result in an error page, can you check the browser's developer/javascript console for a reported error?

Looking at the code, I'm guessing you don't get an error page, but you should have some error information in the javascript console. The relevant code is:

// TODO handle an error in some way!
this.gettingTeams = false;
console.error(error);

Skimping on error handling is never a good idea - sorry about this. :(

@gigaga
Copy link
Author

gigaga commented Jul 19, 2018

Hi,

behind a proxy or not, I get the same error:

{"errorType":"ServerError","message":"Unexpected server error","trace":"io.apicurio.hub.core.exceptions.ServerError: Unexpected server error\n\tat io.apicurio.hub.api.rest.impl.AccountsResource.getTeams(AccountsResource.java:314)\n\tat io.apicurio.hub.api.rest.impl.AccountsResource$Proxy$_$$_WeldClientProxy.getTeams(Unknown Source)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)\n\tat org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)\n\tat io.apicurio.hub.api.security.KeycloakAuthenticationFilter.doFilter(KeycloakAuthenticationFilter.java:72)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apicurio.hub.api.filters.DisableCachingFilter.doFilter(DisableCachingFilter.java:66)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apicurio.hub.api.filters.CorsFilter.doFilter(CorsFilter.java:64)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)\n\tat io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)\n\tat io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)\n\tat org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66)\n\tat io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)\n\tat io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)\n\tat io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)\n\tat io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)\n\tat io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)\n\tat io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)\n\tat io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)\n\tat io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)\n\tat io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)\n\tat io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)\n\tat io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)\n\tat io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)\n\tat io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)\n\tat io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: io.apicurio.hub.api.connectors.SourceConnectorException: java.io.IOException: Unexpected response from Keycloak: 403::Forbidden\n\tat io.apicurio.hub.api.connectors.AbstractSourceConnector.getExternalToken(AbstractSourceConnector.java:99)\n\tat io.apicurio.hub.api.bitbucket.BitbucketSourceConnector.addSecurityTo(BitbucketSourceConnector.java:314)\n\tat io.apicurio.hub.api.bitbucket.BitbucketSourceConnector.getTeams(BitbucketSourceConnector.java:196)\n\tat io.apicurio.hub.api.bitbucket.BitbucketSourceConnector$Proxy$_$$_WeldClientProxy.getTeams(Unknown Source)\n\tat io.apicurio.hub.api.rest.impl.AccountsResource.getTeams(AccountsResource.java:312)\n\t... 68 more\nCaused by: java.io.IOException: Unexpected response from Keycloak: 403::Forbidden\n\tat io.apicurio.hub.api.security.KeycloakLinkedAccountsProvider.getLinkedAccountToken(KeycloakLinkedAccountsProvider.java:186)\n\tat io.apicurio.hub.api.security.KeycloakLinkedAccountsProvider$Proxy$_$$_WeldClientProxy.getLinkedAccountToken(Unknown Source)\n\tat io.apicurio.hub.api.connectors.AbstractSourceConnector.getExternalToken(AbstractSourceConnector.java:91)\n\t... 72 more\n"}

@gigaga
Copy link
Author

gigaga commented Jul 19, 2018

Furthermore, from Postman GET on <kc_host>/auth/realms/beyond/broker/Bitbucket/token and from valid token, I get the error "Client [apicurio] not authorized to retrieve tokens from identity provider [Bitbucket]."
I added "read-token" as default role :(

@gigaga
Copy link
Author

gigaga commented Jul 19, 2018

After adding "read-token" role to apicurio client (not as default roles), it's work like a charm :D :D

@gigaga
Copy link
Author

gigaga commented Jul 19, 2018

Again me :)
For now, I able to get my teams but after selecting a team I get just 10 repositories whereas there are 362 repositories in the selected team.
By trying to get these repositories directly from Bitbucket API, I have 362 repositories but on several pages of 10 repositories...

I think, you don't implement retrieving of repositories that are on several pages.
Maybe, using an autocomplete combobox in your UI to select a repository could be great. You could use Bitbucket filter mecanism:
https://bitbucket.org/api/2.0/repositories/<team>?q=name~"name"

@EricWittmann
Copy link
Member

So first of all - nice job figuring out the read-token fix. I'm not sure why you needed to add that to the apicurio client if you added it as a default. I'm also not sure why it wasn't already set up if you imported the realm JSON file. But I'm glad it's working.

As for your other issue (only listing 10 repositories) - that is a bug for sure (just checked the code). I've opened up a separate GH issue for this: #350

@gigaga
Copy link
Author

gigaga commented Jul 19, 2018

Thanks! We can close it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants