loic-sharma / BaGet

A lightweight NuGet and symbol server
https://loic-sharma.github.io/BaGet/
MIT License
2.62k stars 680 forks source link

Support for multiple feeds #155

Open DoCode opened 5 years ago

DoCode commented 5 years ago

Like myget. Under different URL's:

/f/buildtools-dev/v3/index.json
/f/core/v3/index.json
LordMike commented 5 years ago

Duplicate of #36 ?

DoCode commented 5 years ago

Nop, I come tomorrow with details for this feature.

LordMike commented 5 years ago

Ah, maybe #36 is mostly about auth on the service..

loic-sharma commented 5 years ago

This is a bit of a hack, but you can run two instances of BaGet side-by-side by setting the PathBase variable. These won't be able to share resources though. Is this acceptable?

LordMike commented 5 years ago

Maybe have a way to work in multi-tenancy in the web host?

It'd be great if feeds could be created from the UI, keys managed centrally -- one key for multiple feeds, etc.

EDIT: Multi tenancy is probably the way to go:

Against multi tenancy:

DoCode commented 5 years ago

I implemented a multi-tenant service, based on the NuGet.Server code base. It's rudimentary but it works for us.

The tenants stored in a simple JSON file: Feed URL, users with passwords and API keys. The API creates dynamically the controllers from the NuGet.Server. See that base classes: IHttpControllerActivator, HttpControllerDescriptor, DefaultHttpControllerSelector

All this works very well and stable. But it based on the old v2 NuGet protocol... ;-)

loic-sharma commented 5 years ago

I'd like to do a prototype of multi tenancy on BaGet before committing to anything. I'm worried that this feature could hurt BaGet's ease-of-use and bring complexity to the code base.

DoCode commented 5 years ago

Yes, that's a different architecture, but when its injected in BaGet, it's irrelevant if a user has one or more feeds/tenants...

greatkeke commented 5 years ago

In spite of the PathBase was set, for example /nuget/core, the static files' href still were the root path /static/css/main.a14e254f.css

loic-sharma commented 5 years ago

It seems to be broken. I'll need to dig deeper into this, I wasn't able to figure this out easily.

greatkeke commented 5 years ago

@loic-sharma Have any news here? May I do something for you to resolve this issue?

WernerMairl commented 5 years ago

i'm working on a prototype for investigations about "multiple feeds"

routing can be enhanced with a few small changes, but i found one issue located here image

the 2 red items are not rendering the tenant into the url "localhost/tenantid/v3/registration" because the call "url.AbsoluteUrl" is not supporting that, the other one using "url.AbsoluteRoutingUrl" are perfectly working=> i have a implementation proposal for that..... but during regression tests i found one issue/question about trailing slash.

currently, "PackageBase" and "RegistrationBase" are delivered WITH trailing slash, the other items (PackagePublish, SymbolPublish etc) are delivered WITHOUT trailing slash.

Is this different behavior intended ? if we change the implementation for the two red items into "AbsoluteRoutingUrl" then we deliver WITHOUT trailing slash, and i'm not sure about the impact....

Werner

loic-sharma commented 5 years ago

@kexxxfeng I haven't had a chance to look deeper into this yet.

@WernerMairl Whether there's a trailing slash shouldn't matter, that behavior is unintentional. What is AbsoluteRoutingUrl? I can't find documentation for that anywhere.

WernerMairl commented 5 years ago

AbsoluteRoutingUrl creates a Url based on the ROUTING information from the (incoming) request.

for my prototype i have added a additional "variable" into the routing template: "http/localhost/{feed}/v3/{controller}" AbsoluteRouteUrl ensures that the value for "{feed}" is resolved at runtime!

a few changes made for routing available for discussion/feedback here:

https://github.com/mssforks/BaGet/tree/feature/tenants

(not ready for PR but showing the changes with the highest impact)