Skip to content

Commit

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

https://bugzilla.redhat.com/show_bug.cgi?id=1562797
  • Loading branch information
AllenBW authored and simaishi committed Apr 2, 2018
1 parent c63a461 commit 98c826b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
1 change: 0 additions & 1 deletion client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ require('angular-cookies')
require('angular-resource')
require('angular-messages')
require('angular-sanitize')
require('angular-base64')
require('angular-bootstrap-switch')
require('angular-file-saver')
require('angular-ui-bootstrap')
Expand Down
13 changes: 11 additions & 2 deletions client/app/core/authentication-api.factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import base64js from 'base64-js'
const TextEncoderLite = require('text-encoder-lite').TextEncoderLite

// utf8-capable window.btoa
function base64encode (str, encoding = 'utf-8') {
let bytes = new (window.TextEncoder || TextEncoderLite)(encoding).encode(str)
return base64js.fromByteArray(bytes)
}

/** @ngInject */
export function AuthenticationApiFactory ($http, $base64, API_BASE, Session, Notifications) {
export function AuthenticationApiFactory ($http, API_BASE, Session, Notifications) {
var service = {
login: login
}
Expand All @@ -10,7 +19,7 @@ export function AuthenticationApiFactory ($http, $base64, API_BASE, Session, Not
return new Promise((resolve, reject) => {
$http.get(API_BASE + '/api/auth?requester_type=ui', {
headers: {
'Authorization': 'Basic ' + $base64.encode([userLogin, password].join(':')),
'Authorization': 'Basic ' + base64encode([userLogin, password].join(':')),
'X-Auth-Token': undefined
}
}).then(loginSuccess, loginFailure)
Expand Down
1 change: 0 additions & 1 deletion client/app/core/core.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { TaggingService } from './tagging.service.js'

export const CoreModule = angular
.module('app.core', [
'base64',
'gettext',
'miqStaticAssets',
'ngAnimate',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"actioncable": "5.1.4",
"angular": "1.6.6",
"angular-animate": "1.6.6",
"angular-base64": "2.0.5",
"angular-bootstrap-switch": "0.5.2",
"angular-cookies": "1.6.6",
"angular-datatables": "0.6.2",
Expand All @@ -63,6 +62,7 @@
"babel-eslint": "8.0.1",
"babel-loader": "7.1.2",
"babel-preset-env": "1.6.1",
"base64-js": "1.2.3",
"bootstrap-combobox": "1.0.2",
"bootstrap-switch": "3.3.4",
"brace": "0.10.0",
Expand Down Expand Up @@ -109,6 +109,7 @@
"sprintf-js": "1.1.1",
"standard-loader": "6.0.1",
"style-loader": "0.19.0",
"text-encoder-lite": "coolaj86/TextEncoderLite#e1e031b",
"ts-loader": "3.1.1",
"typescript": "2.5.3",
"ui-select": "0.19.8",
Expand Down
18 changes: 8 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ angular-animate@1.6.6:
version "1.6.6"
resolved "https://registry.yarnpkg.com/angular-animate/-/angular-animate-1.6.6.tgz#6925647b141a040d241bf125040f1a150fcd8a70"

angular-base64@2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/angular-base64/-/angular-base64-2.0.5.tgz#13255562ad1c8e8ca09b9c4b1f4ef966ac4cd093"
dependencies:
angular ">= 1.0.8"

angular-bootstrap-switch@0.5.2, angular-bootstrap-switch@^0.5.1:
version "0.5.2"
resolved "https://registry.yarnpkg.com/angular-bootstrap-switch/-/angular-bootstrap-switch-0.5.2.tgz#9469b7fc23bcb958d280edbf81692dfd1c6a9397"
Expand Down Expand Up @@ -354,7 +348,7 @@ angular@1.5.*:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.5.11.tgz#8c5ba7386f15965c9acf3429f6881553aada30d6"

angular@1.6.6, "angular@>= 1.0.8", angular@>=1.3.0, angular@>=1.4.0, angular@>=1.6.0:
angular@1.6.6, angular@>=1.3.0, angular@>=1.4.0, angular@>=1.6.0:
version "1.6.6"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.6.tgz#fd5a3cfb437ce382d854ee01120797978527cb64"

Expand Down Expand Up @@ -1149,9 +1143,9 @@ base64-arraybuffer@0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8"

base64-js@^1.0.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
base64-js@1.2.3, base64-js@^1.0.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.3.tgz#fb13668233d9614cf5fb4bce95a9ba4096cdf801"

base64id@1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -7773,6 +7767,10 @@ tar@^2.0.0, tar@^2.2.1:
fstream "^1.0.2"
inherits "2"

text-encoder-lite@coolaj86/TextEncoderLite#e1e031b:
version "1.0.2"
resolved "https://codeload.github.com/coolaj86/TextEncoderLite/tar.gz/e1e031b4a7fb89c35629340a61a06ec4f50ce7cb"

text-encoding@0.6.4, text-encoding@^0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
Expand Down

0 comments on commit 98c826b

Please sign in to comment.