Implement OAuth2 client authentication for password and application flow
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
scopes: {},
|
||||
isPasswordFlow: false
|
||||
isPasswordFlow: false,
|
||||
clientAuthenticationType: 'none'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
@@ -21,7 +22,12 @@ SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
this.set('isPasswordFlow', attributes.flow && attributes.flow === 'password');
|
||||
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');
|
||||
}
|
||||
this.on('change', this.validate);
|
||||
},
|
||||
|
||||
@@ -43,6 +49,11 @@ SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user