Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selecting a user from dropdown #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ function _runServer(argv) {

const showUser = function (req, res, next) {
res.render('user', {
user: req.user,
user: req.user || req.presets[0],
presets: req.presets || [req.user],
metadata: req.metadata,
authnRequest: req.authnRequest,
idp: req.idp.options
Expand Down Expand Up @@ -432,6 +433,7 @@ function _runServer(argv) {
app.use(function(req, res, next){
req.user = argv.config.user;
req.user.sessionIndex = Math.abs(getHashCode(req.session.id));
req.presets = argv.config.presets;
req.metadata = argv.config.metadata;
req.idp = { options: idpOptions };
next();
Expand Down Expand Up @@ -469,6 +471,12 @@ function _runServer(argv) {
delete authOptions.encryptionPublicKey;
}

if(req.body.preset) {
req.user = req.presets.find(function(u) {
return u.userName === req.body.preset;
});
}

// Set Session Index
authOptions.sessionIndex = req.user.sessionIndex;

Expand Down
35 changes: 27 additions & 8 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@

/**
* User Profile
* User Profiles
*/
var profile = {
userName: 'saml[email protected]',
var presets = [{
userName: 'saml_1[email protected]',
nameIdFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
firstName: 'Saml',
firstName: 'Saml 1',
lastName: 'Jackson',
displayName: 'saml jackson',
email: 'saml[email protected]',
displayName: 'saml1 jackson',
email: 'saml1[email protected]',
mobilePhone: '+1-415-555-5141',
groups: 'Simple IdP Users, West Coast Users, Cloud Users'
}
},{
userName: '[email protected]',
nameIdFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
firstName: 'Saml 2',
lastName: 'Jackson',
displayName: 'saml2 jackson',
email: '[email protected]',
mobilePhone: '+1-415-555-5141',
groups: 'Simple IdP Users, West Coast Users, Cloud Users'
},{
userName: '[email protected]',
nameIdFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
firstName: 'Saml 3',
lastName: 'Jackson',
displayName: 'saml3 jackson',
email: '[email protected]',
mobilePhone: '+1-415-555-5141',
groups: 'Simple IdP Users, West Coast Users, Cloud Users'
}]

/**
* SAML Attribute Metadata
Expand Down Expand Up @@ -61,6 +79,7 @@ var metadata = [{
}];

module.exports = {
user: profile,
user: presets[0],
presets: presets,
metadata: metadata
}
26 changes: 26 additions & 0 deletions views/user.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@
{{/if}}

<div class="col-md-8 col-md-offset-2">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-user"><span>Default Users</span></i></h3>
</div>
<div class="panel-body">
<form action="/sso" class="form-horizontal form-profile" method="post" role="form">
<div class="form-group">
<label class="col-sm-3 control-label" for="preset">Select User</label>
<div class="col-sm-9">
<select class="form-control" id="preset" name="preset">
{{#each presets}}
<option value="{{this.userName}}">
{{this.displayName}}
</option>
{{/each}}
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-right">
<button class="btn btn-primary input-xlarge" type="submit"><i class="fa fa-sign-in"><span>Sign in</span></i></button>
</div>
</div>
</form>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-code"><span>SAML Assertion</span></i></h3>
Expand Down
Loading