Expand my Community achievements bar.

SOLVED

Sling Authentication Framework

Avatar

Level 3

Hi all, I am new to sling authentication and have no prior knowledge about it. I am creating a login component which will sign in the users in created in home/groups/custom_group. I will use HTL for the same.

 

Now I want to know how I should I authenticate these users present in the custom group using sling authenticationn framework.

 

I found few docs regarding the topic but still confused on how to implement it in AEM.

 

Thanks in advance

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
4 Replies

Avatar

Employee Advisor

Are you implementing this for AEM author or publish? And with "login" do you mean the traditional username/password combination or something more modern like SAML?

Avatar

Level 3

I have to implement it on publish but for now for testing the component I am doing it on author. And I have made a custom login component i.e traditional username and password.

Avatar

Correct answer by
Community Advisor

Avatar

Community Advisor

Hi @janhavi_singh ,

If you are looking for a component for login using user/password. You just need few lines of code. Sharing sightly code used in component. You can add sling model as per need. This sightly is enough for working login component. 
You just need to have fields name and action url. 
hidden field(resource) used to set redirect url after successful login.

<div class="row">
    <div class="col-lg-6">
        <div class="p-5">
            <div class="text-center">
                <h1 class="h4 text-gray-900 mb-4">Welcome Back!</h1>
            </div>
                <form class="user" method="POST" action="${currentPage.getPath}/j_security_check">
                    <input type="hidden" name="resource" value="${'/content/we-retail/us/en/men.html'}">
                    <input type="hidden" name="_charset_" value="UTF-8">
                    <div class="form-group">
                        <input type="text" class="form-control form-control-user" id="userId" placeholder="User" name="j_username">
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control form-control-user" id="userPassword" placeholder="Password" name="j_password">
                    </div>
                    <button class="btn btn-primary btn-user btn-block" type="submit">
                        Login
                    </button>
                </form>
         </div>
    </div>
</div>