Merge pull request 'token-plugin' (#15) from token-plugin into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/15
This commit is contained in:
commit
d3a2256334
5
.gitignore
vendored
5
.gitignore
vendored
@ -29,3 +29,8 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
|
||||
### Python ###
|
||||
__pycache__
|
||||
.pytest_cache
|
11
README.md
11
README.md
@ -20,11 +20,22 @@ server.port=1285
|
||||
```
|
||||
|
||||
Następnym krokiem jest odpalenie poniższych komend w terminalu.
|
||||
|
||||
```
|
||||
cd restservice
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
## Token
|
||||
|
||||
Żeby tesotwać API wpełni potrzebny nam jest token który otrzymujemy na podstawie ticketa z systemu autoryzacyjnego **CAS**. Z tego powodu system autoryzacji działa inaczej niż w "książkowych" restowych aplikacjach i np Postman za nas jej nie dokona. Musimy mu podać już uzyskany token. Aby łatwo go uzyskać odpal skrypt
|
||||
|
||||
```
|
||||
python gettoken.py
|
||||
```
|
||||
|
||||
Na koniec w przęglądarce dostaniesz w odpowiedzi token. W samym pliku można zmienić porty aplikacji jeśli to potrzebne.
|
||||
|
||||
## Packaging
|
||||
|
||||
Zeby spakowac apke do `jara` wystarcza dwie komendy zaczynajac z glownego katalogu projektu
|
||||
|
39
gettoken.py
Executable file
39
gettoken.py
Executable file
@ -0,0 +1,39 @@
|
||||
import webbrowser
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer, SimpleHTTPRequestHandler
|
||||
import urllib.parse as urlparse
|
||||
from urllib.parse import parse_qs
|
||||
import sys
|
||||
import requests as r
|
||||
|
||||
API_ADDRESS = "http://localhost:1285"
|
||||
PORT = 3000
|
||||
|
||||
|
||||
class S(BaseHTTPRequestHandler):
|
||||
def _set_response(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/html')
|
||||
self.end_headers()
|
||||
|
||||
def do_GET(self):
|
||||
parsed = urlparse.urlparse(str(self.path))
|
||||
ticket = str(parse_qs(parsed.query)['ticket'][0])
|
||||
print(ticket)
|
||||
response = r.get(API_ADDRESS + "/token?ticket=" + ticket)
|
||||
self._set_response()
|
||||
self.wfile.write("Your token: {}".format(
|
||||
response.text).encode('utf-8'))
|
||||
|
||||
|
||||
def wait_for_request(server_class=HTTPServer,
|
||||
handler_class=S):
|
||||
server_address = ('localhost', PORT)
|
||||
httpd = server_class(server_address, handler_class)
|
||||
return httpd.handle_request()
|
||||
|
||||
|
||||
url = 'https://cas.amu.edu.pl/cas/login?service=http://localhost:' + \
|
||||
str(PORT) + '&locale=pl'
|
||||
|
||||
webbrowser.open_new_tab(url)
|
||||
wait_for_request()
|
12
pom.xml
12
pom.xml
@ -2,11 +2,11 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.plannaplan</groupId>
|
||||
<artifactId>backend</artifactId>
|
||||
@ -78,7 +78,7 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<modules>
|
||||
<modules>
|
||||
<module>buisnesslogic</module>
|
||||
<module>restservice</module>
|
||||
</modules>
|
||||
|
Loading…
Reference in New Issue
Block a user