zoukankan      html  css  js  c++  java
  • Authorization-Server入门(一)

    授权服务器入门(一)

    本文主要讲授权服务器基本入门,还有client_credentials和password授权方式。client_credentials是机器或应用之间交互,没有用户介入,不对外开放注册。password需要用户交互,在获取服务器资源之前需要用户名和密码认证。另外password的授权方式返回的token有refresh_token,而client_credentials没有。

    1 工程代码

    1.1Maven依赖

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    	<groupId>org.springframework.cloud</groupId>
    	<artifactId>spring-cloud-starter-oauth2</artifactId>
    </dependency>
    

    1.2 AuthorizationServer05Application.java 配置信息

    package com.example.authorizationserver05;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;

    @EnableAuthorizationServer
    @SpringBootApplication
    public class AuthorizationServer05Application {

        public static void main(String[] args) {
            SpringApplication.run(AuthorizationServer05Application.classargs);
        }

    }


    1.3 application.properties 属性文件

    security.oauth2.client.client-id = client01
    security.oauth2.client.client-secret = 123456

    spring.security.user.name=user1
    spring.security.user.password=123456

    4 运行应用

    通过client_credentials获取token 的url http://localhost:8080/oauth/token?grant_type=client_credentials&scope=all 

    通过password获取token 的url http://localhost:8080/oauth/token?grant_type=password&scope=all

  • 相关阅读:
    Hive-0.12.0 配置Mysql的Metasotre
    cdecl、stdcall、fastcall、thiscall函数调用约定区别 (转)
    汇编函数 哪些寄存器在使用时需要保护和恢复现场
    如何用C++ 写Python模块扩展(二)
    如何用C++ 写Python模块扩展(一)
    python装饰器装饰原理探秘
    Linux 命令
    iOS为所需要的视图添加模糊效果--UIVisualEffectView
    UIAlertView ----警告视图
    Virtual Box 下Ubuntu桥接网络设置
  • 原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/13877520.html
Copyright © 2011-2022 走看看