mirror of https://github.com/rancher/ui.git
Ping Login form
This commit is contained in:
parent
34f454ab47
commit
73f663b0a8
|
|
@ -0,0 +1,16 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import { get, set } from '@ember/object';
|
||||
|
||||
export default Component.extend({
|
||||
saml: service(),
|
||||
errors: null,
|
||||
|
||||
actions: {
|
||||
authenticate() {
|
||||
get(this, 'saml').login().catch( ( err ) => {
|
||||
set(this, 'errors', [err.message])
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<form {{action "authenticate" on="submit"}} class="row pt-10 pb-10">
|
||||
<button disabled={{waiting}} class="btn bg-primary" {{action "authenticate"}}>
|
||||
<i class="icon icon-ping"></i> {{t 'loginPing.buttonText'}}
|
||||
</button>
|
||||
{{top-errors errors=errors}}
|
||||
</form>
|
||||
|
|
@ -131,6 +131,10 @@ export default Controller.extend({
|
|||
return !!get(this, 'access.providers').findBy('id', 'github');
|
||||
}),
|
||||
|
||||
isPing: computed('access.providers', function() {
|
||||
return !!get(this, 'access.providers').findBy('id', 'ping');
|
||||
}),
|
||||
|
||||
isActiveDirectory: computed('access.provider', function() {
|
||||
return !!get(this, 'access.providers').findBy('id', 'activedirectory');
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@
|
|||
{{login-azure action="started"}}
|
||||
{{/if}}
|
||||
|
||||
{{#if isPing}}
|
||||
{{login-ping action="started"}}
|
||||
{{/if}}
|
||||
|
||||
{{#if isLocal}}
|
||||
{{login-user-pass
|
||||
action="authenticate"
|
||||
|
|
|
|||
|
|
@ -8,13 +8,25 @@ export default Service.extend({
|
|||
access: service(),
|
||||
app: service(),
|
||||
|
||||
test(config, cb) {
|
||||
login() {
|
||||
const finalUrl = window.location.origin;
|
||||
const provider = get(this, 'access.providers').findBy('id', 'ping');
|
||||
|
||||
return provider.doAction('login', { finalRedirectUrl: finalUrl }).then( ( resp ) => {
|
||||
return window.location.href = resp.idpRedirectUrl;
|
||||
}).catch(() => {
|
||||
return {
|
||||
type: 'error',
|
||||
message: get(this, 'intl').t('authPage.saml.authError')
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
test(config, cb) {
|
||||
let responded = false;
|
||||
|
||||
window.onAuthTest = (err, code) => {
|
||||
if ( !responded ) {
|
||||
|
||||
let authConfig = code;
|
||||
|
||||
responded = true;
|
||||
|
|
@ -28,7 +40,6 @@ export default Service.extend({
|
|||
|
||||
let timer = setInterval(function() {
|
||||
if (popup && popup.closed ) {
|
||||
|
||||
clearInterval(timer);
|
||||
|
||||
if ( !responded ) {
|
||||
|
|
@ -52,11 +63,9 @@ export default Service.extend({
|
|||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
},
|
||||
|
||||
finishTest(config, code, cb) {
|
||||
|
||||
const authConfig = config;
|
||||
|
||||
set(authConfig, 'enabled', true);
|
||||
|
|
@ -64,16 +73,13 @@ export default Service.extend({
|
|||
const allowedPrincipalIds = get(authConfig, 'allowedPrincipalIds') || [];
|
||||
|
||||
return authConfig.save().then(() => {
|
||||
|
||||
let found = false;
|
||||
const myPIds = get(this, 'access.me.principalIds');
|
||||
|
||||
myPIds.forEach( (id) => {
|
||||
|
||||
if (allowedPrincipalIds.indexOf(id) >= 0) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if ( !found && !allowedPrincipalIds.length) {
|
||||
|
|
@ -83,7 +89,6 @@ export default Service.extend({
|
|||
return authConfig.save().then(() => {
|
||||
window.location.href = window.location.href;
|
||||
});
|
||||
|
||||
}).catch((err) => {
|
||||
cb(err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ authPage:
|
|||
post: 'Waiting to hear back from Ping'
|
||||
providerName:
|
||||
ping: Ping
|
||||
authError: 'Github access was not authorized'
|
||||
authError: 'Access was not authorized'
|
||||
popupError: 'Please disable your pop-up blocker and click "Authenticate" again.'
|
||||
|
||||
shibboleth:
|
||||
|
|
@ -4190,6 +4190,9 @@ loginGithub:
|
|||
loginAzure:
|
||||
buttonText: Log In with Azure AD
|
||||
|
||||
loginPing:
|
||||
buttonText: Log In with Ping Federate
|
||||
|
||||
loginUserPass:
|
||||
local: Use a Local User
|
||||
provider: "{kind}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue