In: Computer Science
Research and write a report summarizing the different options available for authorization or authentication in Spark, that is, how is data protected from inadvertent and/or unauthorized access. Your report should be no less than 1.000 words, not including references and citations.
Different Types of Authentication in Spark:
JSON Web Token(JWT): JWT comprises of 3 parts i.e., Header, Payload and Signature
Header contains 2 parts the token type and the hashing algorithm. Payload contains all the data we want to transmit, and Signature consists of header and payload in encoded form appended with a secret key. A combination of these 3 generates the JWT token.
Whenever a User makes a login request with their credentials the server verifies and sends back a token containing token containing identity of the user which is later stored on the client system and that allows the user inside the application.
Now when a user wants to access a resource the token is added to the authorization header and send to the server. The server then checks the token and lets him or her access the resource if it matches.
There are 2 JWT interfaces in Spark Jwt\GeneratorInterface and Jwt\ParserInterface which generates and parses tokens respectively.
Authentication Handler: It is a middleware that co-ordinates the authentication process. It consists of Token, Credential, Adapter and Request Filter.
Firstly, the Tokens are accepted and decoded for validation from the application sending the request. Then credentials check for the correct username and password of the user that comes along with the request trying to access it.
Then tokens are generated based upon existing tokens for a user or new tokens for an existing user.
If they don’t match then an exception is thrown.
Incase if no value is specified for authentication then Request Filter will come into play and authenticate all the existing users.