Authentication / Authorization

The Beapi Springboot Starter has several built-in tools to help you get loggedIn/Logout and secure your users access.. Below is an explanation of those tools and how to use them.


Authentication/Authorization

User management including authentication/authorization are BUILT-IN. You can login and get a token using the following methids...

  • Authentication
    Assuming you already have a 'registered acct', you can 'authenticate' using the following command:

    curl -v -c ./cookies.txt -H "Content-Type: application/json" -X POST -d '{"username":"YOUR_USERNAME","password":"YOUR_PASSWORD"}' http://YOURSITE:8080/authenticate

    An example of authenticating via Javascript/Jquery is below:



  • Authorization
    Once you get back a token, you can use it in followup requests like so:

    curl -v -b ./cookies.txt -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_TOKEN" --request GET "http://YOURSITE:8080/v1.0/user/show?id%3Dtest"

Mail Server Setup

Two-factor auth is used for 'registration/'forgot password' functionality. For this, you need to create an acct at 'twilio'/'sendgrid'


The following variables in the beapi_api.yml file, need to be changed to match your mail server setup...

...
    mail:
        host: 'smtp.sendgrid.net'
        port: 587
        username: 'apikey'
        password: "password"
        fromAddress: 'donotrespond@yoursite.com'
        senderName: 'beapi.io'
        smtpAuth: true
        smtpStarttlsEnable: true
        testemail: 'youremail@gmail.com'