懒羊羊
2023-08-30 71e81ed1d12e4d69f53c8ad9e066650ad4186293
提交 | 用户 | 时间
71e81e 1 /**
2  * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
3  * <p>
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package cn.stylefeng.guns.base.auth.service;
17
18 import cn.stylefeng.guns.base.auth.model.LoginUser;
19
20 import java.util.List;
21
22 /**
23  * Auth相关数据库的操作
24  *
25  * @author fengshuonan
26  * @date 2016年12月5日 上午10:23:34
27  */
28 public interface AuthService {
29
30     /**
31      * 登录
32      *
33      * @param username 账号
34      * @param password 密码
35      * @return token
36      */
37     String login(String username, String password);
38
39     /**
40      * 登录(直接用账号登录)
41      *
42      * @param username 账号
43      * @return token
44      */
45     String login(String username);
46
47     /**
48      * 创建登录cookie
49      */
50     void addLoginCookie(String token);
51
52     /**
53      * 退出当前用户
54      */
55     void logout();
56
57     /**
58      * 退出
59      */
60     void logout(String token);
61
62     /**
63      * 根据账号获取登录用户
64      *
65      * @param account 账号
66      */
67     LoginUser user(String account);
68
69     /**
70      * 获取权限列表通过角色id
71      *
72      * @param roleId 角色id
73      */
74     List<String> findPermissionsByRoleId(Long roleId);
75
76     /**
77      * 检查当前登录用户是否拥有指定的角色访问当
78      *
79      * @param roleNames 角色名称集合
80      */
81     boolean check(String[] roleNames);
82
83     /**
84      * 检查当前登录用户是否拥有当前请求的servlet的权限
85      */
86     boolean checkAll();
87
88 }