Skip to content

Commit

Permalink
Merge pull request #3682 from himdel/password-utf-bz1527316
Browse files Browse the repository at this point in the history
API js - use base64encode which can deal with UTF8 passwords
(cherry picked from commit aa6b2fd)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1562797
  • Loading branch information
mzazrivec authored and simaishi committed Apr 2, 2018
1 parent 9b3ce84 commit e6aeca1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/miq_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
API.post = withData('POST');
API.put = withData('PUT');

var base64encode = window.btoa; // browser api

API.login = function(login, password) {
API.logout();

Expand Down
8 changes: 8 additions & 0 deletions app/javascript/packs/compat-common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import base64js from 'base64-js';
import TextEncoderLite from 'text-encoder-lite';

// utf8-capable window.btoa
window.base64encode = (str, encoding = 'utf-8') => {
let bytes = new (TextEncoder || TextEncoderLite)(encoding).encode(str);
return base64js.fromByteArray(bytes);
};
6 changes: 6 additions & 0 deletions app/views/layouts/login.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
= javascript_include_tag 'miq_debug'
= stylesheet_link_tag 'miq_debug'

= javascript_pack_tag 'vendor'
-# FIXME: the conditional below is a temporary fix for a webpacker issue, remove when it's resolved
- unless Rails.env.test?
- Webpacker::Manifest.instance.data.keys.each do |pack|
= javascript_pack_tag pack if pack.ends_with? '-common.js'

= render :partial => 'layouts/i18n_js'

%body{:class => ::Settings.server.custom_login_logo ? 'whitelabel' : ''}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"@angular/core": "~4.0.3",
"@angular/platform-browser": "~4.0.3",
"@angular/platform-browser-dynamic": "~4.0.3",
"base64-js": "~1.2.3",
"core-js": "~2.4.1",
"rxjs": "~5.3.0",
"text-encoder-lite": "~1.0.1",
"ui-select": "0.19.8",
"zone.js": "~0.8.5"
},
Expand Down

0 comments on commit e6aeca1

Please sign in to comment.