<div dir="ltr">Thanks Tomas for the clarification !<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 24, 2016 at 2:41 PM, Tomas Nozicka <span dir="ltr"><<a href="mailto:tnozicka@redhat.com" target="_blank">tnozicka@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the feedback, Shoubhik.<br>
<br>
Small clarification inline...<br>
<div><div class="h5"><br>
On Fri, 2016-10-21 at 23:18 +0530, Shoubhik Bose wrote:<br>
> Thanks Tomas,<br>
> The overview is detailed and inline with what I was thinking about ,<br>
> and generally implemented.<br>
> Responses inline ----<br>
> On Oct 21, 2016 9:18 PM, "Tomas Nozicka" <<a href="mailto:tnozicka@redhat.com">tnozicka@redhat.com</a>> wrote:<br>
> ><br>
> > Hi Shoubhik,<br>
> ><br>
> > you have a good point that I haven't described OAuth specifics in<br>
> my<br>
> > post, just mentioned it several times. That's mostly because I<br>
> haven't<br>
> > really decided yet on which approach to take and that mail was<br>
> already<br>
> > a long one to try to attack this issue.<br>
> ><br>
> > Continues inline...<br>
> ><br>
> > On Thu, 2016-10-20 at 19:02 +0530, Shoubhik Bose wrote:<br>
> > > Hi Tomas,<br>
> > > Very nice overview!<br>
> > > I had a few thoughts on the auth tokens.<br>
> > > I see it mentioned in a number of sections and wanted to share a<br>
> generalized understanding:<br>
> > > 1. ALM would need to be pre configured with OAuth application id<br>
> + application secret for every external system we integrate with for<br>
> builds. These could be read by alm-core as environment variables and<br>
> passed on to the SPIs when needed. The environment variables can be<br>
> set as Openshift Secrets.<br>
> > > This allows ALM to identify itself when it talks to the external<br>
> build system.<br>
> > Well, in the approach you are correct. Although I don't<br>
> > think "application id + application" is actually a requirement for<br>
> > OAuth. It is just a way how some services provide you with OAuth<br>
> > credentials to get token, but there are other ways. For example<br>
> > OpenShift does not have those. (It has a concept of serviceaccounts<br>
> > which by themselves provide you with a special long-term token to<br>
> use<br>
> > for authentication. But they need a namespace to be created in,<br>
> setup<br>
> > permissions for other namespaces; generally some non-trivial<br>
> > management).<br>
> ><br>
> This sounds good. I agree, the applicationid and application secret<br>
> are very external system specific and different systems have<br>
> different ways of identifying who is accessing the specific external<br>
> system.<br>
> > The way I see it:<br>
> >  - User will enter a URL of OAuth resource (like build environment)<br>
> to<br>
> > UI (e.g. <a href="http://openshift.com" rel="noreferrer" target="_blank">openshift.com</a>)<br>
> >  - He will be redirected to <a href="http://openshift.com" rel="noreferrer" target="_blank">openshift.com</a> and asked for his regular<br>
> > credentials<br>
> >  - Almighty will get back a token that will be stored in<br>
> configuration<br>
> > with the URL<br>
> ><br>
> > The only issue with this approach is that the token might have<br>
> limited<br>
> > lifetime so when running build, Almighty shall detect expiry and<br>
> ask<br>
> > user to refresh token by redirecting him back to <a href="http://openshift.com" rel="noreferrer" target="_blank">openshift.com</a>. But<br>
> we<br>
> > should be prepared to do the same even if it would be long-term<br>
> tokens<br>
> > because they can still expire someday.<br>
> ><br>
> Yes this is the conventional procedure/approach.<br>
> > There also a "backup" and more complicated way that we let user to<br>
> > login by username and password and provider will setup long-term<br>
> > service account on his behalf, but I would rather not go this way;<br>
> at<br>
> > least for now. (It may be needed in case of cross cluster<br>
> deployments<br>
> > but in a limited way.)<br>
> Do you mean that this is not the usual OAuth workflow but that a<br>
> username/password would eventually generate a server token?<br>
<br>
</div></div>Well, not really. It is a regular OAuth, the difference is with how you<br>
setup the OAuth server. Let's be more concrete and use an example with<br>
OpenShift here:<br>
<br>
1. You can login to OpenShift's OAuth by using your regular credentials<br>
(user: developer, password: developer); you will receive short-term<br>
token and can do anything that user can<br>
2. You can create service account with associated (long-term) token<br>
(Alternative to appid+secret, which provide you with such token after<br>
login in) and have some scoped (limited) access (it doesn't have to be<br>
limited; scope can be "full")<br>
3. You can use 1. to create 2. on users behalf and use 2. for ongoing<br>
operations<br>
<br>
Option 3. was the one I was referring to as "backup" and more<br>
complicated solution.<br>
<br>
We'll go with option 1 as our starting point.<br></blockquote><div><br></div><div>Understood, this is basically like a server token available from the OAuth provider's dashboard and can be used directly for making API calls from ALM.<br><br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> ><br>
> > And there will be a default build environment, to the same<br>
> OpenShift<br>
> > instance as Almighty is running on, for which the above mentioned<br>
> > authentication steps will result in "noop". (When user is already<br>
> > logged in Almighty.)<br>
> ><br>
> Sounds good.<br>
> > Yes, environment variables and secrets will be pasted to SPI<br>
> provider<br>
> > using CRUD operations. In case of OSPB this will be mapped to<br>
> OpenShift<br>
> > secrets and env variables for pipelines.<br>
> ><br>
> > > 2. With the help of of ALM UI , the user gives ALM authorization<br>
> to manage builds on the external system. This step gives ALM an OAuth<br>
> access token with which it is able to manage builds on the external<br>
> system on the user's behalf.<br>
> > > This access token allows ALM to do privileged stuff with the<br>
> external system.<br>
> > True.<br>
> ><br>
> > > Expiry :<br>
> > > The expiry of access tokens should be set to fairly large as<br>
> possible because the alm gets to specify the expiry during OAuth<br>
> token generation procedure.<br>
> > I don't think client is the one to choose and we can't influence<br>
> > default values in target platform (OAuth server) like OpenShift<br>
> Online.<br>
> > We can do it for the default build environment which will be pre-<br>
> > configured, but that's about it.<br>
> ><br>
> In some cases the client can ask for expiry times but in any case ,<br>
> as you said there are always default values which could be banked<br>
> upon.<br>
> ><br>
> > > We would need to have ways to notify the user in the UI when the<br>
> token expires, gracefully.<br>
> > Correct.<br>
> ><br>
> ><br>
> > Regards,<br>
> > Tomas<br>
> ><br>
> > ><br>
> > > Let me know if this is what you intended to explain.<br>
> > > Thanks<br>
> > > Shoubhik<br>
> > ><br>
> > > On Oct 13, 2016 8:54 PM, "Tomas Nozicka" <<a href="mailto:tnozicka@redhat.com">tnozicka@redhat.com</a>><br>
> wrote:<br>
> > > > Hi all,<br>
> > > ><br>
> > > > this is a followup on Andy's initial mail[1] about this topic<br>
> and<br>
> > > > presents my view on what the Build Service (and providers)<br>
> should look<br>
> > > > like.<br>
> > > ><br>
> > > > Feel free to challenge any design here as you see fit; we are<br>
> still in<br>
> > > > early stages and figuring it out ourself.<br>
> > > ><br>
> > > > Andy published the generic design in his last email[1] at the<br>
> highest<br>
> > > > abstraction level and that stays the same. [2]<br>
> > > ><br>
> > > > Let's start by defining what Build Service is, because the name<br>
> might<br>
> > > > seem a bit confusing; at least it was for me when we joined<br>
> this<br>
> > > > project. Build Service should provide user with the ability to<br>
> > > > transform repository code (e.g. git branch) into artifacts<br>
> (like docker<br>
> > > > images) and the ability to *deploy* them to target environment<br>
> (e.g.<br>
> > > > OpenShift). Build Service should be able to cover the whole<br>
> CI/*CD*<br>
> > > > story, not just builds.<br>
> > > ><br>
> > > > There is already a similar concept implemented in OpenShift<br>
> called<br>
> > > > *Pipelines* [3]. But, in ALM, we want to be more generic and<br>
> provide<br>
> > > > users with Build Service with plugable providers. That's why we<br>
> are<br>
> > > > creating Build SPI; to abstract the provider specifics away.<br>
> Generally<br>
> > > > speaking regular build (non-pipeline) job looks like a pipeline<br>
> of 0<br>
> > > > stages, which is a valid pipeline.<br>
> > > ><br>
> > > > Although there will be most probably different providers in the<br>
> future,<br>
> > > > we will start by implementing "OpenShift Build Provider" (OSBP)<br>
> that<br>
> > > > will use OpenShift's pipelines.<br>
> > > ><br>
> > > > There are 3 parts connected by Build SPI and Almighty public<br>
> API:<br>
> > > >  - ALM Core - Build Service<br>
> > > >  - OSBP<br>
> > > >  - ALM UI<br>
> > > ><br>
> > > > Good thing is that after we define the interfaces (mainly Build<br>
> SPI)<br>
> > > > those can be worked on in parallel.<br>
> > > ><br>
> > > > = ALM UI =<br>
> > > > There is a lot of work done for visualizing pipelines in<br>
> OpenShift's<br>
> > > > Console. This is OSS and we could try to reuse those blocks.<br>
> They will<br>
> > > > most definitely need modifications because e.g. they read<br>
> status<br>
> > > > directly from OpenShift's API and that will be abstracted away<br>
> by Build<br>
> > > > SPI and ALM API in our case. Also I am not sure how well they<br>
> visualize<br>
> > > > pipelines without any stages. Also I remember Michael<br>
> mentioning<br>
> > > > Console uses Angular v1 and ALM UI v2.<br>
> > > ><br>
> > > > UI will also need to be able to indirectly ask user for<br>
> credentials to<br>
> > > > build and target/prod environment's (more generally to 1-N<br>
> > > > environments) using OAuth2. ALM's core and build providers will<br>
> > > > authenticate only by token produced by this (OAuth) step. And<br>
> the rest<br>
> > > > of those tokens will be given to build provider as secrets for<br>
> > > > authentication to other environments (e.g. in case of cross-<br>
> cluster<br>
> > > > deployments).<br>
> > > ><br>
> > > ><br>
> > > > = ALM Build Service =<br>
> > > > This will be the service in ALM core that will issue calls<br>
> against<br>
> > > > Build SPI provider. How it will be represented, mainly what<br>
> information<br>
> > > > it needs to hold, will be strict superset of provider<br>
> configuration.<br>
> > > ><br>
> > > ><br>
> > > > = Build Providers =<br>
> > > > Build provider will comunicate with Build Service through Build<br>
> SPI<br>
> > > > which abstracts provider specifics away. It will have several<br>
> functions<br>
> > > > like:<br>
> > > >  - CRUD operations<br>
> > > >  - StartBuild<br>
> > > >  - CancelBuild<br>
> > > >  - GetStages<br>
> > > >  - GetLogs<br>
> > > >  - and many more (this will be in Build SPI spec)<br>
> > > > which can all be fit to work with both pipelines and regular<br>
> build jobs<br>
> > > > with the assumption that regular build job is pipeline of 0<br>
> stages.<br>
> > > ><br>
> > > ><br>
> > > > = Full picture =<br>
> > > >  - ALM admin will add providers (register them) to ALM; or it<br>
> will be<br>
> > > > registered the way that ALM SPIs do... I haven looked into it<br>
> yet:(<br>
> > > >  - User will choose to add a Build Service to his project<br>
> choosing<br>
> > > > provider in UI<br>
> > > >  - User will configure OAuth to his build environment [(URL)-<br>
> >(token)]<br>
> > > > and optionally other OAuth resources [(URL, name)->(name,<br>
> token)] which<br>
> > > > will be passed to build provider as secrets that can be used<br>
> e.g. for<br>
> > > > cross-cluster deployments in that build<br>
> > > >    Since this will be done through OAuth, ALM shall never see<br>
> user's<br>
> > > > credentials.<br>
> > > >  - Build Service instance is created in ALM core<br>
> > > >  - Build Service uses provider to create BuildConfig instance<br>
> passing<br>
> > > > it necessary configuration like: token, secrets[(name, token)],<br>
> > > > repository reference, ...<br>
> > > >  - followed by many Build SPI calls...<br>
> > > ><br>
> > > > ALM core shall verify that all OAuth tokens are valid (not<br>
> expired)<br>
> > > > before calling Build SPI and refresh them with cooperation with<br>
> ALM UI<br>
> > > > if needed. (For the main token Build SPI will return<br>
> unathorized, but<br>
> > > > for the OAuth tokens in secrets the underlying technology does<br>
> not<br>
> > > > support that and build will be marked as failed otherwise. This<br>
> might<br>
> > > > be a common scenario since some tokens may last for about a day<br>
> or so.)<br>
> > > ><br>
> > > > Also in case ALM will run on the same OpenShift instance as you<br>
> setup<br>
> > > > for your builds, or there will be a dedicated OpenShift<br>
> instance for<br>
> > > > ALM build set up with ALM as OpenShift's identity provider, you<br>
> can be<br>
> > > > authenticated to your build environment using your ALM token<br>
> without<br>
> > > > the need to be asked for credentials. If allowed, this should<br>
> be the<br>
> > > > default.<br>
> > > ><br>
> > > > = Next steps =<br>
> > > > I will work on putting Build SPI proposal on paper and also on<br>
> how we<br>
> > > > should represent Build Service in core which is connected with<br>
> it. <br>
> > > ><br>
> > > > There is also a userstory for next sprint on GitHub[3].<br>
> > > ><br>
> > > > I will appreciate your feedback!<br>
> > > ><br>
> > > > Regards,<br>
> > > > Tomas<br>
> > > ><br>
> > > > [1] - <a href="https://www.redhat.com/archives/almighty-public/2016-" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>archives/almighty-public/2016-</a><br>
> September/ms<br>
> > > > g00150.html<br>
> > > > [2]<br>
> - <a href="https://drive.google.com/file/d/0B10zSvDl_cuwMHZtTmR1RVIteGM/view" rel="noreferrer" target="_blank">https://drive.google.com/<wbr>file/d/0B10zSvDl_<wbr>cuwMHZtTmR1RVIteGM/view</a><br>
> > > >  (RH Only, but there is a screenshot in attached in [1])<br>
> > > > [3] - <a href="https://github.com/almighty/almighty-core/issues/352" rel="noreferrer" target="_blank">https://github.com/almighty/<wbr>almighty-core/issues/352</a><br>
> > > ><br>
> > > > ______________________________<wbr>_________________<br>
> > > > almighty-public mailing list<br>
> > > > <a href="mailto:almighty-public@redhat.com">almighty-public@redhat.com</a><br>
> > > > <a href="https://www.redhat.com/mailman/listinfo/almighty-public" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/almighty-<wbr>public</a><br>
> > > ><br>
</div></div></blockquote></div><br></div></div></div>