Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleRouter: support paths in BASE #405
base: master
Are you sure you want to change the base?
ModuleRouter: support paths in BASE #405
Changes from 3 commits
3ce3a64
b253b30
fc9374c
8cb44d6
b4b8df8
0c8ab4f
416d501
740ba28
f975308
f166869
e25c9e0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.path.join
will not work on certain platforms (see Windows..).To join URLs with paths using a function, use
urllib.parse.urljoin
; but it also has caveats (paths that begin with/
will be considered the root, and bases that do not end with a/
will be considered a file and will be truncated).The simplest approach is to just concatenate with a
/
(ie,f"{self.base_url}/{self.name}"
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always forget about Windows, good catch, thanks.
The biggest advantage of
os.path.join
that it handles double slashes and empty strings intelligently. I'm thinking about adding apath_join
function toutil.py
which would save the work of working around the emptybase_path
with"/".join([foo, bar])
all the time. (And I didn't want to add Python >=3.9 dependency withstr.removesuffix()
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably name the function
join_url_paths
(verb first).Note that the latest pysaml2 already requires Python 3.9 and SATOSA will be updated to require it too. IdentityPython projects try to be compatible with the python that ships on the latest Debian stable release (which is now Python 3.9).
So, requiring Python 3.9 is fine; but no newer atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated patch contains a
join_paths
implementation, which tries to handle separators a little bit more intelligently than a simple concatenation. I've replaced all erroneousos.path.join
calls tojoin_paths
, but didn't replace{}/{}.format(foo, bar)
all over the code, since this appears way too many times.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issuer is discovered through a WebFinger request for resources of
http://openid.net/specs/connect/1.0/issuer
relation. The response contains one or morehref
properties with the Issuer URL, which is allowed to contain a path.What we define is that the frontend contains the frontend name as a path component and under that you can query the well-known documents.
With that in mind we can have multiple frontends each with its own discovery.
The problem is that atm, the
base_url
is used instead ofendpoint_baseurl
.We can introduce a configuration option to select between the two behaviours, or (even better) introduce a configuration to set the discovery URL for a frontend.
At some point I would like to invert this logic; instead of a component defining paths of URLs internally that mapped to functionality (which the routing module has to match to based on some rules), there should be URLs as entrypoints mapped to functionality directly (as it happens within most web frameworks - flask, django, fastapi, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you agree to add a
use_module_name_in_issuer
option (default False for backward compatibility, but the examples changed to True)?A more subtle change but also harder to document alternative would be to make the assignment in
SATOSA/src/satosa/frontends/openid_connect.py
Line 66 in fc9374c
provider
dict.Is any of the two OK with you, or am I misunderstanding the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, both are ok with me. As long as we provide a way to configure things to work as before, it is fine to introduce such changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated patchset contains a commit, which does not perform the above assignment if the provider config has the issuer set. I did some research in git log, but I think it was just in this way forever.
I added a brief explanation to the example configuration, too.
Note that this could be a breaking change for those, who had a lurking "issuer" in their provider config, but since it's never been supported, I'm inclined to go this way rather than adding a new "fix-something-but-dont-break-old-config" type of configuration option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not equivalents. The equivalent form would be
jwks_uri = ("^{}$".format(join_paths("/", self.endpoint_basepath, "jwks")), self.jwks)
Or is it what you are suggesting that the leading '/' should not be present when endpoint_basepath is the empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I didn't think that
self.endpoint_basepath
would be empty.Previously,
self.name
was used and was always filled; in general, we do not match routes that start with/
.So, I still think this is fine, but let me know if I'm skipping over anything.