Skip to content

Commit

Permalink
Merge pull request #820 from biigle/patch-1
Browse files Browse the repository at this point in the history
SSO only registration
  • Loading branch information
mzur authored May 1, 2024
2 parents f18df2f + 81a48d2 commit 833d15d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 59 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function showRegistrationForm()
*/
public function register(Request $request)
{
if ($this->isRegistrationDisabled()) {
if ($this->isRegistrationDisabled() || config('biigle.sso_registration_only')) {
abort(Response::HTTP_NOT_FOUND);
}

Expand Down
10 changes: 10 additions & 0 deletions config/biigle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
*/
'user_registration' => env('BIIGLE_USER_REGISTRATION', false),

/*
| Only allow user registration via SSO.
*/
'sso_registration_only' => env('BIIGLE_SSO_REGISTRATION_ONLY', false),

/*
| Show this message to explain why only SSO registration is available.
*/
'sso_registration_only_message' => env('BIIGLE_SSO_REGISTRATION_ONLY_MESSAGE', 'Please register via single sign-on below.'),

/*
| Enable user registration confirmation by admins. Whenever a new user is registered,
| they are created with the global "guest" role and an email notification is sent to
Expand Down
124 changes: 66 additions & 58 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,91 @@
<h1 class="logo logo--standalone"><a href="{{ route('home') }}" class="logo__biigle">BIIGLE</a></h1>
<form class="well clearfix" role="form" method="POST" action="{{ url('register') }}">

{!! Honeypot::generate('website', 'homepage') !!}
@if (config('biigle.sso_registration_only'))
<div class="panel panel-warning">
<div class="panel-body text-warning">
{{config('biigle.sso_registration_only_message')}}
</div>
</div>
@else
{!! Honeypot::generate('website', 'homepage') !!}

<p class="lead text-center">{{ trans('biigle.new_acc') }}</p>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-envelope"></i>
<p class="lead text-center">{{ trans('biigle.new_acc') }}</p>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-envelope"></i>
</div>
<input type="email" placeholder="{{ trans('form.email') }}" class="form-control" name="email" value="{{ old('email') }}" autofocus required>
</div>
<input type="email" placeholder="{{ trans('form.email') }}" class="form-control" name="email" value="{{ old('email') }}" autofocus required>
@if($errors->has('email'))
<span class="help-block">{{ $errors->first('email') }}</span>
@endif
</div>
@if($errors->has('email'))
<span class="help-block">{{ $errors->first('email') }}</span>
@endif
</div>

<div class="form-group{{ $errors->has('firstname') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user"></i>
<div class="form-group{{ $errors->has('firstname') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user"></i>
</div>
<input type="text" placeholder="{{ trans('form.firstname') }}" class="form-control" name="firstname" value="{{ old('firstname') }}" required>
</div>
<input type="text" placeholder="{{ trans('form.firstname') }}" class="form-control" name="firstname" value="{{ old('firstname') }}" required>
@if($errors->has('firstname'))
<span class="help-block">{{ $errors->first('firstname') }}</span>
@endif
</div>
@if($errors->has('firstname'))
<span class="help-block">{{ $errors->first('firstname') }}</span>
@endif
</div>

<div class="form-group{{ $errors->has('lastname') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user"></i>
<div class="form-group{{ $errors->has('lastname') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user"></i>
</div>
<input type="text" placeholder="{{ trans('form.lastname') }}" class="form-control" name="lastname" value="{{ old('lastname') }}" required>
</div>
<input type="text" placeholder="{{ trans('form.lastname') }}" class="form-control" name="lastname" value="{{ old('lastname') }}" required>
@if($errors->has('lastname'))
<span class="help-block">{{ $errors->first('lastname') }}</span>
@endif
</div>
@if($errors->has('lastname'))
<span class="help-block">{{ $errors->first('lastname') }}</span>
@endif
</div>

<div class="form-group{{ $errors->has('affiliation') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-building"></i>
<div class="form-group{{ $errors->has('affiliation') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-building"></i>
</div>
<input type="text" placeholder="Affiliation (institute name, company, etc.)" class="form-control" name="affiliation" value="{{ old('affiliation') }}">
</div>
<input type="text" placeholder="Affiliation (institute name, company, etc.)" class="form-control" name="affiliation" value="{{ old('affiliation') }}">
@if($errors->has('affiliation'))
<span class="help-block">{{ $errors->first('affiliation') }}</span>
@endif
</div>
@if($errors->has('affiliation'))
<span class="help-block">{{ $errors->first('affiliation') }}</span>
@endif
</div>

<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-lock"></i>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-lock"></i>
</div>
<input type="password" minlength="8" placeholder="{{ trans('form.password') }}" class="form-control" name="password" required>
</div>
<input type="password" minlength="8" placeholder="{{ trans('form.password') }}" class="form-control" name="password" required>
@if($errors->has('password'))
<span class="help-block">{{ $errors->first('password') }}</span>
@endif
</div>
@if($errors->has('password'))
<span class="help-block">{{ $errors->first('password') }}</span>
@endif
</div>

@mixin('registrationForm')
@mixin('registrationForm')

@include('auth.partials.privacy-checkbox')
@include('auth.partials.terms-checkbox')
@include('auth.partials.privacy-checkbox')
@include('auth.partials.terms-checkbox')

@if ($errors->has('homepage'))
<p class="text-danger">{{ $errors->first('homepage') }}</p>
@endif
@if ($errors->has('website'))
<p class="text-danger">{{ $errors->first('website') }}</p>
@endif
@if ($errors->has('homepage'))
<p class="text-danger">{{ $errors->first('homepage') }}</p>
@endif
@if ($errors->has('website'))
<p class="text-danger">{{ $errors->first('website') }}</p>
@endif

<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit" class="btn btn-success btn-block" value="Sign up" onclick="this.disabled=true;this.form.submit();">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit" class="btn btn-success btn-block" value="Sign up" onclick="this.disabled=true;this.form.submit();">
@endif

@if (!empty(app('modules')->getViewMixins('registerButton')))
<hr>
Expand Down
7 changes: 7 additions & 0 deletions tests/php/Http/Controllers/Auth/RegisterControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public function testRegisterRouteDisabled()
$this->post('register')->assertStatus(404);
}

public function testRegisterRouteSsoOnly()
{
config(['biigle.sso_registration_only' => true]);
$this->get('register')->assertStatus(200);
$this->post('register')->assertStatus(404);
}

public function testRegisterFieldsRequired()
{
$this->get('register');
Expand Down

0 comments on commit 833d15d

Please sign in to comment.