-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Implement OAuth2 password flow #2397
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
|
||
SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({ | ||
defaults: { | ||
scopes: {} | ||
scopes: {}, | ||
isPasswordFlow: false, | ||
clientAuthenticationType: 'none' | ||
}, | ||
|
||
initialize: function () { | ||
|
@@ -19,6 +21,13 @@ SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({ | |
attributes.scopes = scopes; | ||
this.attributes = attributes; | ||
} | ||
|
||
if (this.attributes && this.attributes.flow) { | ||
var flow = this.attributes.flow; | ||
this.set('isPasswordFlow', flow === 'password'); | ||
this.set('requireClientAuthentication', flow === 'application'); | ||
this.set('clientAuthentication', flow === 'password' || flow === 'application'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's advisable what you say. |
||
} | ||
this.on('change', this.validate); | ||
}, | ||
|
||
|
@@ -35,6 +44,16 @@ SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({ | |
|
||
validate: function () { | ||
var valid = false; | ||
if (this.get('isPasswordFlow') && | ||
(!this.get('username'))) { | ||
return false; | ||
} | ||
|
||
if (this.get('clientAuthenticationType') in ['basic', 'request-body'] && | ||
(!this.get('clientId'))) { | ||
return false; | ||
} | ||
|
||
var scp = this.get('scopes'); | ||
var idx = _.findIndex(scp, function (o) { | ||
return o.checked === true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,4 +201,9 @@ | |
} | ||
|
||
.api-popup-actions { padding-top: 10px; } | ||
|
||
fieldset { | ||
padding-bottom: 10px; | ||
padding-left: 20px; | ||
} | ||
} |
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.
Can this default be configurable? In fact, I would love to have it configured to be Basic by default as it is what the RFC describes.