Code Monkey home page Code Monkey logo

Comments (7)

zikes avatar zikes commented on May 22, 2024

I've got a headers issuer started at https://github.com/zikes/oathkeeper/tree/issuer-header/proxy with a passing test, however I still need to implement incoming header scrubbing and fill in more complex test cases. Let me know if you feel like that's on the right track.

from oathkeeper.

aeneasr avatar aeneasr commented on May 22, 2024

That's a pretty cool idea! I think you can build and cache templates so it shouldn't be too straining on performance. I think the Go template syntax needs getting used to but it's a pretty good place for it. I'd love to see a PR!

from oathkeeper.

zikes avatar zikes commented on May 22, 2024

@arekkas Some good news and bad news about the Go templating: the good news is that it turns out you can access maps via e.g. {{ .Extra.iss }} or {{ .Extra.aud }}. If the key doesn't exist in the map, it will fill in the zero value for the map value's type. The bad news is that the zero value for interface{} is considered unprintable by the text/template package, and it will always print <no value> in such cases even if missingkey=zero is set for the template.

Currently my fix for this is to use a lookup FuncMap function, turning the syntax into {{ lookup .Extra \"iss\" }}, which looks even worse than the original {{ .Extra[\"iss\"] }} in my opinion 😬

Would it be possible to change the Extra field of AuthenticationSession to a map[string]string? Alternatively I can pretty easily convert the map to a map[string]string within the Issuer with fmt.Sprintf, but I don't know what you have planned for that Extra field so I don't know how it would behave down the road.

from oathkeeper.

zikes avatar zikes commented on May 22, 2024

I went ahead and implemented the map conversion method, in favor of having a better interface to present to the users. If Extra is going to potentially contain more complex data we can figure out a better solution. You can have a look at the current implementation at https://github.com/zikes/oathkeeper/tree/issuer-header/proxy

from oathkeeper.

aeneasr avatar aeneasr commented on May 22, 2024

Extra can have arbitrary data, for OAuth 2.0 Access Tokens it's - for example - the metadata associated with the access token. Depending on the server this can be float64, int, string, bool or a nested structure. It should therefore not be map[string]string

from oathkeeper.

aeneasr avatar aeneasr commented on May 22, 2024

How about .String(key), .Int(key) ...?

from oathkeeper.

zikes avatar zikes commented on May 22, 2024

I think I've worked out a FuncMap function that keeps it fairly clean and simple: https://play.golang.org/p/SyzsYJnaepW

I was mostly worried about having to create a complex key lookup system that mimics what text/template does for nesting maps, but with this function I can fall back on text/template for the lookup and override how it prints that value. Oathkeeper can specify that the print FuncMap function is the "safe" way to access keys and should be used for all values.

from oathkeeper.

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.