Code Monkey home page Code Monkey logo

Comments (16)

TimHess avatar TimHess commented on August 18, 2024 1

@lukastosic That does make some amount of sense... one of the things the Pivotal library does is handle authentication with Eureka, so it probably shouldn't be surprising that there could be a problem using it and setting username/password.

I've logged a bug to investigate further and see if we could do something other than declare it a known issue, but I don't know when we'll look at it. In the meantime, if anybody does have a need to use both the Pivotal library and the username/password authentication please let us know with a thumbs up or a comment

https://www.pivotaltracker.com/story/show/158848832

from discovery.

cf-gitbot avatar cf-gitbot commented on August 18, 2024

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/149630055

The labels on this github issue will be updated when the story is started.

from discovery.

kkho avatar kkho commented on August 18, 2024

any news about this?

from discovery.

kkho avatar kkho commented on August 18, 2024

For me it seems that the only solution is to not have defaultZone. but just the url. Also the problem is that there are no translation bindings that are the setup. In Spring, its possible to translate properties (i.e. ${vcap:something:something:user}:${something:password}:${serviceurl}/eureka

from discovery.

dtillman avatar dtillman commented on August 18, 2024

Hi kkho,
Currently the Eureka client does not support Basic Auth (username/password) settings in the serviceUrl.
Likewise, Eureka configuration does not support the Spring Property Place holder feature (e.g. ${blah.blah}
.
I have had a couple requests to get both of these things added, so I'll look at doing that in the very near future.

I'll leave issue open to track the work

from discovery.

nbarboutis avatar nbarboutis commented on August 18, 2024

any progress on this.

from discovery.

nbarboutis avatar nbarboutis commented on August 18, 2024

I have a proposed fix for this issue. Let me know if you require any changes.
Thanks.

from discovery.

TimHess avatar TimHess commented on August 18, 2024

Thanks @nbarboutis, this feature is available as of 2.1.0-dev-191!

from discovery.

lukastosic avatar lukastosic commented on August 18, 2024

@TimHess

I'm not sure this is included in latest "dev" release ...

When I try to run "FortuneTellerService" sample (from SteeltoeOSS samples repository) with username password I am getting "unauthorized" response

Then I did the following:

  1. cloned this git repo
  2. switched to dev branch,
  3. open solution in Visual Studio
  4. added existing project to solution (FortuneTellerService)
  5. removed nuget reference
  6. added project reference to this project (Steeltoe.Discovery.ClientCore)

Rebuild, run -> then it was OK.

I used TCPMon to scan requests, and when I used latest dev nuget, there were no Authorization header in request, but when I switched to use "project dependency" then authorization request was there.

from discovery.

TimHess avatar TimHess commented on August 18, 2024

@lukastosic we don't normally keep the samples in lock-step with dev feed releases. You should be able to just update the Pivotal.Discovery.ClientCore reference from 2.1.0-dev-00172 to 2.1.0-dev-194 to use this feature

from discovery.

lukastosic avatar lukastosic commented on August 18, 2024

@TimHess yeah .. that is what I did the first time I saw this thread - changed reference in sample to "latest" dev version ..

tried with 2.1.0-dev-194, but got error that version doesn't exist .. it offered:

c:\Users\lstosic\Source\Repos\Fortune-Teller-Service>dotnet run -f netcoreapp2.1
c:\Users\lstosic\Source\Repos\Fortune-Teller-Service\Fortune-Teller-Service.csproj : error NU1102: Unable to find package Pivotal.Discovery.ClientCore with version (>= 2.1.0-dev-194)
c:\Users\lstosic\Source\Repos\Fortune-Teller-Service\Fortune-Teller-Service.csproj : error NU1102:   - Found 66 version(s) in SteeltoeDev [ Nearest version: 2.1.0-dev-00194 ]
c:\Users\lstosic\Source\Repos\Fortune-Teller-Service\Fortune-Teller-Service.csproj : error NU1102:   - Found 5 version(s) in SteeltoeMaster [ Nearest version: 2.0.0-master-00130 ]
c:\Users\lstosic\Source\Repos\Fortune-Teller-Service\Fortune-Teller-Service.csproj : error NU1102:   - Found 3 version(s) in nuget.org [ Nearest version: 2.0.1 ]
c:\Users\lstosic\Source\Repos\Fortune-Teller-Service\Fortune-Teller-Service.csproj : error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages

The build failed. Please fix the build errors and run again.

so, then changed to 2.1.0-dev-00194 (two zeros in front of the number)

I sterted TCPmon (made proxy to catch request) and got this as a request:

POST /eureka/apps/FORTUNESERVICE HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 1063
Host: 10.4.1.224:5555

{"instance":{"instanceId":"LT07-
.... OTHER POST data about instance ...
}

But when I build with that local "project dependency" (instead of nuget) .. I see this in TCPmon:

POST /eureka/apps/FORTUNESERVICE HTTP/1.1
Authorization: Basic YWRtaW46RERyV21lbGp6ZTBhY3BhZXFOc3A=
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 1063
Host: 10.4.1.224:5555

{"instance":{"instanceId":"LT07-Luka.infodation.local:fortuneService:5000"
... OTHER POST data
}

"non-nuget" generates proper Authorization header

=========================

This is .csproj (when I use nuget package)

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <None Update="testcert.pfx">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

   <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.0" />
    <PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.1.0-dev-00194" />
    <PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="2.1.0-dev-00227" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.1.0" />
  </ItemGroup>
  
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>
  
</Project>

This is nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
    <add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

from discovery.

lukastosic avatar lukastosic commented on August 18, 2024

@TimHess

after trying out different things:

  1. Git clone samples repository (completely new "clean")
  2. Don't run anything ;)
  3. Open Fortune-Teller-Service.csproj file and adjut Pivotal.Discovery.ClientCore version to: 2.1.0-dev-00194
  4. Run app dotnet run -f netcoreapp2.1

This one does not send authentication header

Then I changed Pivotal.Discovery.ClientCore -> Steeltoe.Discovery.ClientCore with version 2.1.0-dev-00192

(Of course because of that also adjust Startup.cs import rename "Pivotal" -> "Steeltoe")

This one DOES send out authentication header

from discovery.

lukastosic avatar lukastosic commented on August 18, 2024

@TimHess

Thanks Tim ... using "just" Steeltoe instead of "Pivotal" libraries is perfectly fine for my case since we will host application in our own environment, so we will not use any Pivotal Cloud services (Cloud foundry) either way ...

from discovery.

nbarboutis avatar nbarboutis commented on August 18, 2024

I can look into this. I already download the sample and verified the issue Luka is having.

Are the Pivotal libraries open source so I can download them and debug what's going on?

Update: Never mind I found the source.

from discovery.

TimHess avatar TimHess commented on August 18, 2024

@nbarboutis thanks!

For anybody following along, the source for Pivotal.Discovery is over here: https://github.com/pivotal-cf/spring-cloud-dotnet-discovery

from discovery.

nbarboutis avatar nbarboutis commented on August 18, 2024

I determined what is causing the issue:

The PivotalEurekaHttpClient class, although inheriting from EurekaHttpClient is overriding GetRequestMessage. The GetRequestMessage method in EurekaHttpClient class is where the serviceUrl is parsed for username and password and the appropriate header is added. By overriding this method PivotalEurekaHttpClient is bypassing this step and therefore not adding the appropriate header.

I will attempt to fix the issue soon. Will keep you posted.

from discovery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.