STRATGIES, HASHING, PASSPORT.JS
Presenter:
Yauheni Pozdnyakov
Authorization
Strategies
Types of authorization
Crypto Hashing
Authentication
What is authentication?
“Determining the identity of a person”
Why would I need to authenticate you?
“To be sure that you are the person that you claim to be”
Something that you know
Password, PIN number, secret key, secret handshake, secret questions ...
Something that you have
Fingerprint, voice recognition, face recognition ...
Something that you are (biometrics)
IDs, badges, physical key ...
Good as long as
Gets compromised as soon as
Identification
Authentication
Authentication is the process of verifying who you are. When you log on to a PC with a user name and password you are authenticating.
Authentication is about who somebody is
An information system where
Security issues
In order to preserve confidentiality and integrity of data, some people can have more or less privileges to access to some contents
Secure an information system
Complete mediation
Every access to every object is checked
Least privilege
Do not grant a subject more rights than he needs
Separation of privileges
Avoid conflicts of interests
Non-intrusiveness and user-friendly
User acceptance
Creation
Who can create an object and define its rights?
Modification
Who can modify the rights?
Delegation
Is it possible to give a right to do something to someone else?
Core
"Who can do what?": Access Control Matrix
Administration model
Based on the principe of ownership
RBAC: Role Based Access Control
DAC: Discretionary Access Control Model
Core
Introduction of the concept of role
Administration model
ARBAC'97
Store by column: access control lists
Store by row: capability lists
Idea:
The good
The eval
Idea:
The good
The eval
Authorization is the function of specifying access rights to resources, which is related to information security and computer security in general and to access control in particular.
Authorization is the process to confirm what you are authorized to perform. For example, you are allowed to login to your Unix server via ssh client, but you are not allowed to browser / data2 or other file systems. Authorization occurs after authentication is successful. Authorization can be controlled at the level of file system or use a variety of configuration options such as application level chroot. Normally, the connection attempt should be good authentication and authorization by the system. You can easily find out why the connection attempts are either accepted or rejected with the help of two factors.
OAuth is an open-standard authorization protocol or framework that describes how unrelated servers and services can safely allow authenticated access to their assets without actually sharing the initial, related, single logon credential. In authentication parlance, this is known as secure, third-party, user-agent, delegated authorization.
Basic authentication is a simple way of protecting a website at the edge. Users enter a username and password combination to access pages protected by basic authentication. You can use basic authentication to restrict access to low-risk assets like testing and staging environments.
SAML (Security Assertion Mark-up Language) is an umbrella standard that covers federation, identity management and single sign-on (SSO).
// Use the LocalStrategy within Passport to register/"signup" users.
passport.use('local-signup', new LocalStrategy(
{passReqToCallback : true}, //allows us to pass back the request to the callback
(req, username, password, done) => funct.localReg(username, password)
.then(function (user) {
if (user) {
console.log("REGISTERED: " + user.username);
req.session.success = 'You are successfully registered and logged in ' + user.username + '!';
done(null, user);
}
if (!user) {
console.log("COULD NOT REGISTER");
req.session.error = 'That username is already in use, please try a different one.'; //inform user could not log them in
done(null, user);
}
})
.fail(function (err){
console.log(err.body);
});
));passport.use('local-signin', new LocalStrategy(
{passReqToCallback : true}, //allows us to pass back the request to the callback
(req, username, password, done) => funct.localAuth(username, password)
.then(function (user) {
if (user) {
console.log("LOGGED IN AS: " + user.username);
req.session.success = 'You are successfully logged in ' + user.username + '!';
done(null, user);
}
if (!user) {
console.log("COULD NOT LOG IN");
req.session.error = 'Could not log user in. Please try again.'; //inform user could not log them in
done(null, user);
}
})
.fail(function (err){
console.log(err.body);
});
));passport.serializeUser(function(user, done) {
console.log("serializing " + user.username);
done(null, user);
});
passport.deserializeUser(function(obj, done) {
console.log("deserializing " + obj);
done(null, obj);
});function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
req.session.error = 'Please sign in!';
res.redirect('/signin');
} // create private and public routes
const publicApi = express.Router();
const secureApi = express.Router();
// add private middleware
if (config.app_env() !== 'test') {
secureApi.use(isAuthenticated);
secureApi.use(anyRole);
}
// some public routes
publicApi.use('/auth', formParser, authRoute.init(app));
publicApi.get('/api/account/current', accountRoute.get);
publicApi.get('/api/user/current', userRoute.get);
publicApi.use('/healthcheck', healthCheck);
// some private routes
secureApi.use('/api/myfirstapi', firstRoute);
secureApi.use('/api/mysecondapi', secondRoute);
secureApi.use('/api/methirdapi', thirdRoute);
secureApi.use('/api/myfourthapi', fourthRoute);
app.use(publicApi);
app.use(secureApi);
MD5
SHA256
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA.
Compact: Because of their smaller size, JWTs can be sent through a URL, POST parameter, or inside an HTTP header. Additionally, the smaller size means transmission is fast.
Self-contained: The payload contains all the required information about the user, avoiding the need to query the database more than once