hide u2f related stuff from web ui if appid is set to empty

to allow the admin to disable u2f
This commit is contained in:
jcj83429
2016-11-28 01:12:03 -08:00
parent c2e7b5312b
commit d795ca006e
4 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -243,8 +243,8 @@ func (m *Handler) Close() error {
type webSettings struct {
Auth struct {
OIDCConnectors []string `json:"oidc_connectors"`
U2fAppId string `json:"u2f_appid"`
} `json:"auth"`
U2fAppId string `json:"u2f_appid"`
}
func (m *Handler) getSettings(w http.ResponseWriter, r *http.Request) (interface{}, error) {
@@ -263,7 +263,7 @@ func (m *Handler) getSettings(w http.ResponseWriter, r *http.Request) (interface
if err != nil {
return nil, trace.Wrap(err)
}
settings.U2fAppId = u2fAppId
settings.Auth.U2fAppId = u2fAppId
out, err := json.Marshal(settings)
if err != nil {
return nil, trace.Wrap(err)
+2 -1
View File
@@ -75,6 +75,7 @@ var LoginInputForm = React.createClass({
let {isProcessing, isFailed, message } = this.props.attemp;
let providers = cfg.getAuthProviders();
let useGoogle = providers.indexOf(PROVIDER_GOOGLE) !== -1;
let useU2f = !!cfg.getU2fAppId();
return (
<form ref="form" className="grv-login-input-form">
@@ -90,7 +91,7 @@ var LoginInputForm = React.createClass({
<input autoComplete="off" valueLink={this.linkState('token')} className="form-control required" name="token" placeholder="Two factor token (Google Authenticator)"/>
</div>
<button onClick={this.onLogin} disabled={isProcessing} type="submit" className="btn btn-primary block full-width m-b">Login</button>
<button onClick={this.onLoginWithU2f} disabled={isProcessing} type="submit" className="btn btn-primary block full-width m-b">Login with U2F</button>
{ useU2f ? <button onClick={this.onLoginWithU2f} disabled={isProcessing} type="submit" className="btn btn-primary block full-width m-b">Login with U2F</button> : null }
{ useGoogle ? <button onClick={this.onLoginWithGoogle} type="submit" className="btn btn-danger block full-width m-b">With Google</button> : null }
{ isProcessing && this.state.secondFactorType == SECOND_FACTOR_TYPE_U2F ? (<label className="help-block">Insert your U2F key and press the button on the key</label>) : null }
{ isFailed ? (<label className="error">{message}</label>) : null }
+4
View File
@@ -23,6 +23,7 @@ var GoogleAuthInfo = require('./googleAuthLogo');
var {ErrorPage, ErrorTypes} = require('./msgPage');
var {TeleportLogo} = require('./icons.jsx');
var {SECOND_FACTOR_TYPE_HOTP, SECOND_FACTOR_TYPE_U2F} = require('app/services/auth');
var cfg = require('app/config');
var InviteInputForm = React.createClass({
@@ -87,6 +88,7 @@ var InviteInputForm = React.createClass({
render() {
let {isProcessing, isFailed, message } = this.props.attemp;
let useU2f = !!cfg.getU2fAppId();
return (
<form ref="form" className="grv-invite-input-form">
<h3> Get started with Teleport </h3>
@@ -117,6 +119,7 @@ var InviteInputForm = React.createClass({
className="form-control"
placeholder="Password confirm"/>
</div>
{ useU2f ?
<div className="form-group">
<input
type="radio"
@@ -131,6 +134,7 @@ var InviteInputForm = React.createClass({
onChange={ this.onSecondFactorTypeChanged }/>
U2F
</div>
: null }
{ this.state.secondFactorType == SECOND_FACTOR_TYPE_HOTP ?
<div className="form-group">
<input
+6 -1
View File
@@ -28,7 +28,8 @@ let cfg = {
displayDateFormat: 'l LTS Z',
auth: {
oidc_connectors: []
oidc_connectors: [],
u2f_appid: ""
},
routes: {
@@ -116,6 +117,10 @@ let cfg = {
return cfg.auth.oidc_connectors;
},
getU2fAppId(){
return cfg.auth.u2f_appid;
},
init(config={}){
$.extend(true, this, config);
}