I'm trying to do api-auth by checking generated token from the logged-in user's username with md5 encryption method on the fly in laravel 5.5, and don't want to save the token into the users' table. When the user logs out the token will be invalid. The URL will be like this:
How can I do this?
Added - It is a test project from 44th world skills competition and following is from the test project document:
- Authentication
a. Login (v1/auth/login)
Description: For client to get login token via username and password
Request method: POST
Header: header authorization basic
Requested parameter:
- Body:
o Username
o password
Response result:
- If success,
o header: response status: 200
o body:
token`: authorization token (to be valid until logout). Token will be generated by the system from logged in username with md5 encryption method
Role (ADMIN / USER)
- If username/password not correct or empty,
o header: response status: 401
o body: message: invalid login
b. Logout (v1/auth/logout?token={AUTHORIZATION_TOKEN})
Description: For server to invalid the user’s token
Request method: GET
Header: header authorization basic
Response result:
- If success,
o header: response status: 200
o body:
message: logout success
- If unauthorized user access it,
data:
o Message: Unauthorized user
o Response status: 401
- Place
a. All Places (v1/place?token={AUTHORIZATION_TOKEN})
Description: For client to list all places in the database (include user’s search history indexed based on the frequency)
Request method: GET
Header: header authorization basic
Response result:
body:
o All data on array; consists of id, name, latitude, longitude, x, y, image_path, description.
o Response status: 200
- If unauthorized user access it,
data:
o Message: Unauthorized user
o Response status: 401
...