-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Improve provider name handling #213
base: master
Are you sure you want to change the base?
Conversation
golangci-lint fixes are in #214 |
Pull Request Test Coverage Report for Build 12588015969Details
💛 - Coveralls |
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.
LGTM, I guess it shouldn't break anything.
I would suggest creating separate small PR with all changes not related to name handing improvement, e.g. README.md, provider/apple_pubkeys.go, provider/apple_test.go, provider/telegram_test.go.
Add provider name into JWT token claims to allow provider names with multiple underscore "_" symbols. Forbid provider names containing URL reserved symbols.
5a80324
to
3157345
Compare
Rebased on top of master, without altering anything. @umputun could you please take a look? |
|
||
path, err := url.PathUnescape(name) | ||
if err != nil || path != name { | ||
formatForbidden(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.
small thing: in debug mode, this function's redirect for logging will lose the source line information. I'd suggest creating an error message instead and logging it directly.
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.
thx, lgtm. just a minor suggestion
The problem occurs when the provider name contains underscore characters
_
.If provider name is like
provider_prod
and fullclaims.User.ID
in the JWT token looks likeprovider_prod_user1
,then Authenticator.isProviderAllowed() check fails and provider with such name cannot be used.
This was initially discovered in #201 (comment).
It might be better to add an explicit provider name into the JWT token claims,
and avoid parsing already serialized string back to tokens.
Provider name passed into
Service.AddProvider()
also becomes a part ofhttps://host:port/auth/provider_prod/login
URL, and therefore it requires special handling.One solution is to url-encode it, but then it will be still possible to use names containing spaces or special characters (by accident or with purpose).
Another solution is to forbid all provider names which require url-encoding.
It might be better to forbid empty names as well.
_
underscore has been mentioned in the README examples for some time now, i am not sure about it.But those names may be even more strict and contain only ASCII alphanumeric symbols.
What do you think?
It is not possible to return errors from
Service.AddProvider()
, therefore invalid providers are just ignored andERROR
level message is logged.