Can I use Hub to authenticate my own app
I have an app that work in tandem with YouTrack. They all use LDAP auth. Currently, I need to login to both YouTrack and my app independently to get tokens. Could I leverage the token from Hub (for YouTrack) in my own app?
Please sign in to leave a comment.
Yes, you can. Hub implements OAuth 2.0. See https://www.jetbrains.com/hub/help/1.0/OAuth-2.0-Authorization.html. Samples there are in Java but it is just an implementation of OAuth 2.0 standard. After authorization you can use https://www.jetbrains.com/hub/help/1.0/HUB-REST-API_Users_Get-Me.html to get information about logged in user.
I've started to play with this a bit...
I wanted to create a new Service for my app - let's call it ChatService.
When I create a new service in the hub admin ui, I can specify the root url and get an ID & Secret for OAuth 2.0 but cannot assign resources/permissions/roles to it.
Ultimately, I'd like to use this hub to configure roles for LDAP authenticated users of my ChatService app as well as YouTrack; is this possible?
You are supposed to create/update these fields of a service programmatically. You can set up resources/permissions/roles for the service using https://www.jetbrains.com/hub/help/1.0/HUB-REST-API_Services_Update-Existing-Service.html
Ok - that makes sense.
What's the rest api endpoint for logging in to get a cookie as Admin?
Actually it is not cookie based. To call REST methods you have to pass Authorization header with word 'Bearer' and OAuth 2.0 access token, just as required by OAuth 2.0.
To call REST methods on behalf of trusted service you can use client credentials flow https://www.jetbrains.com/hub/help/1.0/Client-Credentials.html
Ok - I've started trying to connect via OAuth 2 but I'm having issues with CORS.
In my flow, I'd like to auth from my server, I'm sending a redirect from my server with the proper CORS headers to the Hub OAuth 2 endpoint. Hub is trying to redirect me to a login page but it's getting blocked because my CORS headers are removed from the Hub redirect.
Is there somewhere I can specify CORS headers in Hub config?