Skip to content

Latest commit

 

History

History
78 lines (72 loc) · 2.94 KB

用户认证.md

File metadata and controls

78 lines (72 loc) · 2.94 KB

dolphin提供了三种认证模式token, jwt, encrypt, 默认为token, 并且可自由切换

Token

基于oauth2实现的sso, 这个默认的认证方式

Your FrontEnd Project      Your BackEnd Project                     SSO
	||                              ||                              ||
	||                              ||                              ||
	||  1.     fetch api            ||                              ||
	||  -------------------------\  ||                              ||
	||      unauthorized            ||                              ||
	|| /-------------------------   ||                              ||
	||                              ||                              ||
	||  2. fetch oauth url          ||                              ||
	||  ------------------------\   ||                              ||
	|| /-------------------------   ||                              ||
	||                              ||                              ||
	||  3. goto sso oauth           ||     goto sso oauth           ||
	||  -------------------------   ||  -------------------------\  ||
	||                              ||     goto client with code    ||
	||                              || /-------------------------   ||
	||                              ||                              ||
	||                              ||                              ||
	||  4. redirect and set cookie  ||     get token by code        ||
	||                              || -------------------------\   ||
	|| /-------------------------   || /-------------------------   ||
	||                           	||                              ||

JWT

<controller name="jwt" desc="jwt认证">
    <api name="login" method="post" desc="登陆" auth="never">
        <return>
            <success type="$success"/>
            <failure type="$fail"/>
        </return>
    </api>
    <api name="check" method="get" desc="验证" auth="jwt">
        <param name="id" type="int" desc="id"/>
        <return>
            <success type="$success"/>
            <failure type="$fail"/>
        </return>
    </api>
</controller>

Encrypt

<controller name="encrypt" desc="Encrypt controller">
    <api name="add" desc="Add Encrypt" method="post" auth="encrypt">
        <param name="encrypt_info" type="$encrypt_info" desc="Encrypt info" />
        <return>
            <success type="$success"/>
            <failure type="$fail"/>
        </return>
    </api>
    <api name="info" method="get" auth="never"  desc="skip auth">
        <return>
            <success type="$success"/>
            <failure type="$fail"/>
        </return>
    </api>
</controller>