Add option to configure an external OAuth server#18969
Add option to configure an external OAuth server#18969openshift-merge-robot merged 2 commits intoopenshift:masterfrom
Conversation
|
/unassign |
|
@enj PTAL |
pkg/cmd/server/origin/master.go
Outdated
| }, | ||
| ExtraConfig: NonAPIExtraConfig{ | ||
| EnableOAuth: c.Options.OAuthConfig != nil, | ||
| EnableOAuth: c.Options.OAuthConfig != nil || c.Options.ExternalOAuthConfig != nil, |
| @@ -60,7 +61,7 @@ func (c completedOpenshiftNonAPIConfig) New(delegationTarget genericapiserver.De | |||
| // TODO move this up to the spot where we wire the oauth endpoint | |||
| // Set up OAuth metadata only if we are configured to use OAuth | |||
| if c.ExtraConfig.EnableOAuth { | |||
There was a problem hiding this comment.
Instead have this also check the length of the metadata file
There was a problem hiding this comment.
Why is this better ?
Validation already checks the lenght of the metadata file you can't run if it is 0
| var err error | ||
| oAuthMetadata, err = oauthutil.DecodeOAuthMetadataFile(ExtraConfig.OAuthMetadataFile) | ||
| if err != nil { | ||
| glog.Error(err) |
There was a problem hiding this comment.
The message is already provided by DecodeOAuthMetadataFile() I do not see why we need to re-wrap it, there is nothing to add really.
| } | ||
|
|
||
| mux.UnlistedHandleFunc(path, func(w http.ResponseWriter, req *http.Request) { | ||
| mux.UnlistedHandleFunc(oauthMetadataEndpoint, func(w http.ResponseWriter, req *http.Request) { |
There was a problem hiding this comment.
Not sure why you removed the path.
There was a problem hiding this comment.
Just moved things around
pkg/oauth/util/discovery.go
Outdated
| return oAuthMetadata, fmt.Errorf("Unable to decode External OAuth Metadata file: %v", err) | ||
| } | ||
|
|
||
| return oAuthMetadata, nil |
There was a problem hiding this comment.
This needs validation on the actual fields
|
|
||
| if len(ExtraConfig.OAuthMetadataFile) > 0 { | ||
| var err error | ||
| oAuthMetadata, err = oauthutil.DecodeOAuthMetadataFile(ExtraConfig.OAuthMetadataFile) |
There was a problem hiding this comment.
I am wondering if it makes more sense to literally return the file data the user provided after it has passed validation. Then they could include extra fields that osin does not support.
There was a problem hiding this comment.
Uhmm, that may be a good point.
There was a problem hiding this comment.
Thinking more about this, I do not see how you can put more data without failing to unmarshal the json for verification. So I'll just add fields validation now.
There was a problem hiding this comment.
That is not how unmarshalling works. Unknown fields are always ignored. Otherwise you could never add a new field to any serialized object.
cd0189c to
88f4c48
Compare
|
/retest |
fd512ee to
495bc22
Compare
|
Integration test is broken, uploaded so @enj can take a look as the suggestion to use two clusters in one test was his |
|
@enj finally the fully mocked integration test seem to be working, PTAL |
|
/retest |
2 similar comments
|
/retest |
|
/retest |
|
@deads2k we discussed about always using a file for oauth metadata, however I think the new PrepOauthMetadata() function I added is a reasonable compromise for 3.10, PTAL |
pkg/cmd/server/apis/config/types.go
Outdated
| // MetadataFile is a path to a file containing the discovery endpoint for OAuth 2.0 Authorization Server Metadata | ||
| // for an External OAuth server. | ||
| // See IETF Draft: // https://tools.ietf.org/html/draft-ietf-oauth-discovery-04#section-2 | ||
| MetadataFile string |
pkg/cmd/server/apis/config/types.go
Outdated
| Error string | ||
| } | ||
|
|
||
| type ExternalOAuthConfig struct { |
There was a problem hiding this comment.
@liggitt you ready to start an AuthenticationConfig or shall we wait until we split configs and just a little more ugly here? I don't feel strongly.
There was a problem hiding this comment.
Do you want me to move this under MasterAuthConfig like for the WebToken stuff ?
Wasn't sure this was appropriate.
There was a problem hiding this comment.
I can have a simple ExternalOAuthMetadataFile string in there and avoid a new structure
| // OAuthMetadataFile is a path to a file containing the discovery endpoint for OAuth 2.0 Authorization | ||
| // Server Metadata for an external OAuth server. | ||
| // See IETF Draft: // https://tools.ietf.org/html/draft-ietf-oauth-discovery-04#section-2 | ||
| OAuthMetadataFile string `json:"oauthMetadataFile"` |
There was a problem hiding this comment.
Note that this is optional and mutually exclusive in the doc.
| // OAuthMetadataFile is a path to a file containing the discovery endpoint for OAuth 2.0 Authorization | ||
| // Server Metadata for an external OAuth server. | ||
| // See IETF Draft: // https://tools.ietf.org/html/draft-ietf-oauth-discovery-04#section-2 | ||
| OAuthMetadataFile string |
There was a problem hiding this comment.
Forgot to update GetMasterFileReferences? I don't see it.
| validationResults := ValidationResults{} | ||
|
|
||
| if len(config.OAuthMetadataFile) > 0 { | ||
| if _, _, err := oauthutil.LoadOAuthMetadataFile(config.OAuthMetadataFile); err != nil { |
There was a problem hiding this comment.
This check has made the oauthmetadatafile format part of our API. Make a TODO to fix the package dependency order and promote the struct.
There was a problem hiding this comment.
Added in discovery.go, I have a card to deal with this as a followup
|
api approved. |
Signed-off-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enj, simo5 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
This helps replacing our internal Oauth Server with an external one.
REquires a metadata file to be generated by the external OAuth server and be provided for config.