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

remove check sso #386

Open
wants to merge 1 commit into
base: main
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
13 changes: 0 additions & 13 deletions keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const PostAuth = require('./middleware/post-auth')
const GrantAttacher = require('./middleware/grant-attacher')
const Protect = require('./middleware/protect')
const Enforcer = require('./middleware/enforcer')
const CheckSso = require('./middleware/check-sso')

/**
* Instantiate a Keycloak.
Expand Down Expand Up @@ -241,18 +240,6 @@ Keycloak.prototype.enforcer = function (permissions, config) {
return new Enforcer(this, config).enforce(permissions)
}

/**
* Apply check SSO middleware to an application or specific URL.
*
* Check SSO will only authenticate the client if the user is already logged-in,
* if the user is not logged-in the browser will be redirected back
* to the originally-requested URL and remain unauthenticated.
*
*/
Keycloak.prototype.checkSso = function () {
return CheckSso(this)
}

/**
* Callback made upon successful authentication of a user.
*
Expand Down
79 changes: 0 additions & 79 deletions middleware/check-sso.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/node-console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ function NodeApp () {
output(res, JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4), 'Auth Success')
})

app.get('/check-sso', keycloak.checkSso(), function (req, res) {
const authenticated = 'Check SSO Success (' + (req.session['keycloak-token'] ? 'Authenticated' : 'Not Authenticated') + ')'
output(res, authenticated)
})

app.get('/restricted', keycloak.protect('realm:admin'), function (req, res) {
const user = req.kauth.grant.access_token.content.preferred_username
output(res, user, 'Restricted access')
Expand Down
58 changes: 0 additions & 58 deletions test/keycloak-connect-web-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,64 +192,6 @@ test('Public client should be forbidden for invalid public key', t => {
})
})

test('Confidential client should be forbidden for invalid public key', t => {
t.plan(3)
const app = new NodeApp()
const client = admin.createClient(app.confidential('app3'))

return client.then((installation) => {
installation['realm-public-key'] = TestVector.wrongRealmPublicKey
app.build(installation)
return page.get(app.port).then(() =>
page.output().getText().then(text => {
t.equal(text, 'Init Success (Not Authenticated)', 'User should not be authenticated')
return page.logInButton().click().then(() =>
page.body().getText().then(text => {
t.equal(text, 'Access denied', 'Message should be access denied')
})
.then(() => page.logout(app.port))
.then(() => page.logoutConfirm())
.then(() => page.get(app.port, '/check-sso'))
.then(() => page.output().getText().then(text => t.equal(text, 'Check SSO Success (Not Authenticated)', 'User should not be authenticated')))
)
})
).then(() => {
app.destroy()
}).catch(err => {
app.destroy()
throw err
})
})
})

test('Should test check SSO after logging in and logging out', t => {
t.plan(3)

// make sure user is logged out
page.get(app.port, '/check-sso').then(() =>
page.output().getText().then(text => {
t.equal(text, 'Check SSO Success (Not Authenticated)', 'User should not be authenticated')

page.logInButton().click().then(() =>
page.login('alice', 'password').then(() =>
page.get(app.port, '/check-sso').then(() =>
page.output().getText().then(text => {
t.equal(text, 'Check SSO Success (Authenticated)', 'User should be authenticated')
return page.logout(app.port)
}).then(() => {
page.get(app.port, '/check-sso').then(() =>
page.output().getText().then(text => {
t.equal(text, 'Check SSO Success (Not Authenticated)', 'User should not be authenticated')
})
)
})
)
)
)
})
)
})

test('Public client should work with slash in the end of auth-server-url', t => {
t.plan(3)
const app = new NodeApp()
Expand Down