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
  • Loading branch information
AllenBW committed Mar 28, 2018
2 parents a3593b8 + eeb03c9 commit 0ae3d01
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
1 change: 0 additions & 1 deletion client/app.js
Expand Up @@ -26,7 +26,6 @@ require('angular-cookies')
require('angular-resource')
require('angular-messages')
require('angular-sanitize')
require('angular-base64')
require('angular-gettext')
require('angular-ui-bootstrap')
require('@uirouter/angularjs')
Expand Down
13 changes: 11 additions & 2 deletions client/app/core/authentication-api.factory.js
@@ -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
Expand Up @@ -44,7 +44,6 @@ import 'ng-redux'

export const CoreModule = angular
.module('app.core', [
'base64',
'gettext',
'miqStaticAssets',
'ngAnimate',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -44,7 +44,6 @@
"actioncable": "5.1.5",
"angular": "1.6.9",
"angular-animate": "1.6.9",
"angular-base64": "2.0.5",
"angular-bootstrap-switch": "0.5.2",
"angular-cookies": "1.6.9",
"angular-drag-and-drop-lists": "2.1.0",
Expand All @@ -62,6 +61,7 @@
"babel-eslint": "8.2.2",
"babel-loader": "7.1.4",
"babel-preset-env": "1.6.1",
"base64-js": "1.2.3",
"body-parser": "1.18.2",
"bootstrap-combobox": "1.0.2",
"bootstrap-datepicker": "1.7.1",
Expand Down Expand Up @@ -112,6 +112,7 @@
"sprintf-js": "1.1.1",
"standard-loader": "6.0.1",
"style-loader": "0.20.2",
"text-encoder-lite": "coolaj86/TextEncoderLite#e1e031b",
"ts-loader": "3.5.0",
"typescript": "2.7.2",
"ui-select": "0.19.8",
Expand Down
14 changes: 6 additions & 8 deletions yarn.lock
Expand Up @@ -311,12 +311,6 @@ angular-animate@1.6.9:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular-animate/-/angular-animate-1.6.9.tgz#a0f926c1ba3190bd8929ef966a7fa79760682622"

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 @@ -434,7 +428,7 @@ angular@1.5.*:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.5.11.tgz#8c5ba7386f15965c9acf3429f6881553aada30d6"

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

Expand Down Expand Up @@ -1246,7 +1240,7 @@ 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:
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"

Expand Down Expand Up @@ -9310,6 +9304,10 @@ test-exclude@^4.1.1:
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"

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:
version "0.6.4"
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
Expand Down

0 comments on commit 0ae3d01

Please sign in to comment.