-
Notifications
You must be signed in to change notification settings - Fork 195
Feature/support dynamic registration management rfc7591 rfc7592 #1 #782
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
…ent-rfc7591-rfc7592
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
Signed-off-by: mqf20 <[email protected]>
…-management-rfc7591-rfc7592 Feature/support dynamic registration management rfc7591 rfc7592
| // Accept: application/json | ||
| // Host: server.example.com | ||
| // Authorization: Bearer this.is.an.access.token.value.ffx83 | ||
| func getBearerToken(r *http.Request) (string, error) { |
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.
this would accept Authorization: Bearerfoobar 1111
suggestion:
func getBearerToken(r *http.Request) (string, error) {
authHeader := r.Header.Get("authorization")
if len(authHeader) == 0 {
return "", errMissingAuthorizationHeader
}
tokenSlice := strings.Split(authHeader[0], " ")
if tokenSlice[0] != "Bearer" {
return "", errors.New("unsupported auth method")
} else if len(tokenSlice) != 2 {
return "", errInvalidHeader
}
return tokenSlice[1], nil
}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.
this would accept Authorization: Bearerfoobar 1111
getBearerToken checks against oidc.PrefixBearer:
if !strings.HasPrefix(auth, oidc.PrefixBearer) {
http.Error(w, "invalid header", http.StatusUnauthorized)
return false, ""
}In other words,
# not accepted
Authorization: Bearerfoobar 1111
# accepted (returns `foobar 1111`)
Authorization: Bearer foobar 1111
getBearerToken is modelled after checkToken:
func checkToken(w http.ResponseWriter, r *http.Request) (bool, string) {
auth := r.Header.Get("authorization")
if auth == "" {
http.Error(w, "auth header missing", http.StatusUnauthorized)
return false, ""
}
if !strings.HasPrefix(auth, oidc.PrefixBearer) {
http.Error(w, "invalid header", http.StatusUnauthorized)
return false, ""
}
return true, strings.TrimPrefix(auth, oidc.PrefixBearer)
}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.
My bad wasn't explicit enough; i was more meaning about error checking like differenciating between protocols. Bearer Basic and so on.
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.
Thanks for clarifying, I didn't read about Dynamic Client Registration supporting basic auth, is this something we have to support?
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.
No but for example okta uses SSWS, depends if we want to make it generic or not.
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.
@zekth I'm fine if you would like to add to this PR, or submit a follow-up PR
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 a reviewer like to weigh in on this? @elinashoko
|
Heya @mqf20 thanks for your contribution - we'll review this as soon as we can, currently working through a lot of contributions. |
lukaslihotzki-f
left a comment
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.
This approach looks good. I especially like the modeling of the JSON schema as Go types (for example, InternationalizedField).
| // AuthorizeClientRegistration will check if a Client Registration Request ([RFC7591]) is authorized by parsing | ||
| // either: | ||
| // | ||
| // - an initial access token (OAuth 2.0 access token optionally issued by an authorization server to a developer | ||
| // or client and used to authorize calls to the client registration endpoint.), or | ||
| // - a software statement (A digitally signed or MACed JSON Web Token (JWT) [RFC7519] that asserts metadata | ||
| // values about the client software.) | ||
| // | ||
| // If the initial access token is invalid, return an ErrInvalidInitialAccessToken. | ||
| // | ||
| // If the software statement is invalid, return an ErrInvalidSoftwareStatement. | ||
| // | ||
| // If the software statement presented is not approved for use by this authorization server, return an | ||
| // ErrUnapprovedSoftwareStatement. | ||
| // | ||
| // [RFC7591]: https://www.rfc-editor.org/rfc/rfc7591 | ||
| // [RFC7519]: https://www.rfc-editor.org/rfc/rfc7519 |
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.
To support open registration and facilitate wider interoperability,
the client registration endpoint SHOULD allow registration requests
with no authorization (which is to say, with no initial access token
in the request). These requests MAY be rate-limited or otherwise
limited to prevent a denial-of-service attack on the client
registration endpoint.
This comment contradicts RFC 7591 (section 3.) by implying Protected Dynamic Client Registration. Implementing Open Dynamic Client Registration should be possible by always returning nil.
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.
@lukaslihotzki-f I'm not sure I follow your point - would you like to suggest a fix?
|
This PR only adds the routes in op.go, but not in http_server.go. I don't know why there are two routers with separate handler functions, but Zitadel seems to use http_server.go. Otherwise, when configuring a registration endpoint, Zitadel only returns 404 on the advertised registration endpoint. I used this commit to add the route to http_server.go, which works: famedly@a38fab7 This commit implements the new interface in Zitadel: famedly/zitadel@c747723 Is there a way to use the existing interface (ClientsStorage) in Zitadel? Otherwise, all routes should also be added to http_server.go. |
|
Please take note of #785 |
@muhlemmer any chance this PR can be looked at in an upcoming sprint? |
Co-authored-by: lukaslihotzki-f <[email protected]>
@lukaslihotzki-f do you mean all routes should be added to Also, will you be submitting a PR for your fix? |
Resolves #763
Definition of Ready